From f3698c9127d6e384eabe779b8fb3519c94e0babb Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Wed, 24 Apr 2019 22:17:09 -0700 Subject: Added IShaderResourceVariable::IsBound method (updated API version to 240024) --- Graphics/GraphicsEngine/interface/APIInfo.h | 2 +- .../interface/ShaderResourceVariable.h | 12 +++++-- .../include/ShaderResourceLayoutD3D11.h | 38 +++++++++++++++++---- .../src/ShaderResourceLayoutD3D11.cpp | 39 ---------------------- .../include/ShaderVariableD3D12.h | 5 +++ .../include/GLProgramResources.h | 6 ++++ .../include/ShaderVariableVk.h | 5 +++ 7 files changed, 58 insertions(+), 49 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h index f1c89e58..fd6ef747 100644 --- a/Graphics/GraphicsEngine/interface/APIInfo.h +++ b/Graphics/GraphicsEngine/interface/APIInfo.h @@ -26,7 +26,7 @@ /// \file /// Diligent API information -#define DILIGENT_API_VERSION 240023 +#define DILIGENT_API_VERSION 240024 #include "../../../Primitives/interface/BasicTypes.h" diff --git a/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h b/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h index 1bf9fdfd..477c7380 100644 --- a/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h +++ b/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h @@ -120,13 +120,19 @@ public: virtual void SetArray(IDeviceObject* const* ppObjects, Uint32 FirstElement, Uint32 NumElements) = 0; /// Returns the shader resource variable type - virtual SHADER_RESOURCE_VARIABLE_TYPE GetType()const = 0; + virtual SHADER_RESOURCE_VARIABLE_TYPE GetType() const = 0; /// Returns shader resource description. See Diligent::ShaderResourceDesc. - virtual ShaderResourceDesc GetResourceDesc()const = 0; + virtual ShaderResourceDesc GetResourceDesc() const = 0; /// Returns the variable index that can be used to access the variable. - virtual Uint32 GetIndex()const = 0; + virtual Uint32 GetIndex() const = 0; + + /// Returns true if non-null resource is bound to this variable. + + /// \param [in] ArrayIndex - Resource array index. Must be 0 for + /// non-array variables. + virtual bool IsBound(Uint32 ArrayIndex) const = 0; }; } diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h b/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h index bfc39727..d19a611b 100644 --- a/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourceLayoutD3D11.h @@ -87,7 +87,11 @@ public: BindResource(ppObjects[elem], FirstElement+elem); } - __forceinline bool IsBound(Uint32 ArrayIndex)const; + virtual bool IsBound(Uint32 ArrayIndex)const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsCBBound(m_Attribs.BindPoint + ArrayIndex); + } }; struct TexSRVBindInfo final : ShaderVariableD3D11Base @@ -110,7 +114,12 @@ public: BindResource(ppObjects[elem], FirstElement+elem); } - __forceinline bool IsBound(Uint32 ArrayIndex)const; + virtual bool IsBound(Uint32 ArrayIndex)const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsSRVBound(m_Attribs.BindPoint + ArrayIndex, true); + } + bool ValidSamplerAssigned() const {return SamplerIndex != InvalidSamplerIndex;} @@ -136,7 +145,11 @@ public: BindResource(ppObjects[elem], FirstElement+elem); } - __forceinline bool IsBound(Uint32 ArrayIndex)const; + __forceinline virtual bool IsBound(Uint32 ArrayIndex)const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsUAVBound(m_Attribs.BindPoint + ArrayIndex, true); + } }; struct BuffUAVBindInfo final : ShaderVariableD3D11Base @@ -157,7 +170,12 @@ public: BindResource(ppObjects[elem], FirstElement+elem); } - __forceinline bool IsBound(Uint32 ArrayIndex)const; + virtual bool IsBound(Uint32 ArrayIndex)const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsUAVBound(m_Attribs.BindPoint + ArrayIndex, false); + } + }; struct BuffSRVBindInfo final : ShaderVariableD3D11Base @@ -178,7 +196,11 @@ public: BindResource(ppObjects[elem], FirstElement+elem); } - __forceinline bool IsBound(Uint32 ArrayIndex)const; + virtual bool IsBound(Uint32 ArrayIndex)const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsSRVBound(m_Attribs.BindPoint + ArrayIndex, false); + } }; struct SamplerBindInfo final : ShaderVariableD3D11Base @@ -199,7 +221,11 @@ public: BindResource(ppObjects[elem], FirstElement+elem); } - __forceinline bool IsBound(Uint32 ArrayIndex)const; + virtual bool IsBound(Uint32 ArrayIndex)const override final + { + VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); + return m_ParentResLayout.m_ResourceCache.IsSamplerBound(m_Attribs.BindPoint + ArrayIndex); + } }; // dbgResourceCache is only used for sanity check and as a remainder that the resource cache must be alive diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp index 4ac61366..7f8623b0 100755 --- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceLayoutD3D11.cpp @@ -441,13 +441,6 @@ void ShaderResourceLayoutD3D11::ConstBuffBindInfo::BindResource(IDeviceObject* p -bool ShaderResourceLayoutD3D11::ConstBuffBindInfo::IsBound(Uint32 ArrayIndex)const -{ - VERIFY_EXPR(ArrayIndex < m_Attribs.BindCount); - return m_ParentResLayout.m_ResourceCache.IsCBBound(m_Attribs.BindPoint + ArrayIndex); -} - - #ifdef DEVELOPMENT template