summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-03-06 07:00:47 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-03-19 00:38:16 +0000
commit72d2e4a6482150ee61b3124de546af1ec5a0bf38 (patch)
treef33e4b9bc627519b0d6e9755c902e6945a4a93b6 /Graphics/GraphicsEngine
parentReworked FenceGLImpl to use std::atomic (diff)
downloadDiligentCore-72d2e4a6482150ee61b3124de546af1ec5a0bf38.tar.gz
DiligentCore-72d2e4a6482150ee61b3124de546af1ec5a0bf38.zip
Moved GetResourceAttribution() function to PipelineStateBase to eliminate duplication
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/PipelineStateBase.hpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
index 558daf29..f831f4ea 100644
--- a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
+++ b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
@@ -43,6 +43,7 @@
#include "GraphicsAccessories.hpp"
#include "FixedLinearAllocator.hpp"
#include "HashUtils.hpp"
+#include "PipelineResourceSignatureBase.hpp"
namespace Diligent
{
@@ -94,6 +95,12 @@ private:
// Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.).
using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType;
+ // Pipeline state implementation type (PipelineStateD3D12Impl, PipelineStateVkImpl, etc.).
+ using PipelineStateImplType = typename EngineImplTraits::PipelineStateImplType;
+
+ // Pipeline resource signature implementation type (PipelineResourceSignatureD3D12Impl, PipelineResourceSignatureVkImpl, etc.).
+ using PipelineResourceSignatureImplType = typename EngineImplTraits::PipelineResourceSignatureImplType;
+
using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, PipelineStateDesc>;
/// \param pRefCounters - Reference counters object that controls the lifetime of this PSO
@@ -751,6 +758,70 @@ protected:
CopyResourceLayout(CreateInfo.PSODesc.ResourceLayout, this->m_Desc.ResourceLayout, MemPool);
}
+
+ // Resource attribution properties
+ struct ResourceAttribution
+ {
+ static constexpr Uint32 InvalidSignatureIndex = ~0u;
+ static constexpr Uint32 InvalidResourceIndex = PipelineResourceSignatureImplType::InvalidResourceIndex;
+ static constexpr Uint32 InvalidSamplerIndex = InvalidImmutableSamplerIndex;
+
+ const PipelineResourceSignatureImplType* pSignature = nullptr;
+
+ Uint32 SignatureIndex = InvalidSignatureIndex;
+ Uint32 ResourceIndex = InvalidResourceIndex;
+ Uint32 ImmutableSamplerIndex = InvalidSamplerIndex;
+
+ ResourceAttribution() noexcept {}
+ ResourceAttribution(const PipelineResourceSignatureImplType* _pSignature,
+ Uint32 _SignatureIndex,
+ Uint32 _ResourceIndex,
+ Uint32 _ImmutableSamplerIndex = InvalidResourceIndex) noexcept :
+ pSignature{_pSignature},
+ SignatureIndex{_SignatureIndex},
+ ResourceIndex{_ResourceIndex},
+ ImmutableSamplerIndex{_ImmutableSamplerIndex}
+ {
+ VERIFY_EXPR(pSignature == nullptr || pSignature->GetDesc().BindingIndex == SignatureIndex);
+ VERIFY_EXPR((ResourceIndex == InvalidResourceIndex) || (ImmutableSamplerIndex == InvalidSamplerIndex));
+ }
+
+ explicit operator bool() const
+ {
+ return ((SignatureIndex != InvalidSignatureIndex) &&
+ (ResourceIndex != InvalidResourceIndex || ImmutableSamplerIndex != InvalidSamplerIndex));
+ }
+
+ bool IsImmutableSampler() const
+ {
+ return operator bool() && ImmutableSamplerIndex != InvalidSamplerIndex;
+ }
+ };
+
+ ResourceAttribution GetResourceAttribution(const char* Name, SHADER_TYPE Stage) const
+ {
+ const auto* const pThis = static_cast<const PipelineStateImplType*>(this);
+
+ const auto SignCount = pThis->GetResourceSignatureCount();
+ for (Uint32 sign = 0; sign < SignCount; ++sign)
+ {
+ const PipelineResourceSignatureImplType* const pSignature = pThis->GetResourceSignature(sign);
+ if (pSignature == nullptr)
+ continue;
+
+ const auto ResIndex = pSignature->FindResource(Stage, Name);
+ if (ResIndex != ResourceAttribution::InvalidResourceIndex)
+ return ResourceAttribution{pSignature, sign, ResIndex};
+ else
+ {
+ const auto ImtblSamIndex = pSignature->FindImmutableSampler(Stage, Name);
+ if (ImtblSamIndex != ResourceAttribution::InvalidSamplerIndex)
+ return ResourceAttribution{pSignature, sign, ResourceAttribution::InvalidResourceIndex, ImtblSamIndex};
+ }
+ }
+ return ResourceAttribution{};
+ }
+
private:
static void ReserveResourceLayout(const PipelineResourceLayoutDesc& SrcLayout, FixedLinearAllocator& MemPool) noexcept
{