diff options
| author | Yong He <yonghe@outlook.com> | 2022-08-16 17:11:54 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-16 17:11:54 -0700 |
| commit | 42f49937ffa69c82e333e886952eed027e12340e (patch) | |
| tree | 08e3e9821dd40e23476060215d589e29092adb53 /tools/gfx/d3d12 | |
| parent | e68fab2bda5d979f8d991fc41122bb9aa71849a6 (diff) | |
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 <yhe@nvidia.com>
Diffstat (limited to 'tools/gfx/d3d12')
| -rw-r--r-- | tools/gfx/d3d12/d3d12-command-encoder.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/gfx/d3d12/d3d12-command-encoder.h b/tools/gfx/d3d12/d3d12-command-encoder.h index bf2f7710b..5dd9909f8 100644 --- a/tools/gfx/d3d12/d3d12-command-encoder.h +++ b/tools/gfx/d3d12/d3d12-command-encoder.h @@ -52,6 +52,25 @@ class ResourceCommandEncoderImpl , public PipelineCommandEncoder { public: + virtual void* getInterface(SlangUUID const& uuid) + { + if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + return this; + return nullptr; + } + virtual SLANG_NO_THROW SlangResult SLANG_MCALL + queryInterface(SlangUUID const& uuid, void** outObject) + { + if (auto ptr = getInterface(uuid)) + { + *outObject = ptr; + return SLANG_OK; + } + return SLANG_E_NO_INTERFACE; + } + virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() { return 1; } + virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() { return 1; } + virtual SLANG_NO_THROW void SLANG_MCALL copyBuffer( IBufferResource* dst, Offset dstOffset, @@ -138,6 +157,13 @@ class ComputeCommandEncoderImpl { public: SLANG_GFX_FORWARD_RESOURCE_COMMAND_ENCODER_IMPL(ResourceCommandEncoderImpl) + virtual void* getInterface(SlangUUID const& uuid) override + { + if (uuid == GfxGUID::IID_IComputeCommandEncoder || uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + return this; + return nullptr; + } + public: virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override; void init( @@ -169,6 +195,13 @@ class RenderCommandEncoderImpl { public: SLANG_GFX_FORWARD_RESOURCE_COMMAND_ENCODER_IMPL(ResourceCommandEncoderImpl) + virtual void* getInterface(SlangUUID const& uuid) override + { + if (uuid == GfxGUID::IID_IRenderCommandEncoder || uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + return this; + return nullptr; + } + public: RefPtr<RenderPassLayoutImpl> m_renderPass; RefPtr<FramebufferImpl> m_framebuffer; @@ -266,6 +299,13 @@ class RayTracingCommandEncoderImpl { public: SLANG_GFX_FORWARD_RESOURCE_COMMAND_ENCODER_IMPL(ResourceCommandEncoderImpl) + virtual void* getInterface(SlangUUID const& uuid) override + { + if (uuid == GfxGUID::IID_IRayTracingCommandEncoder || uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + return this; + return nullptr; + } + public: virtual SLANG_NO_THROW void SLANG_MCALL buildAccelerationStructure( const IAccelerationStructure::BuildDesc& desc, |
