From 344898b091867e5450a3fa432a207d75255df77a Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 12 Oct 2022 14:51:13 -0700 Subject: Add gfx debug layer trampoline for D3D12 interfaces. (#2445) Co-authored-by: Yong He --- tools/gfx/debug-layer/debug-command-buffer.cpp | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tools/gfx/debug-layer/debug-command-buffer.cpp') diff --git a/tools/gfx/debug-layer/debug-command-buffer.cpp b/tools/gfx/debug-layer/debug-command-buffer.cpp index aa9c6b8b8..f3c71cb77 100644 --- a/tools/gfx/debug-layer/debug-command-buffer.cpp +++ b/tools/gfx/debug-layer/debug-command-buffer.cpp @@ -22,6 +22,15 @@ DebugCommandBuffer::DebugCommandBuffer() m_rayTracingCommandEncoder.commandBuffer = this; } +ICommandBuffer* DebugCommandBuffer::getInterface(const Slang::Guid& guid) +{ + if (guid == GfxGUID::IID_ICommandBuffer || guid == GfxGUID::IID_ISlangUnknown) + return (DebugObject*)this; + if (guid == GfxGUID::IID_ICommandBufferD3D12) + return static_cast(this); + return nullptr; +} + void DebugCommandBuffer::encodeRenderCommands( IRenderPassLayout* renderPass, IFramebuffer* framebuffer, @@ -127,6 +136,30 @@ Result DebugCommandBuffer::getNativeHandle(InteropHandle* outHandle) return baseObject->getNativeHandle(outHandle); } +void DebugCommandBuffer::invalidateDescriptorHeapBinding() +{ + SLANG_GFX_API_FUNC; + ComPtr cmdBuf; + if (SLANG_FAILED(baseObject->queryInterface(SlangUUID SLANG_UUID_ICommandBufferD3D12, (void**)cmdBuf.writeRef()))) + { + GFX_DIAGNOSE_ERROR("The current command buffer implementation does not provide ICommandBufferD3D12 interface."); + return; + } + return cmdBuf->invalidateDescriptorHeapBinding(); +} + +void DebugCommandBuffer::ensureInternalDescriptorHeapsBound() +{ + SLANG_GFX_API_FUNC; + ComPtr cmdBuf; + if (SLANG_FAILED(baseObject->queryInterface(SlangUUID SLANG_UUID_ICommandBufferD3D12, (void**)cmdBuf.writeRef()))) + { + GFX_DIAGNOSE_ERROR("The current command buffer implementation does not provide ICommandBufferD3D12 interface."); + return; + } + return cmdBuf->ensureInternalDescriptorHeapsBound(); +} + void DebugCommandBuffer::checkEncodersClosedBeforeNewEncoder() { if (m_renderCommandEncoder.isOpen || m_resourceCommandEncoder.isOpen || -- cgit v1.2.3