summaryrefslogtreecommitdiffstats
path: root/tools/gfx/cpu/render-cpu.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-10-18 12:19:45 -0700
committerGitHub <noreply@github.com>2021-10-18 12:19:45 -0700
commit2f44d9e01234911dd563f0456b9d861fd8db286d (patch)
treee2727f31654ebc93bae6a1de4b25586be6fb9d10 /tools/gfx/cpu/render-cpu.cpp
parent87e7c49fbfccd54be0d1cee61fba8f309b1f792e (diff)
GFX: implement mutable shader objects. (#1963)
* GFX: implement mutable shader objects. * Revert unnecessary changes * Revert more changes. * Fix clang errors. * Fix clang/gcc errors. * Fix clang errors. * Remove CPU test. * Fix after merge. * Fix after merge. * Remove gl test * Code review fixes. * Fixing all vk validation errors. * Flush test output more often. * Fix a crash in `specializeDynamicAssociatedTypeLookup`. * temporarily disable std-lib-serialize test to see what happens * Fix crashes. * Make sure cpu gfx unit tests are properly disabled on TeamCity. * Disable cpu test. * Fix. * Fix cuda. * Disable nv-ray-tracing-motion-blur Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tools/gfx/cpu/render-cpu.cpp')
-rw-r--r--tools/gfx/cpu/render-cpu.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/tools/gfx/cpu/render-cpu.cpp b/tools/gfx/cpu/render-cpu.cpp
index 56804f15e..c6662b851 100644
--- a/tools/gfx/cpu/render-cpu.cpp
+++ b/tools/gfx/cpu/render-cpu.cpp
@@ -11,7 +11,7 @@
#include "../immediate-renderer-base.h"
#include "../slang-context.h"
-
+#include "../mutable-shader-object.h"
#define SLANG_PRELUDE_NAMESPACE slang_prelude
#include "prelude/slang-cpp-types.h"
@@ -942,6 +942,9 @@ public:
char* getDataBuffer() { return m_data.getBuffer(); }
};
+class CPUMutableShaderObject : public MutableShaderObject<CPUMutableShaderObject, CPUShaderObjectLayout>
+{};
+
class CPUEntryPointShaderObject : public CPUShaderObject
{
public:
@@ -951,12 +954,9 @@ public:
class CPURootShaderObject : public CPUShaderObject
{
public:
- // Override default reference counting behavior to disable lifetime management via ComPtr.
- // Root objects are managed by command buffer and does not need to be freed by the user.
- SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override { return 1; }
- SLANG_NO_THROW uint32_t SLANG_MCALL release() override { return 1; }
+ virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override { return 1; }
+ virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() override { return 1; }
-public:
SlangResult init(IDevice* device, CPUProgramLayout* programLayout);
CPUProgramLayout* getLayout() { return static_cast<CPUProgramLayout*>(m_layout.Ptr()); }
@@ -1007,17 +1007,9 @@ public:
}
};
-class CPUQueryPool : public IQueryPool, public ComObject
+class CPUQueryPool : public QueryPoolBase
{
public:
- SLANG_COM_OBJECT_IUNKNOWN_ALL;
- IQueryPool* getInterface(const Guid& guid)
- {
- if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_IQueryPool)
- return static_cast<IQueryPool*>(this);
- return nullptr;
- }
-public:
List<uint64_t> m_queries;
Result init(const IQueryPool::Desc& desc)
{
@@ -1216,6 +1208,19 @@ public:
return SLANG_OK;
}
+ virtual Result createMutableShaderObject(
+ ShaderObjectLayoutBase* layout,
+ IShaderObject** outObject) override
+ {
+ auto cpuLayout = static_cast<CPUShaderObjectLayout*>(layout);
+
+ RefPtr<CPUMutableShaderObject> result = new CPUMutableShaderObject();
+ SLANG_RETURN_ON_FAIL(result->init(this, cpuLayout));
+ returnComPtr(outObject, result);
+
+ return SLANG_OK;
+ }
+
virtual Result createRootShaderObject(IShaderProgram* program, ShaderObjectBase** outObject) override
{
auto cpuProgram = static_cast<CPUShaderProgram*>(program);