From fff2114b1f4968dc4fdd4918de24092dce6d1a54 Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 16 Mar 2021 22:04:28 -0700 Subject: ShaderVariableManagerD3D11: some code updates --- .../include/ShaderVariableManagerD3D11.hpp | 74 ++++++---------------- .../src/PipelineResourceSignatureD3D11Impl.cpp | 2 +- .../src/ShaderVariableManagerD3D11.cpp | 28 ++++---- 3 files changed, 31 insertions(+), 73 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderVariableManagerD3D11.hpp b/Graphics/GraphicsEngineD3D11/include/ShaderVariableManagerD3D11.hpp index 38700fdf..581001d6 100644 --- a/Graphics/GraphicsEngineD3D11/include/ShaderVariableManagerD3D11.hpp +++ b/Graphics/GraphicsEngineD3D11/include/ShaderVariableManagerD3D11.hpp @@ -83,7 +83,7 @@ public: const ResourceAttribs& GetAttribs(Uint32 Index) const; - template + template struct ShaderVariableD3D11Base : ShaderVariableBase { public: @@ -119,102 +119,66 @@ public: GetResourceDesc(HLSLResDesc); HLSLResDesc.ShaderRegister = GetAttribs().BindPoints[m_ParentManager.m_ShaderTypeIndex]; } + + virtual bool DILIGENT_CALL_TYPE IsBound(Uint32 ArrayIndex) const override final + { + VERIFY_EXPR(ArrayIndex < GetDesc().ArraySize); + return m_ParentManager.m_ResourceCache.IsResourceBound(GetAttribs().BindPoints + ArrayIndex); + } }; - struct ConstBuffBindInfo final : ShaderVariableD3D11Base + struct ConstBuffBindInfo final : ShaderVariableD3D11Base { ConstBuffBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base{ParentLayout, ResIndex} + ShaderVariableD3D11Base{ParentLayout, ResIndex} {} - // Non-virtual function __forceinline void BindResource(IDeviceObject* pObj, Uint32 ArrayIndex); - - virtual bool DILIGENT_CALL_TYPE IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < GetDesc().ArraySize); - return m_ParentManager.m_ResourceCache.IsResourceBound(GetAttribs().BindPoints + ArrayIndex); - } }; - struct TexSRVBindInfo final : ShaderVariableD3D11Base + struct TexSRVBindInfo final : ShaderVariableD3D11Base { TexSRVBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base{ParentLayout, ResIndex} + ShaderVariableD3D11Base{ParentLayout, ResIndex} {} - // Non-virtual function __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); - - virtual bool DILIGENT_CALL_TYPE IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < GetDesc().ArraySize); - return m_ParentManager.m_ResourceCache.IsResourceBound(GetAttribs().BindPoints + ArrayIndex); - } }; - struct TexUAVBindInfo final : ShaderVariableD3D11Base + struct TexUAVBindInfo final : ShaderVariableD3D11Base { TexUAVBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base{ParentLayout, ResIndex} + ShaderVariableD3D11Base{ParentLayout, ResIndex} {} - // Provide non-virtual function __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); - - __forceinline virtual bool DILIGENT_CALL_TYPE IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < GetDesc().ArraySize); - return m_ParentManager.m_ResourceCache.IsResourceBound(GetAttribs().BindPoints + ArrayIndex); - } }; - struct BuffUAVBindInfo final : ShaderVariableD3D11Base + struct BuffUAVBindInfo final : ShaderVariableD3D11Base { BuffUAVBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base{ParentLayout, ResIndex} + ShaderVariableD3D11Base{ParentLayout, ResIndex} {} - // Non-virtual function __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); - - virtual bool DILIGENT_CALL_TYPE IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < GetDesc().ArraySize); - return m_ParentManager.m_ResourceCache.IsResourceBound(GetAttribs().BindPoints + ArrayIndex); - } }; - struct BuffSRVBindInfo final : ShaderVariableD3D11Base + struct BuffSRVBindInfo final : ShaderVariableD3D11Base { BuffSRVBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base{ParentLayout, ResIndex} + ShaderVariableD3D11Base{ParentLayout, ResIndex} {} - // Non-virtual function __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); - - virtual bool DILIGENT_CALL_TYPE IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < GetDesc().ArraySize); - return m_ParentManager.m_ResourceCache.IsResourceBound(GetAttribs().BindPoints + ArrayIndex); - } }; - struct SamplerBindInfo final : ShaderVariableD3D11Base + struct SamplerBindInfo final : ShaderVariableD3D11Base { SamplerBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base{ParentLayout, ResIndex} + ShaderVariableD3D11Base{ParentLayout, ResIndex} {} - // Non-virtual function __forceinline void BindResource(IDeviceObject* pObject, Uint32 ArrayIndex); - - virtual bool DILIGENT_CALL_TYPE IsBound(Uint32 ArrayIndex) const override final - { - VERIFY_EXPR(ArrayIndex < GetDesc().ArraySize); - return m_ParentManager.m_ResourceCache.IsResourceBound(GetAttribs().BindPoints + ArrayIndex); - } }; void BindResources(IResourceMapping* pResourceMapping, Uint32 Flags); diff --git a/Graphics/GraphicsEngineD3D11/src/PipelineResourceSignatureD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/PipelineResourceSignatureD3D11Impl.cpp index 21bedd54..33220e34 100644 --- a/Graphics/GraphicsEngineD3D11/src/PipelineResourceSignatureD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/PipelineResourceSignatureD3D11Impl.cpp @@ -251,7 +251,7 @@ void PipelineResourceSignatureD3D11Impl::CreateLayout() } } - // Add bindings for immutable samplers that is not assigned to texture or separate sampler. + // Add bindings for immutable samplers that are not assigned to texture or separate sampler. for (Uint32 i = 0; i < m_Desc.NumImmutableSamplers; ++i) { const auto Range = D3D11_RESOURCE_RANGE_SAMPLER; diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderVariableManagerD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderVariableManagerD3D11.cpp index 2479ab1a..09789b98 100644 --- a/Graphics/GraphicsEngineD3D11/src/ShaderVariableManagerD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/ShaderVariableManagerD3D11.cpp @@ -237,7 +237,7 @@ void ShaderVariableManagerD3D11::Initialize(const PipelineResourceSignatureD3D11 { case SHADER_RESOURCE_TYPE_CONSTANT_BUFFER: // Initialize current CB in place, increment CB counter - new (&GetResource(cb++)) ConstBuffBindInfo(*this, Index); + new (&GetResource(cb++)) ConstBuffBindInfo{*this, Index}; break; case SHADER_RESOURCE_TYPE_TEXTURE_SRV: @@ -248,22 +248,22 @@ void ShaderVariableManagerD3D11::Initialize(const PipelineResourceSignatureD3D11 case SHADER_RESOURCE_TYPE_BUFFER_SRV: // Initialize buff SRV in place, increment counter of buff SRVs - new (&GetResource(bufSrv++)) BuffSRVBindInfo(*this, Index); + new (&GetResource(bufSrv++)) BuffSRVBindInfo{*this, Index}; break; case SHADER_RESOURCE_TYPE_TEXTURE_UAV: // Initialize tex UAV in place, increment counter of tex UAVs - new (&GetResource(texUav++)) TexUAVBindInfo(*this, Index); + new (&GetResource(texUav++)) TexUAVBindInfo{*this, Index}; break; case SHADER_RESOURCE_TYPE_BUFFER_UAV: // Initialize buff UAV in place, increment counter of buff UAVs - new (&GetResource(bufUav++)) BuffUAVBindInfo(*this, Index); + new (&GetResource(bufUav++)) BuffUAVBindInfo{*this, Index}; break; case SHADER_RESOURCE_TYPE_SAMPLER: // Initialize current sampler in place, increment sampler counter - new (&GetResource(sam++)) SamplerBindInfo(*this, Index); + new (&GetResource(sam++)) SamplerBindInfo{*this, Index}; break; default: @@ -290,8 +290,7 @@ void ShaderVariableManagerD3D11::ConstBuffBindInfo::BindResource(IDeviceObject* VERIFY_EXPR(Desc.ResourceType == SHADER_RESOURCE_TYPE_CONSTANT_BUFFER); - // We cannot use ValidatedCast<> here as the resource retrieved from the - // resource mapping can be of wrong type + // We cannot use ValidatedCast<> here as the resource can be of wrong type RefCntAutoPtr pBuffD3D11Impl{pBuffer, IID_BufferD3D11}; #ifdef DILIGENT_DEVELOPMENT { @@ -314,8 +313,7 @@ void ShaderVariableManagerD3D11::TexSRVBindInfo::BindResource(IDeviceObject* pVi VERIFY_EXPR(Desc.ResourceType == SHADER_RESOURCE_TYPE_TEXTURE_SRV || Desc.ResourceType == SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT); - // We cannot use ValidatedCast<> here as the resource retrieved from the - // resource mapping can be of wrong type + // We cannot use ValidatedCast<> here as the resource can be of wrong type RefCntAutoPtr pViewD3D11{pView, IID_TextureViewD3D11}; #ifdef DILIGENT_DEVELOPMENT { @@ -376,8 +374,7 @@ void ShaderVariableManagerD3D11::SamplerBindInfo::BindResource(IDeviceObject* pS VERIFY_EXPR(Desc.ResourceType == SHADER_RESOURCE_TYPE_SAMPLER); - // We cannot use ValidatedCast<> here as the resource retrieved from the - // resource mapping can be of wrong type + // We cannot use ValidatedCast<> here as the resource can be of wrong type RefCntAutoPtr pSamplerD3D11{pSampler, IID_SamplerD3D11}; #ifdef DILIGENT_DEVELOPMENT @@ -420,8 +417,7 @@ void ShaderVariableManagerD3D11::BuffSRVBindInfo::BindResource(IDeviceObject* pV VERIFY_EXPR(Desc.ResourceType == SHADER_RESOURCE_TYPE_BUFFER_SRV); - // We cannot use ValidatedCast<> here as the resource retrieved from the - // resource mapping can be of wrong type + // We cannot use ValidatedCast<> here as the resource can be of wrong type RefCntAutoPtr pViewD3D11{pView, IID_BufferViewD3D11}; #ifdef DILIGENT_DEVELOPMENT { @@ -446,8 +442,7 @@ void ShaderVariableManagerD3D11::TexUAVBindInfo::BindResource(IDeviceObject* pVi VERIFY_EXPR(Desc.ResourceType == SHADER_RESOURCE_TYPE_TEXTURE_UAV); - // We cannot use ValidatedCast<> here as the resource retrieved from the - // resource mapping can be of wrong type + // We cannot use ValidatedCast<> here as the resource can be of wrong type RefCntAutoPtr pViewD3D11{pView, IID_TextureViewD3D11}; #ifdef DILIGENT_DEVELOPMENT { @@ -471,8 +466,7 @@ void ShaderVariableManagerD3D11::BuffUAVBindInfo::BindResource(IDeviceObject* pV VERIFY_EXPR(Desc.ResourceType == SHADER_RESOURCE_TYPE_BUFFER_UAV); - // We cannot use ValidatedCast<> here as the resource retrieved from the - // resource mapping can be of wrong type + // We cannot use ValidatedCast<> here as the resource can be of wrong type RefCntAutoPtr pViewD3D11{pView, IID_BufferViewD3D11}; #ifdef DILIGENT_DEVELOPMENT { -- cgit v1.2.3