summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-01-27 05:58:44 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-01-27 05:58:44 +0000
commitf1dbc752658cff61f95172fa1fad57f7bb17372c (patch)
treea5c654ef240dee1187312456ef83f3c598be17d3 /Graphics/GraphicsEngine
parentMoved CreateShaderResourceBinding, GetStaticVariableByName, GetStaticVariable... (diff)
downloadDiligentCore-f1dbc752658cff61f95172fa1fad57f7bb17372c.tar.gz
DiligentCore-f1dbc752658cff61f95172fa1fad57f7bb17372c.zip
Resource signature: added validation that texture and assigned samplers are compatible; some code cleanup.
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp b/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
index 167296c5..cf2cff2e 100644
--- a/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
+++ b/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
@@ -81,6 +81,42 @@ void ValidatePipelineResourceSignatureDesc(const PipelineResourceSignatureDesc&
LOG_PRS_ERROR_AND_THROW("Desc.Resources[", i, "].Flags must not contain PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER if ResourceType is not buffer");
}
+ if (Desc.UseCombinedTextureSamplers)
+ {
+ if (Desc.CombinedSamplerSuffix == nullptr)
+ LOG_PRS_ERROR_AND_THROW("Desc.UseCombinedTextureSamplers is true, but Desc.CombinedSamplerSuffix is null");
+
+ for (Uint32 i = 0; i < Desc.NumResources; ++i)
+ {
+ const auto& Res = Desc.Resources[i];
+ if (Res.ResourceType == SHADER_RESOURCE_TYPE_TEXTURE_SRV)
+ {
+ auto AssignedSamplerName = String{Res.Name} + Desc.CombinedSamplerSuffix;
+ for (Uint32 s = 0; s < Desc.NumResources; ++s)
+ {
+ const auto& Sam = Desc.Resources[s];
+ if (Sam.ResourceType != SHADER_RESOURCE_TYPE_SAMPLER)
+ continue;
+
+ if (AssignedSamplerName == Sam.Name && (Sam.ShaderStages & Res.ShaderStages) != 0)
+ {
+ if (Sam.ShaderStages != Res.ShaderStages)
+ {
+ LOG_PRS_ERROR_AND_THROW("Texture '", Res.Name, "' and sampler '", Sam.Name, "' assigned to it use different shader stages.");
+ }
+
+ if (Sam.VarType != Res.VarType)
+ {
+ LOG_PRS_ERROR_AND_THROW("The type (", GetShaderVariableTypeLiteralName(Res.VarType), ") of texture resource '", Res.Name,
+ "' does not match the type (", GetShaderVariableTypeLiteralName(Sam.VarType),
+ ") of sampler '", Sam.Name, "' that is assigned to it.");
+ }
+ }
+ }
+ }
+ }
+ }
+
for (Uint32 i = 0; i < Desc.NumImmutableSamplers; ++i)
{
if (Desc.ImmutableSamplers[i].SamplerOrTextureName == nullptr)