From 42f49937ffa69c82e333e886952eed027e12340e Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 16 Aug 2022 17:11:54 -0700 Subject: Add gfx interface definition in Slang. (#2364) * Add gfx interface definition in Slang. - add gfx interface definitons in Slang. - fix slang compiler to correctly type-check `out` interface argument. - modify gfx interface to be fully COM compatible - add convenient ShaderProgram creation methods to gfx. * Fix compile errors and warnings. * Update project files * Fix cuda. * Properly implement queryInterface in command encoder impls. Co-authored-by: Yong He --- tools/gfx/debug-layer/debug-command-encoder.h | 48 ++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'tools/gfx/debug-layer/debug-command-encoder.h') diff --git a/tools/gfx/debug-layer/debug-command-encoder.h b/tools/gfx/debug-layer/debug-command-encoder.h index 8a0ffbfdb..b53a11074 100644 --- a/tools/gfx/debug-layer/debug-command-encoder.h +++ b/tools/gfx/debug-layer/debug-command-encoder.h @@ -15,7 +15,18 @@ public: virtual DebugCommandBuffer* getCommandBuffer() = 0; virtual bool getIsOpen() = 0; virtual IResourceCommandEncoder* getBaseResourceEncoder() = 0; - + virtual void* getInterface(SlangUUID const& uuid) = 0; + SlangResult queryInterface(SlangUUID const& uuid, void** outObject) + { + if (auto ptr = getInterface(uuid)) + { + *outObject = ptr; + return SLANG_OK; + } + return SLANG_E_NO_INTERFACE; + } + uint32_t addRef() { return 1; } + uint32_t release() { return 1; } public: virtual SLANG_NO_THROW void SLANG_MCALL copyBuffer( IBufferResource* dst, @@ -97,6 +108,14 @@ public: virtual DebugCommandBuffer* getCommandBuffer() override { return commandBuffer; } virtual bool getIsOpen() override { return isOpen; } virtual IResourceCommandEncoder* getBaseResourceEncoder() override { return baseObject; } + virtual void* getInterface(SlangUUID const& uuid) override + { + if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == GfxGUID::IID_IComputeCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + { + return this; + } + return nullptr; + } public: virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override; @@ -122,7 +141,14 @@ public: virtual DebugCommandBuffer* getCommandBuffer() override { return commandBuffer; } virtual bool getIsOpen() override { return isOpen; } virtual IResourceCommandEncoder* getBaseResourceEncoder() override { return baseObject; } - + virtual void* getInterface(SlangUUID const& uuid) override + { + if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + { + return this; + } + return nullptr; + } public: virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override; @@ -144,7 +170,14 @@ public: } virtual bool getIsOpen() override { return isOpen; } virtual IResourceCommandEncoder* getBaseResourceEncoder() override { return baseObject; } - + virtual void* getInterface(SlangUUID const& uuid) override + { + if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == GfxGUID::IID_IRenderCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + { + return this; + } + return nullptr; + } public: virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override; virtual SLANG_NO_THROW Result SLANG_MCALL @@ -212,7 +245,14 @@ public: virtual DebugCommandBuffer* getCommandBuffer() override { return commandBuffer; } virtual bool getIsOpen() override { return isOpen; } virtual IResourceCommandEncoder* getBaseResourceEncoder() override { return baseObject; } - + virtual void* getInterface(SlangUUID const& uuid) override + { + if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == GfxGUID::IID_IRayTracingCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + { + return this; + } + return nullptr; + } public: virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override; virtual SLANG_NO_THROW void SLANG_MCALL buildAccelerationStructure( -- cgit v1.2.3