summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-02-23 02:01:50 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-03-19 00:38:10 +0000
commit859eb02ccdca5c2a69935e011810490b986cb719 (patch)
treef7594cd1dcaae6edc6a0cb9e8d292e79ccb6fb13 /Graphics/GraphicsEngine
parentFixed bug in DescriptorHeapAllocationManager (diff)
downloadDiligentCore-859eb02ccdca5c2a69935e011810490b986cb719.tar.gz
DiligentCore-859eb02ccdca5c2a69935e011810490b986cb719.zip
Implemented committed resource validation in d3d12
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp48
-rw-r--r--Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp12
2 files changed, 48 insertions, 12 deletions
diff --git a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp
index 93659fa7..bf7b2bf7 100644
--- a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp
+++ b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp
@@ -49,14 +49,15 @@ namespace Diligent
/// Validates pipeline resource signature description and throws an exception in case of an error.
void ValidatePipelineResourceSignatureDesc(const PipelineResourceSignatureDesc& Desc) noexcept(false);
+static constexpr Uint32 InvalidImmutableSamplerIndex = ~0u;
/// Finds an immutable sampler for the resource name 'ResourceName' that is defined in shader stages 'ShaderStages'.
/// If 'SamplerSuffix' is not null, it will be appended to the 'ResourceName'.
-/// Returns an index of the sampler in ImtblSamplers array, or -1 if there is no suitable sampler.
-Int32 FindImmutableSampler(const ImmutableSamplerDesc* ImtblSamplers,
- Uint32 NumImtblSamplers,
- SHADER_TYPE ShaderStages,
- const char* ResourceName,
- const char* SamplerSuffix);
+/// Returns an index of the sampler in ImtblSamplers array, or InvalidImmutableSamplerIndex if there is no suitable sampler.
+Uint32 FindImmutableSampler(const ImmutableSamplerDesc* ImtblSamplers,
+ Uint32 NumImtblSamplers,
+ SHADER_TYPE ShaderStages,
+ const char* ResourceName,
+ const char* SamplerSuffix);
/// Returns true if two pipeline resource signature descriptions are compatible, and false otherwise
bool PipelineResourceSignaturesCompatible(const PipelineResourceSignatureDesc& Desc0,
@@ -178,6 +179,41 @@ public:
return SHADER_TYPE_UNKNOWN;
}
+ static constexpr Uint32 InvalidResourceIndex = ~0u;
+ /// Finds a resource with the given name in the specified shader stage and returns its
+ /// index in m_Desc.Resources[], or InvalidResourceIndex if the resource is not found.
+ Uint32 FindResource(SHADER_TYPE ShaderStage, const char* ResourceName) const
+ {
+ for (Uint32 r = 0; r < this->m_Desc.NumResources; ++r)
+ {
+ const auto& ResDesc = this->m_Desc.Resources[r];
+ if ((ResDesc.ShaderStages & ShaderStage) != 0 && strcmp(ResDesc.Name, ResourceName) == 0)
+ return r;
+ }
+
+ return InvalidResourceIndex;
+ }
+
+ /// Finds an immutable with the given name in the specified shader stage and returns its
+ /// index in m_Desc.ImmutableSamplers[], or InvalidImmutableSamplerIndex if the sampler is not found.
+ Uint32 FindImmutableSampler(SHADER_TYPE ShaderStage, const char* ResourceName) const
+ {
+ return Diligent::FindImmutableSampler(this->m_Desc.ImmutableSamplers, this->m_Desc.NumImmutableSamplers,
+ ShaderStage, ResourceName, GetCombinedSamplerSuffix());
+ }
+
+ const PipelineResourceDesc& GetResourceDesc(Uint32 ResIndex) const
+ {
+ VERIFY_EXPR(ResIndex < this->m_Desc.NumResources);
+ return this->m_Desc.Resources[ResIndex];
+ }
+
+ const ImmutableSamplerDesc& GetImmutableSamplerDesc(Uint32 SampIndex) const
+ {
+ VERIFY_EXPR(SampIndex < this->m_Desc.NumImmutableSamplers);
+ return this->m_Desc.ImmutableSamplers[SampIndex];
+ }
+
protected:
void ReserveSpaceForDescription(FixedLinearAllocator& Allocator, const PipelineResourceSignatureDesc& Desc) const noexcept(false)
{
diff --git a/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp b/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
index 29c069de..a85e20dd 100644
--- a/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
+++ b/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
@@ -222,11 +222,11 @@ void ValidatePipelineResourceSignatureDesc(const PipelineResourceSignatureDesc&
#undef LOG_PRS_ERROR_AND_THROW
-Int32 FindImmutableSampler(const ImmutableSamplerDesc* ImtblSamplers,
- Uint32 NumImtblSamplers,
- SHADER_TYPE ShaderStages,
- const char* ResourceName,
- const char* SamplerSuffix)
+Uint32 FindImmutableSampler(const ImmutableSamplerDesc* ImtblSamplers,
+ Uint32 NumImtblSamplers,
+ SHADER_TYPE ShaderStages,
+ const char* ResourceName,
+ const char* SamplerSuffix)
{
for (Uint32 s = 0; s < NumImtblSamplers; ++s)
{
@@ -242,7 +242,7 @@ Int32 FindImmutableSampler(const ImmutableSamplerDesc* ImtblSamplers,
}
}
- return -1;
+ return InvalidImmutableSamplerIndex;
}
/// Returns true if two pipeline resources are compatible