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/PipelineStateVkImpl.h | 4 --- .../src/PipelineStateVkImpl.cpp | 31 ++++++---------------- 2 files changed, 8 insertions(+), 27 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h index 0d2988c7..dc9a87cb 100644 --- a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h @@ -106,10 +106,6 @@ private: std::array m_ShaderModules; - // Do not use strong reference to avoid cyclic references - // Default SRB must be defined after allocators - std::unique_ptr > m_pDefaultShaderResBinding; - VkRenderPass m_RenderPass = VK_NULL_HANDLE; // Render passes are managed by the render device VulkanUtilities::PipelineWrapper m_Pipeline; PipelineLayout m_PipelineLayout; diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp index dbdbd63c..24d9b068 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp @@ -147,8 +147,7 @@ PipelineStateVkImpl :: PipelineStateVkImpl(IReferenceCounters* pRefCounters RenderDeviceVkImpl* pDeviceVk, const PipelineStateDesc& PipelineDesc) : TPipelineStateBase(pRefCounters, pDeviceVk, PipelineDesc), - m_SRBMemAllocator(GetRawAllocator()), - m_pDefaultShaderResBinding(nullptr, STDDeleter(pDeviceVk->GetSRBAllocator()) ) + m_SRBMemAllocator(GetRawAllocator()) { const auto& LogicalDevice = pDeviceVk->GetLogicalDevice(); @@ -421,15 +420,6 @@ PipelineStateVkImpl :: PipelineStateVkImpl(IReferenceCounters* pRefCounters m_HasNonStaticResources = true; } - // If there are only static resources, create default shader resource binding - if (m_HasStaticResources && !m_HasNonStaticResources) - { - auto& SRBAllocator = pDeviceVk->GetSRBAllocator(); - // Default shader resource binding must be initialized after resource layouts are parsed! - m_pDefaultShaderResBinding.reset( NEW_RC_OBJ(SRBAllocator, "ShaderResourceBindingVkImpl instance", ShaderResourceBindingVkImpl, this)(this, true) ); - m_pDefaultShaderResBinding->InitializeStaticResources(this); - } - m_ShaderResourceLayoutHash = m_PipelineLayout.GetHash(); } @@ -446,11 +436,7 @@ PipelineStateVkImpl::~PipelineStateVkImpl() } } - // Default SRB must be destroyed before SRB allocators - m_pDefaultShaderResBinding.reset(); - auto& RawAllocator = GetRawAllocator(); - for (Uint32 s=0; s < m_NumShaders; ++s) { m_ShaderResourceLayouts[s].~ShaderResourceLayoutVk(); @@ -529,22 +515,21 @@ void PipelineStateVkImpl::CommitAndTransitionShaderResources(IShaderResourceBind return; #ifdef DEVELOPMENT - if (pShaderResourceBinding == nullptr && m_HasNonStaticResources) + if (pShaderResourceBinding == nullptr) { - LOG_ERROR_MESSAGE("Pipeline state \"", m_Desc.Name, "\" contains mutable/dynamic shader variables and requires shader resource binding to commit all resources, but none is provided."); + LOG_ERROR_MESSAGE("Pipeline state '", m_Desc.Name, "' requires shader resource binding object to commit its resources, but none is provided."); + return; } #endif - // If the shaders contain no resources or static resources only, shader resource binding may be null. - // In this case use special internal SRB object - auto* pResBindingVkImpl = pShaderResourceBinding ? ValidatedCast(pShaderResourceBinding) : m_pDefaultShaderResBinding.get(); - + auto* pResBindingVkImpl = ValidatedCast(pShaderResourceBinding); + #ifdef DEVELOPMENT { auto* pRefPSO = pResBindingVkImpl->GetPipelineState(); - if ( IsIncompatibleWith(pRefPSO) ) + if (IsIncompatibleWith(pRefPSO)) { - LOG_ERROR_MESSAGE("Shader resource binding is incompatible with the pipeline state \"", m_Desc.Name, "\". Operation will be ignored."); + LOG_ERROR_MESSAGE("Shader resource binding is incompatible with the pipeline state '", m_Desc.Name, "'. Operation will be ignored."); return; } } -- cgit v1.2.3