diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2021-03-17 05:04:28 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2021-03-19 00:38:24 +0000 |
| commit | fff2114b1f4968dc4fdd4918de24092dce6d1a54 (patch) | |
| tree | 01888683b66d517e2c6ea262743698f5349dc652 /Graphics/GraphicsEngineD3D11 | |
| parent | Fixed handling pixel shader UAVs in D3D11 (diff) | |
| download | DiligentCore-fff2114b1f4968dc4fdd4918de24092dce6d1a54.tar.gz DiligentCore-fff2114b1f4968dc4fdd4918de24092dce6d1a54.zip | |
ShaderVariableManagerD3D11: some code updates
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
3 files changed, 31 insertions, 73 deletions
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 <typename ThisImplType> + template <typename ThisImplType, D3D11_RESOURCE_RANGE ResRange> struct ShaderVariableD3D11Base : ShaderVariableBase<ThisImplType, ShaderVariableManagerD3D11, IShaderResourceVariableD3D> { 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<ResRange>(GetAttribs().BindPoints + ArrayIndex); + } }; - struct ConstBuffBindInfo final : ShaderVariableD3D11Base<ConstBuffBindInfo> + struct ConstBuffBindInfo final : ShaderVariableD3D11Base<ConstBuffBindInfo, D3D11_RESOURCE_RANGE_CBV> { ConstBuffBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base<ConstBuffBindInfo>{ParentLayout, ResIndex} + ShaderVariableD3D11Base<ConstBuffBindInfo, D3D11_RESOURCE_RANGE_CBV>{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<D3D11_RESOURCE_RANGE_CBV>(GetAttribs().BindPoints + ArrayIndex); - } }; - struct TexSRVBindInfo final : ShaderVariableD3D11Base<TexSRVBindInfo> + struct TexSRVBindInfo final : ShaderVariableD3D11Base<TexSRVBindInfo, D3D11_RESOURCE_RANGE_SRV> { TexSRVBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base<TexSRVBindInfo>{ParentLayout, ResIndex} + ShaderVariableD3D11Base<TexSRVBindInfo, D3D11_RESOURCE_RANGE_SRV>{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<D3D11_RESOURCE_RANGE_SRV>(GetAttribs().BindPoints + ArrayIndex); - } }; - struct TexUAVBindInfo final : ShaderVariableD3D11Base<TexUAVBindInfo> + struct TexUAVBindInfo final : ShaderVariableD3D11Base<TexUAVBindInfo, D3D11_RESOURCE_RANGE_UAV> { TexUAVBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base<TexUAVBindInfo>{ParentLayout, ResIndex} + ShaderVariableD3D11Base<TexUAVBindInfo, D3D11_RESOURCE_RANGE_UAV>{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<D3D11_RESOURCE_RANGE_UAV>(GetAttribs().BindPoints + ArrayIndex); - } }; - struct BuffUAVBindInfo final : ShaderVariableD3D11Base<BuffUAVBindInfo> + struct BuffUAVBindInfo final : ShaderVariableD3D11Base<BuffUAVBindInfo, D3D11_RESOURCE_RANGE_UAV> { BuffUAVBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base<BuffUAVBindInfo>{ParentLayout, ResIndex} + ShaderVariableD3D11Base<BuffUAVBindInfo, D3D11_RESOURCE_RANGE_UAV>{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<D3D11_RESOURCE_RANGE_UAV>(GetAttribs().BindPoints + ArrayIndex); - } }; - struct BuffSRVBindInfo final : ShaderVariableD3D11Base<BuffSRVBindInfo> + struct BuffSRVBindInfo final : ShaderVariableD3D11Base<BuffSRVBindInfo, D3D11_RESOURCE_RANGE_SRV> { BuffSRVBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base<BuffSRVBindInfo>{ParentLayout, ResIndex} + ShaderVariableD3D11Base<BuffSRVBindInfo, D3D11_RESOURCE_RANGE_SRV>{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<D3D11_RESOURCE_RANGE_SRV>(GetAttribs().BindPoints + ArrayIndex); - } }; - struct SamplerBindInfo final : ShaderVariableD3D11Base<SamplerBindInfo> + struct SamplerBindInfo final : ShaderVariableD3D11Base<SamplerBindInfo, D3D11_RESOURCE_RANGE_SAMPLER> { SamplerBindInfo(ShaderVariableManagerD3D11& ParentLayout, Uint32 ResIndex) : - ShaderVariableD3D11Base<SamplerBindInfo>{ParentLayout, ResIndex} + ShaderVariableD3D11Base<SamplerBindInfo, D3D11_RESOURCE_RANGE_SAMPLER>{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<D3D11_RESOURCE_RANGE_SAMPLER>(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<ConstBuffBindInfo>(cb++)) ConstBuffBindInfo(*this, Index); + new (&GetResource<ConstBuffBindInfo>(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<BuffSRVBindInfo>(bufSrv++)) BuffSRVBindInfo(*this, Index); + new (&GetResource<BuffSRVBindInfo>(bufSrv++)) BuffSRVBindInfo{*this, Index}; break; case SHADER_RESOURCE_TYPE_TEXTURE_UAV: // Initialize tex UAV in place, increment counter of tex UAVs - new (&GetResource<TexUAVBindInfo>(texUav++)) TexUAVBindInfo(*this, Index); + new (&GetResource<TexUAVBindInfo>(texUav++)) TexUAVBindInfo{*this, Index}; break; case SHADER_RESOURCE_TYPE_BUFFER_UAV: // Initialize buff UAV in place, increment counter of buff UAVs - new (&GetResource<BuffUAVBindInfo>(bufUav++)) BuffUAVBindInfo(*this, Index); + new (&GetResource<BuffUAVBindInfo>(bufUav++)) BuffUAVBindInfo{*this, Index}; break; case SHADER_RESOURCE_TYPE_SAMPLER: // Initialize current sampler in place, increment sampler counter - new (&GetResource<SamplerBindInfo>(sam++)) SamplerBindInfo(*this, Index); + new (&GetResource<SamplerBindInfo>(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<BufferD3D11Impl> 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<TextureViewD3D11Impl> 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<SamplerD3D11Impl> 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<BufferViewD3D11Impl> 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<TextureViewD3D11Impl> 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<BufferViewD3D11Impl> pViewD3D11{pView, IID_BufferViewD3D11}; #ifdef DILIGENT_DEVELOPMENT { |
