diff options
| author | Yong He <yonghe@outlook.com> | 2022-04-27 13:58:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-27 13:58:55 -0700 |
| commit | ec530b300524635dfe0fd86949b0a4fc5c19a984 (patch) | |
| tree | 994b88e2da8c8a25098ad179d93e6b41c45af0ee | |
| parent | 50d5a1021623a89df035a1ef78557e0f1152648d (diff) | |
gfx: Add interop API to control descriptor heap binding. (#2211)
Co-authored-by: Yong He <yhe@nvidia.com>
| -rw-r--r-- | slang-gfx.h | 10 | ||||
| -rw-r--r-- | tools/gfx/d3d12/render-d3d12.cpp | 7 | ||||
| -rw-r--r-- | tools/gfx/d3d12/render-d3d12.h | 6 | ||||
| -rw-r--r-- | tools/gfx/renderer-shared.cpp | 2 | ||||
| -rw-r--r-- | tools/gfx/renderer-shared.h | 1 |
5 files changed, 20 insertions, 6 deletions
diff --git a/slang-gfx.h b/slang-gfx.h index 46b07fb4f..208c1b50e 100644 --- a/slang-gfx.h +++ b/slang-gfx.h @@ -1860,6 +1860,16 @@ public: 0x5d56063f, 0x91d4, 0x4723, { 0xa7, 0xa7, 0x7a, 0x15, 0xaf, 0x93, 0xeb, 0x48 } \ } +class ICommandBufferD3D12 : public ICommandBuffer +{ +public: + virtual SLANG_NO_THROW void SLANG_MCALL invalidateDescriptorHeapBinding() = 0; +}; +#define SLANG_UUID_ICommandBufferD3D12 \ + { \ + 0xd56b7616, 0x6c14, 0x4841, { 0x9d, 0x9c, 0x7b, 0x7f, 0xdb, 0x9f, 0xd9, 0xb8 } \ + } + class ICommandQueue : public ISlangUnknown { public: diff --git a/tools/gfx/d3d12/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp index 98f56958c..e6168f17c 100644 --- a/tools/gfx/d3d12/render-d3d12.cpp +++ b/tools/gfx/d3d12/render-d3d12.cpp @@ -6408,10 +6408,11 @@ RefPtr<BufferResource> ShaderTableImpl::createDeviceBuffer( // a `CommandBuffer` created from the heap. We need to break the cycle upon // the public reference count of a command buffer dropping to 0. -ICommandBuffer* CommandBufferImpl::getInterface(const Guid& guid) +ICommandBufferD3D12* CommandBufferImpl::getInterface(const Guid& guid) { - if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_ICommandBuffer) - return static_cast<ICommandBuffer*>(this); + if (guid == GfxGUID::IID_ISlangUnknown || guid == GfxGUID::IID_ICommandBuffer || + guid == GfxGUID::IID_ICommandBufferD3D12) + return static_cast<ICommandBufferD3D12*>(this); return nullptr; } diff --git a/tools/gfx/d3d12/render-d3d12.h b/tools/gfx/d3d12/render-d3d12.h index 5dae6a383..c8def3217 100644 --- a/tools/gfx/d3d12/render-d3d12.h +++ b/tools/gfx/d3d12/render-d3d12.h @@ -1641,7 +1641,7 @@ public: #endif class CommandBufferImpl - : public ICommandBuffer + : public ICommandBufferD3D12 , public ComObject { public: @@ -1650,7 +1650,7 @@ public: // the public reference count of a command buffer dropping to 0. SLANG_COM_OBJECT_IUNKNOWN_ALL - ICommandBuffer* getInterface(const Guid& guid); + ICommandBufferD3D12* getInterface(const Guid& guid); virtual void comFree() override { m_transientHeap.breakStrongReference(); } virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* handle) override; @@ -1670,7 +1670,7 @@ public: void bindDescriptorHeaps(); - void invalidateDescriptorHeapBinding() { m_descriptorHeapsBound = false; } + virtual SLANG_NO_THROW void SLANG_MCALL invalidateDescriptorHeapBinding() override { m_descriptorHeapsBound = false; } void reinit(); diff --git a/tools/gfx/renderer-shared.cpp b/tools/gfx/renderer-shared.cpp index dd949efd4..5d62f7fba 100644 --- a/tools/gfx/renderer-shared.cpp +++ b/tools/gfx/renderer-shared.cpp @@ -28,6 +28,8 @@ const Slang::Guid GfxGUID::IID_IShaderObject = SLANG_UUID_IShaderObject; const Slang::Guid GfxGUID::IID_IRenderPassLayout = SLANG_UUID_IRenderPassLayout; const Slang::Guid GfxGUID::IID_IRayTracingCommandEncoder = SLANG_UUID_IRayTracingCommandEncoder; const Slang::Guid GfxGUID::IID_ICommandBuffer = SLANG_UUID_ICommandBuffer; +const Slang::Guid GfxGUID::IID_ICommandBufferD3D12 = SLANG_UUID_ICommandBufferD3D12; + const Slang::Guid GfxGUID::IID_ICommandQueue = SLANG_UUID_ICommandQueue; const Slang::Guid GfxGUID::IID_IQueryPool = SLANG_UUID_IQueryPool; const Slang::Guid GfxGUID::IID_IAccelerationStructure = SLANG_UUID_IAccelerationStructure; diff --git a/tools/gfx/renderer-shared.h b/tools/gfx/renderer-shared.h index f4ca259e7..601a8ee85 100644 --- a/tools/gfx/renderer-shared.h +++ b/tools/gfx/renderer-shared.h @@ -35,6 +35,7 @@ struct GfxGUID static const Slang::Guid IID_IResourceCommandEncoder; static const Slang::Guid IID_IRayTracingCommandEncoder; static const Slang::Guid IID_ICommandBuffer; + static const Slang::Guid IID_ICommandBufferD3D12; static const Slang::Guid IID_ICommandQueue; static const Slang::Guid IID_IQueryPool; static const Slang::Guid IID_IAccelerationStructure; |
