From 43b6f5c36cbe2529d93df0e44e319a330487ed0d Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 4 Jan 2022 11:24:11 -0800 Subject: gfx: Fix root shader object implementation in debug layer. (#2059) * gfx: Fix root shader object implementation in debug layer. * Fix. Co-authored-by: Yong He Co-authored-by: Theresa Foley --- tools/gfx/debug-layer.cpp | 20 +++++++++++++++++--- tools/gfx/debug-layer.h | 13 +++++++++++++ tools/platform/gui.cpp | 4 ++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/tools/gfx/debug-layer.cpp b/tools/gfx/debug-layer.cpp index 97504017e..80c04bd1f 100644 --- a/tools/gfx/debug-layer.cpp +++ b/tools/gfx/debug-layer.cpp @@ -652,17 +652,26 @@ Result DebugDevice::createMutableShaderObject( } Result DebugDevice::createMutableRootShaderObject( - IShaderProgram* program, IShaderObject** outObject) + IShaderProgram* program, IShaderObject** outRootObject) { SLANG_GFX_API_FUNC; - return baseObject->createMutableRootShaderObject(program, outObject); + RefPtr outObject = new DebugShaderObject(); + auto result = baseObject->createMutableRootShaderObject( + getInnerObj(program), outObject->baseObject.writeRef()); + if (SLANG_FAILED(result)) + return result; + outObject->m_device = this; + outObject->m_slangType = nullptr; + outObject->m_rootComponentType = getDebugObj(program)->m_slangProgram; + returnComPtr(outRootObject, outObject); + return result; } Result DebugDevice::createProgram(const IShaderProgram::Desc& desc, IShaderProgram** outProgram) { SLANG_GFX_API_FUNC; - RefPtr outObject = new DebugShaderProgram(); + RefPtr outObject = new DebugShaderProgram(desc); auto result = baseObject->createProgram(desc, outObject->baseObject.writeRef()); if (SLANG_FAILED(result)) return result; @@ -1836,4 +1845,9 @@ Result DebugFence::setCurrentValue(uint64_t value) return baseObject->setCurrentValue(value); } +DebugShaderProgram::DebugShaderProgram(const IShaderProgram::Desc& desc) +{ + m_slangProgram = desc.slangProgram; +} + } // namespace gfx diff --git a/tools/gfx/debug-layer.h b/tools/gfx/debug-layer.h index 35410530e..c5482da87 100644 --- a/tools/gfx/debug-layer.h +++ b/tools/gfx/debug-layer.h @@ -293,9 +293,18 @@ public: setConstantBufferOverride(IBufferResource* constantBuffer) override; public: + // Type name of an ordinary shader object. Slang::String m_typeName; + + // The slang Type of an ordinary shader object. This is null for root objects. slang::TypeReflection* m_slangType = nullptr; + + // The slang program from which a root shader object is created, this is null for ordinary + // objects. + Slang::ComPtr m_rootComponentType; + DebugDevice* m_device; + Slang::List> m_entryPoints; Slang::Dictionary> m_objects; Slang::Dictionary> m_resources; @@ -626,6 +635,10 @@ public: public: IShaderProgram* getInterface(const Slang::Guid& guid); + DebugShaderProgram(const IShaderProgram::Desc& desc); + +public: + Slang::ComPtr m_slangProgram; }; class DebugTransientResourceHeap : public DebugObject diff --git a/tools/platform/gui.cpp b/tools/platform/gui.cpp index 31671c424..5b72bd087 100644 --- a/tools/platform/gui.cpp +++ b/tools/platform/gui.cpp @@ -292,8 +292,8 @@ void GUI::endFrame(ITransientResourceHeap* transientHeap, IFramebuffer* framebuf indexBuffer, sizeof(ImDrawIdx) == 2 ? Format::R16_UINT : Format::R32_UINT); renderEncoder->setPrimitiveTopology(PrimitiveTopology::TriangleList); - UInt vertexOffset = 0; - UInt indexOffset = 0; + uint32_t vertexOffset = 0; + uint32_t indexOffset = 0; ImVec2 pos = draw_data->DisplayPos; for(int ii = 0; ii < commandListCount; ++ii) { -- cgit v1.2.3