summaryrefslogtreecommitdiffstats
path: root/tools/gfx/cuda/render-cuda.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-04-05 13:31:05 -0700
committerGitHub <noreply@github.com>2021-04-05 13:31:05 -0700
commit086ecf41fa21138899960bb9805bc8ced91690f0 (patch)
treec98af81ffc28371a9334e71987a85f9e88bce678 /tools/gfx/cuda/render-cuda.cpp
parentdd662f5cda97e7a6720ef526509a772a06112d4a (diff)
Transient root shader object. (#1782)
Diffstat (limited to 'tools/gfx/cuda/render-cuda.cpp')
-rw-r--r--tools/gfx/cuda/render-cuda.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/tools/gfx/cuda/render-cuda.cpp b/tools/gfx/cuda/render-cuda.cpp
index b29f7f7e4..dbee0c5f2 100644
--- a/tools/gfx/cuda/render-cuda.cpp
+++ b/tools/gfx/cuda/render-cuda.cpp
@@ -990,7 +990,9 @@ public:
return nullptr;
}
public:
- void init(CUDADevice* device) { SLANG_UNUSED(device); }
+ CUDADevice* m_device;
+
+ void init(CUDADevice* device) { m_device = device; }
virtual SLANG_NO_THROW void SLANG_MCALL encodeRenderCommands(
IRenderPassLayout* renderPass,
IFramebuffer* framebuffer,
@@ -1022,25 +1024,29 @@ public:
public:
CommandWriter* m_writer;
-
+ CommandBufferImpl* m_commandBuffer;
+ ComPtr<IShaderObject> m_rootObject;
virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override {}
void init(CommandBufferImpl* cmdBuffer)
{
m_writer = cmdBuffer;
+ m_commandBuffer = cmdBuffer;
}
- virtual SLANG_NO_THROW void SLANG_MCALL setPipelineState(IPipelineState* state) override
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ bindPipeline(IPipelineState* state, IShaderObject** outRootObject) override
{
m_writer->setPipelineState(state);
- }
- virtual SLANG_NO_THROW void SLANG_MCALL
- bindRootShaderObject(IShaderObject* object) override
- {
- m_writer->bindRootShaderObject(PipelineType::Compute, object);
+ PipelineStateBase* pipelineImpl = static_cast<PipelineStateBase*>(state);
+ SLANG_RETURN_ON_FAIL(m_commandBuffer->m_device->createRootShaderObject(
+ pipelineImpl->m_program, outRootObject));
+ m_rootObject = *outRootObject;
+ return SLANG_OK;
}
virtual SLANG_NO_THROW void SLANG_MCALL dispatchCompute(int x, int y, int z) override
{
+ m_writer->bindRootShaderObject(m_rootObject);
m_writer->dispatchCompute(x, y, z);
}
};
@@ -1831,8 +1837,7 @@ public:
return SLANG_OK;
}
- virtual SLANG_NO_THROW Result SLANG_MCALL
- createRootShaderObject(IShaderProgram* program, IShaderObject** outObject) override
+ Result createRootShaderObject(IShaderProgram* program, IShaderObject** outObject)
{
auto cudaProgram = dynamic_cast<CUDAShaderProgram*>(program);
auto cudaLayout = cudaProgram->layout;