From 3f1632a1450a5879f337b4bd178e48880cd583f8 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 31 Mar 2021 11:35:17 -0700 Subject: `gfx` explicit transient resource management. (#1774) --- tools/gfx/cuda/render-cuda.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 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 383ccc924..b29f7f7e4 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 "../simple-transient-resource-heap.h" #include "../slang-context.h" # ifdef RENDER_TEST_OPTIX @@ -989,6 +990,7 @@ public: return nullptr; } public: + void init(CUDADevice* device) { SLANG_UNUSED(device); } virtual SLANG_NO_THROW void SLANG_MCALL encodeRenderCommands( IRenderPassLayout* renderPass, IFramebuffer* framebuffer, @@ -1147,13 +1149,6 @@ public: { return m_desc; } - virtual SLANG_NO_THROW Result SLANG_MCALL - createCommandBuffer(ICommandBuffer** outCommandBuffer) override - { - RefPtr result = new CommandBufferImpl(); - *outCommandBuffer = result.detach(); - return SLANG_OK; - } virtual SLANG_NO_THROW void SLANG_MCALL executeCommandBuffers(uint32_t count, ICommandBuffer* const* commandBuffers) override @@ -1320,6 +1315,8 @@ public: } }; + using TransientResourceHeapImpl = SimpleTransientResourceHeap; + public: ~CUDADevice() { @@ -1921,6 +1918,16 @@ public: } public: + virtual SLANG_NO_THROW Result SLANG_MCALL createTransientResourceHeap( + const ITransientResourceHeap::Desc& desc, + ITransientResourceHeap** outHeap) override + { + RefPtr result = new TransientResourceHeapImpl(); + SLANG_RETURN_ON_FAIL(result->init(this, desc)); + *outHeap = result.detach(); + return SLANG_OK; + } + virtual SLANG_NO_THROW Result SLANG_MCALL createCommandQueue(const ICommandQueue::Desc& desc, ICommandQueue** outQueue) override { -- cgit v1.2.3