From 3c7f55a9e031ec4d0fb469ee8c1a6b86debe345a Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 23 Nov 2018 17:32:30 -0800 Subject: Removed default shader resource binding object --- .../include/PipelineStateD3D11Impl.h | 6 ---- .../src/DeviceContextD3D11Impl.cpp | 39 +++++++++++++++------- .../src/PipelineStateD3D11Impl.cpp | 7 +--- 3 files changed, 28 insertions(+), 24 deletions(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h index 4d3776c8..746323d6 100644 --- a/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h @@ -72,8 +72,6 @@ public: virtual bool IsCompatibleWith(const IPipelineState *pPSO)const override final; - class ShaderResourceBindingD3D11Impl* GetDefaultResourceBinding(){return m_pDefaultShaderResBinding.get();} - SRBMemoryAllocator& GetSRBMemoryAllocator() { return m_SRBMemAllocator; @@ -87,10 +85,6 @@ private: // SRB memory allocator must be defined before the default shader res binding SRBMemoryAllocator m_SRBMemAllocator; - - // Do not use strong reference to avoid cyclic references - // Must be declared after the data allocators - std::unique_ptr > m_pDefaultShaderResBinding; }; } diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index f64409cc..1ac7d5b2 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -147,10 +147,10 @@ namespace Diligent }; // http://diligentgraphics.com/diligent-engine/architecture/d3d11/committing-shader-resources-to-the-gpu-pipeline/ - template + template void DeviceContextD3D11Impl::TransitionAndCommitShaderResources(IPipelineState* pPSO, IShaderResourceBinding* pShaderResourceBinding) { + VERIFY_EXPR(pPSO != nullptr); static_assert(TransitionResources || CommitResources, "At least one of TransitionResources or CommitResources flags is expected to be true"); #ifdef DEVELOPMENT @@ -158,20 +158,32 @@ namespace Diligent auto ppdbgShaders = pdbgPipelineStateD3D11->GetShaders(); #endif - auto pShaderResBindingD3D11 = ValidatedCast(pShaderResourceBinding); - if (!pShaderResBindingD3D11) + if (pShaderResourceBinding == nullptr) { - auto pPipelineStateD3D11 = ValidatedCast( pPSO ); - pShaderResBindingD3D11 = pPipelineStateD3D11->GetDefaultResourceBinding(); - } #ifdef DEVELOPMENT - else - { - if (pdbgPipelineStateD3D11->IsIncompatibleWith(pShaderResourceBinding->GetPipelineState())) + bool ResourcesPresent = false; + for (Uint32 s = 0; s < pdbgPipelineStateD3D11->GetNumShaders(); ++s) { - LOG_ERROR_MESSAGE("Shader resource binding does not match Pipeline State"); - return; + auto* pShaderD3D11 = ValidatedCast(ppdbgShaders[s]); + if (pShaderD3D11->GetResources()->GetTotalResources() > 0) + ResourcesPresent = true; + } + + if (ResourcesPresent) + { + LOG_ERROR_MESSAGE("Pipeline state '", pPSO->GetDesc().Name, "' requires shader resource binding object to commit resources, but none is provided."); } +#endif + return; + } + + + auto pShaderResBindingD3D11 = ValidatedCast(pShaderResourceBinding); +#ifdef DEVELOPMENT + if (pdbgPipelineStateD3D11->IsIncompatibleWith(pShaderResourceBinding->GetPipelineState())) + { + LOG_ERROR_MESSAGE("Shader resource binding does not match Pipeline State"); + return; } #endif @@ -188,6 +200,7 @@ namespace Diligent if (pShaderD3D11->GetStaticResourceLayout().GetTotalResourceCount() > 0) StaticResourcesPresent = true; } + // Static resource bindings are verified in BindStaticShaderResources() if (StaticResourcesPresent && !pShaderResBindingD3D11->IsStaticResourcesBound()) { LOG_ERROR_MESSAGE("Static resources have not been initialized in the shader resource binding object. Please call IShaderResourceBinding::InitializeStaticResources()."); @@ -598,6 +611,8 @@ namespace Diligent void DeviceContextD3D11Impl::TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding) { + DEV_CHECK_ERR(pPipelineState != nullptr, "Pipeline state must not be null"); + DEV_CHECK_ERR(pShaderResourceBinding != nullptr, "Shader resource binding must not be null"); TransitionAndCommitShaderResources(pPipelineState, pShaderResourceBinding); } diff --git a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp index f3a37ddc..5a6f1de8 100644 --- a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp @@ -35,8 +35,7 @@ PipelineStateD3D11Impl::PipelineStateD3D11Impl(IReferenceCounters* pRefCoun RenderDeviceD3D11Impl* pRenderDeviceD3D11, const PipelineStateDesc& PipelineDesc) : TPipelineStateBase(pRefCounters, pRenderDeviceD3D11, PipelineDesc), - m_SRBMemAllocator(GetRawAllocator()), - m_pDefaultShaderResBinding( nullptr, STDDeleter(pRenderDeviceD3D11->GetSRBAllocator()) ) + m_SRBMemAllocator(GetRawAllocator()) { if (PipelineDesc.IsComputePipeline) { @@ -126,10 +125,6 @@ PipelineStateD3D11Impl::PipelineStateD3D11Impl(IReferenceCounters* pRefCoun m_SRBMemAllocator.Initialize(PipelineDesc.SRBAllocationGranularity, m_NumShaders, ShaderResLayoutDataSizes.data(), m_NumShaders, ShaderResCacheDataSizes.data()); } - - auto &SRBAllocator = pRenderDeviceD3D11->GetSRBAllocator(); - m_pDefaultShaderResBinding.reset( NEW_RC_OBJ(SRBAllocator, "ShaderResourceBindingD3D11Impl instance", ShaderResourceBindingD3D11Impl, this)(this, true) ); - m_pDefaultShaderResBinding->InitializeStaticResources(nullptr); } -- cgit v1.2.3