From 6866e442b789df5c15693c2d38ae6abc740c5bd2 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sat, 25 Jan 2020 22:31:42 -0800 Subject: Reworked IShader::GetResource to be compatible with C; renamed the method to GetResourceDesc --- Graphics/GraphicsEngine/interface/Shader.h | 8 ++++---- Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h | 4 ++-- Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h | 4 ++-- Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h | 2 +- Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.h | 2 +- Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp | 4 +--- Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h | 2 +- Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp | 4 +--- 8 files changed, 13 insertions(+), 17 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/interface/Shader.h b/Graphics/GraphicsEngine/interface/Shader.h index 7cfa7a79..876fe897 100644 --- a/Graphics/GraphicsEngine/interface/Shader.h +++ b/Graphics/GraphicsEngine/interface/Shader.h @@ -302,7 +302,7 @@ public: virtual Uint32 GetResourceCount() const = 0; /// Returns the pointer to the array of shader resources - virtual ShaderResourceDesc GetResource(Uint32 Index) const = 0; + virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const = 0; }; #else @@ -314,7 +314,7 @@ struct IShader; struct IShaderMethods { Uint32 (*GetResourceCount)(struct IShader*); - struct ShaderResourceDesc (*GetResource) (struct IShader*, Uint32 Index); + struct ShaderResourceDesc (*GetResourceDesc) (struct IShader*, Uint32 Index); }; // clang-format on @@ -335,8 +335,8 @@ struct IShader # define IShader_GetDesc(This) (const struct ShaderDesc*)IDeviceObject_GetDesc(This) -# define IShader_GetResourceCount(This) (This)->pVtbl->Shader.GetResourceCount((struct IShader*)(This)) -# define IShader_GetResource(This, ...) (This)->pVtbl->Shader.GetResource ((struct IShader*)(This), __VA_ARGS__) +# define IShader_GetResourceCount(This) (This)->pVtbl->Shader.GetResourceCount((struct IShader*)(This)) +# define IShader_GetResourceDesc(This, ...) (This)->pVtbl->Shader.GetResourceDesc ((struct IShader*)(This), __VA_ARGS__) // clang-format on diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h index f6ca3bac..aaaae904 100644 --- a/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h @@ -66,9 +66,9 @@ public: } /// Implementation of IShader::GetResource() in Direct3D11 backend. - virtual ShaderResourceDesc GetResource(Uint32 Index) const override final + virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const override final { - return GetHLSLResource(Index); + ResourceDesc = GetHLSLResource(Index); } /// Implementation of IShaderD3D::GetHLSLResource() method. diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h index d76111af..a5be1a03 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h @@ -63,9 +63,9 @@ public: } /// Implementation of IShader::GetResource() in Direct3D12 backend. - virtual ShaderResourceDesc GetResource(Uint32 Index) const override final + virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const override final { - return GetHLSLResource(Index); + ResourceDesc = GetHLSLResource(Index); } /// Implementation of IShaderD3D::GetHLSLResource() in Direct3D12 backend. diff --git a/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h b/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h index 2120b59b..245799e3 100644 --- a/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h +++ b/Graphics/GraphicsEngineMetal/include/ShaderMtlImpl.h @@ -55,7 +55,7 @@ public: return 0; } - virtual ShaderResourceDesc GetResource(Uint32 Index) const override final + virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const override final { LOG_ERROR_MESSAGE("ShaderMtlImpl::GetResource() is not implemented"); return ShaderResourceDesc{}; diff --git a/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.h index 760c3c04..a2528381 100644 --- a/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.h @@ -90,7 +90,7 @@ public: virtual Uint32 GetResourceCount() const override final; /// Implementation of IShader::GetResource() in OpenGL backend. - virtual ShaderResourceDesc GetResource(Uint32 Index) const override final; + virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const override final; static GLObjectWrappers::GLProgramObj LinkProgram(IShader** ppShaders, Uint32 NumShaders, bool IsSeparableProgram); diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp index 0479e80f..8a38bf01 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp @@ -221,9 +221,8 @@ Uint32 ShaderGLImpl::GetResourceCount() const } } -ShaderResourceDesc ShaderGLImpl::GetResource(Uint32 Index) const +void ShaderGLImpl::GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const { - ShaderResourceDesc ResourceDesc; if (m_pDevice->GetDeviceCaps().Features.SeparablePrograms) { DEV_CHECK_ERR(Index < GetResourceCount(), "Index is out of range"); @@ -233,7 +232,6 @@ ShaderResourceDesc ShaderGLImpl::GetResource(Uint32 Index) const { LOG_WARNING_MESSAGE("Shader resource queries are not available when separate shader objects are unsupported"); } - return ResourceDesc; } } // namespace Diligent diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h index 6da22a8b..1fa1053c 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h @@ -60,7 +60,7 @@ public: } /// Implementation of IShader::GetResource() in Vulkan backend. - virtual ShaderResourceDesc GetResource(Uint32 Index) const override final; + virtual void GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const override final; /// Implementation of IShaderVk::GetSPIRV(). virtual const std::vector& GetSPIRV() const override final diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp index ef570dc0..e024643a 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp @@ -145,17 +145,15 @@ ShaderVkImpl::~ShaderVkImpl() { } -ShaderResourceDesc ShaderVkImpl::GetResource(Uint32 Index) const +void ShaderVkImpl::GetResourceDesc(Uint32 Index, ShaderResourceDesc& ResourceDesc) const { auto ResCount = GetResourceCount(); DEV_CHECK_ERR(Index < ResCount, "Resource index (", Index, ") is out of range"); - ShaderResourceDesc ResourceDesc; if (Index < ResCount) { const auto& SPIRVResource = m_pShaderResources->GetResource(Index); ResourceDesc = SPIRVResource.GetResourceDesc(); } - return ResourceDesc; } } // namespace Diligent -- cgit v1.2.3