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/vulkan | |
| 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/vulkan')
| -rw-r--r-- | tools/gfx/vulkan/vk-command-encoder.h | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/tools/gfx/vulkan/vk-command-encoder.h b/tools/gfx/vulkan/vk-command-encoder.h index f71e262c5..0e834a5fb 100644 --- a/tools/gfx/vulkan/vk-command-encoder.h +++ b/tools/gfx/vulkan/vk-command-encoder.h @@ -12,7 +12,7 @@ using namespace Slang; namespace vk { -class PipelineCommandEncoder : public RefObject +class PipelineCommandEncoder : public ComObject { public: CommandBufferImpl* m_commandBuffer; @@ -54,6 +54,25 @@ class ResourceCommandEncoder , public PipelineCommandEncoder { public: + virtual void* getInterface(SlangUUID const& guid) + { + if (guid == GfxGUID::IID_IResourceCommandEncoder || guid == 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, @@ -150,8 +169,16 @@ class RenderCommandEncoder : public IRenderCommandEncoder , public ResourceCommandEncoder { -public: SLANG_GFX_FORWARD_RESOURCE_COMMAND_ENCODER_IMPL(ResourceCommandEncoder) + virtual void* getInterface(SlangUUID const& uuid) override + { + if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == GfxGUID::IID_IRenderCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + { + return this; + } + return nullptr; + } + public: List<VkViewport> m_viewports; List<VkRect2D> m_scissorRects; @@ -233,7 +260,15 @@ class ComputeCommandEncoder { public: SLANG_GFX_FORWARD_RESOURCE_COMMAND_ENCODER_IMPL(ResourceCommandEncoder) -public: + virtual void* getInterface(SlangUUID const& uuid) override + { + if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == GfxGUID::IID_IComputeCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + { + return this; + } + return nullptr; + } + virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override; virtual SLANG_NO_THROW Result SLANG_MCALL @@ -254,7 +289,16 @@ class RayTracingCommandEncoder { public: SLANG_GFX_FORWARD_RESOURCE_COMMAND_ENCODER_IMPL(ResourceCommandEncoder) + virtual void* getInterface(SlangUUID const& uuid) override + { + if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == GfxGUID::IID_IRayTracingCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + { + return this; + } + return nullptr; + } public: + void _memoryBarrier( int count, IAccelerationStructure* const* structures, |
