From 3948fc345b99465f2d792114d06d0e374465ce3d Mon Sep 17 00:00:00 2001 From: azhirnov Date: Sat, 30 Jan 2021 16:21:53 +0300 Subject: update for vulkan PRS --- .../include/PipelineResourceSignatureBase.hpp | 28 ++++++++++++++++++++++ .../include/PipelineLayoutVk.hpp | 10 ++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp index f1634fed..ceb70688 100644 --- a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp +++ b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp @@ -39,6 +39,7 @@ #include "DeviceObjectBase.hpp" #include "RenderDeviceBase.hpp" #include "FixedLinearAllocator.hpp" +#include "BasicMath.hpp" namespace Diligent { @@ -100,6 +101,27 @@ public: return std::pair{m_ResourceOffsets[VarType], m_ResourceOffsets[VarType + 1]}; } + // Returns the number of shader stages that have resources. + Uint32 GetNumActiveShaderStages() const { return m_NumShaderStages; } + + // Returns the type of the active shader stage with the given index. + SHADER_TYPE GetActiveShaderStageType(Uint32 StageIndex) const + { + VERIFY_EXPR(StageIndex < m_NumShaderStages); + + SHADER_TYPE Stages = m_ShaderStages; + for (Uint32 Index = 0; Stages != SHADER_TYPE_UNKNOWN; ++Index) + { + auto StageBit = ExtractLSB(Stages); + + if (Index == StageIndex) + return StageBit; + } + + UNEXPECTED("Index is out of range"); + return SHADER_TYPE_UNKNOWN; + } + protected: void ReserveSpaceForDescription(FixedLinearAllocator& Allocator, const PipelineResourceSignatureDesc& Desc) const noexcept(false) { @@ -252,10 +274,16 @@ protected: protected: size_t m_Hash = 0; + // Shader stages that have resources. + SHADER_TYPE m_ShaderStages = SHADER_TYPE_UNKNOWN; + std::array m_ResourceOffsets = {}; PIPELINE_TYPE m_PipelineType = PIPELINE_TYPE_INVALID; + // The number of shader stages that have resources. + Uint8 m_NumShaderStages = 0; // AZ TODO: remove ? + #ifdef DILIGENT_DEBUG bool m_IsDestructed = false; #endif diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineLayoutVk.hpp b/Graphics/GraphicsEngineVulkan/include/PipelineLayoutVk.hpp index 72b6f6ef..eed3507d 100644 --- a/Graphics/GraphicsEngineVulkan/include/PipelineLayoutVk.hpp +++ b/Graphics/GraphicsEngineVulkan/include/PipelineLayoutVk.hpp @@ -61,10 +61,16 @@ public: } // Returns the index of the first descriptor set used by the given resource signature - Uint32 GetFirstDescrSetIndex(const IPipelineResourceSignature* pPRS) const + Uint32 GetFirstDescrSetIndex(const PipelineResourceSignatureVkImpl* pPRS) const { + VERIFY_EXPR(pPRS != nullptr); Uint32 Index = pPRS->GetDesc().BindingIndex; - return Index < m_SignatureCount ? m_FirstDescrSetIndex[Index] : ~0u; + + VERIFY_EXPR(Index < m_SignatureCount); + VERIFY_EXPR(m_Signatures[Index] != nullptr); + VERIFY_EXPR(!m_Signatures[Index]->IsIncompatibleWith(*pPRS)); + + return m_FirstDescrSetIndex[Index]; } struct ResourceInfo -- cgit v1.2.3