From 2f44d9e01234911dd563f0456b9d861fd8db286d Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 18 Oct 2021 12:19:45 -0700 Subject: 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 --- tools/gfx/cuda/render-cuda.cpp | 45 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'tools/gfx/cuda/render-cuda.cpp') diff --git a/tools/gfx/cuda/render-cuda.cpp b/tools/gfx/cuda/render-cuda.cpp index fccc1e3f0..ed22495cb 100644 --- a/tools/gfx/cuda/render-cuda.cpp +++ b/tools/gfx/cuda/render-cuda.cpp @@ -12,6 +12,7 @@ #include "slang-com-helper.h" #include "../command-writer.h" #include "../renderer-shared.h" +#include "../mutable-shader-object.h" #include "../simple-transient-resource-heap.h" #include "../slang-context.h" @@ -659,6 +660,9 @@ public: } }; +class CUDAMutableShaderObject : public MutableShaderObject< CUDAMutableShaderObject, CUDAShaderObjectLayout> +{}; + class CUDAEntryPointShaderObject : public CUDAShaderObject { public: @@ -668,11 +672,8 @@ public: class CUDARootShaderObject : public CUDAShaderObject { public: - // Override default reference counting behavior to disable lifetime management. - // 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: List> entryPointObjects; virtual SLANG_NO_THROW Result SLANG_MCALL @@ -723,16 +724,8 @@ public: } }; -class CUDAQueryPool : public IQueryPool, public ComObject +class CUDAQueryPool : 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(this); - return nullptr; - } public: // The event object for each query. Owned by the pool. List m_events; @@ -1001,7 +994,6 @@ public: ResourceState src, ResourceState dst) override { - assert(!"Unimplemented"); } virtual SLANG_NO_THROW void SLANG_MCALL bufferBarrier( @@ -1010,7 +1002,6 @@ public: ResourceState src, ResourceState dst) override { - assert(!"Unimplemented"); } virtual SLANG_NO_THROW void SLANG_MCALL @@ -1236,11 +1227,11 @@ public: switch (cmd.name) { case CommandName::SetPipelineState: - setPipelineState(commandBuffer->getObject(cmd.operands[0])); + setPipelineState(commandBuffer->getObject(cmd.operands[0])); break; case CommandName::BindRootShaderObject: bindRootShaderObject( - commandBuffer->getObject(cmd.operands[0])); + commandBuffer->getObject(cmd.operands[0])); break; case CommandName::DispatchCompute: dispatchCompute( @@ -1248,22 +1239,22 @@ public: break; case CommandName::CopyBuffer: copyBuffer( - commandBuffer->getObject(cmd.operands[0]), + commandBuffer->getObject(cmd.operands[0]), cmd.operands[1], - commandBuffer->getObject(cmd.operands[2]), + commandBuffer->getObject(cmd.operands[2]), cmd.operands[3], cmd.operands[4]); break; case CommandName::UploadBufferData: uploadBufferData( - commandBuffer->getObject(cmd.operands[0]), + commandBuffer->getObject(cmd.operands[0]), cmd.operands[1], cmd.operands[2], commandBuffer->getData(cmd.operands[3])); break; case CommandName::WriteTimestamp: writeTimestamp( - commandBuffer->getObject(cmd.operands[0]), + commandBuffer->getObject(cmd.operands[0]), (SlangInt)cmd.operands[1]); } } @@ -1816,6 +1807,16 @@ public: return SLANG_OK; } + virtual Result createMutableShaderObject( + ShaderObjectLayoutBase* layout, + IShaderObject** outObject) override + { + RefPtr result = new CUDAMutableShaderObject(); + SLANG_RETURN_ON_FAIL(result->init(this, dynamic_cast(layout))); + returnComPtr(outObject, result); + return SLANG_OK; + } + Result createRootShaderObject(IShaderProgram* program, ShaderObjectBase** outObject) { auto cudaProgram = dynamic_cast(program); -- cgit v1.2.3