summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-03-01 19:45:04 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-03-19 00:38:13 +0000
commita5aa4f7f3b82a097c73712cade508cf7a9274e67 (patch)
tree9b78f0493e38f047ec69687f0eba2fb8f5790c7a /Graphics/GraphicsEngine
parentAdded test for input attachments in the resource signature; fixed few issues ... (diff)
downloadDiligentCore-a5aa4f7f3b82a097c73712cade508cf7a9274e67.tar.gz
DiligentCore-a5aa4f7f3b82a097c73712cade508cf7a9274e67.zip
Added resource signature creation failure test; fxied validation of resource flags.
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp75
1 files changed, 7 insertions, 68 deletions
diff --git a/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp b/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
index 29b2959b..4fa3029d 100644
--- a/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
+++ b/Graphics/GraphicsEngine/src/PipelineResourceSignatureBase.cpp
@@ -85,78 +85,17 @@ void ValidatePipelineResourceSignatureDesc(const PipelineResourceSignatureDesc&
if ((Res.Flags & PIPELINE_RESOURCE_FLAG_RUNTIME_ARRAY) != 0 && !ShaderResourceRuntimeArraySupported)
{
- LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags: RUNTIME_ARRAY can be used only if ShaderResourceRuntimeArray device feature is enabled.");
+ LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags: RUNTIME_ARRAY can only be used if ShaderResourceRuntimeArray device feature is enabled.");
}
static_assert(SHADER_RESOURCE_TYPE_LAST == 8, "Please add the new resource type to the switch below");
- switch (Res.ResourceType)
- {
- case SHADER_RESOURCE_TYPE_CONSTANT_BUFFER:
- if ((Res.Flags & ~PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS) != 0)
- {
- LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags (", GetPipelineResourceFlagsString(Res.Flags),
- "): NO_DYNAMIC_BUFFERS is the only valid flag for a constant buffer.");
- }
- break;
- case SHADER_RESOURCE_TYPE_TEXTURE_SRV:
- if ((Res.Flags & ~PIPELINE_RESOURCE_FLAG_COMBINED_SAMPLER) != 0)
- {
- LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags (", GetPipelineResourceFlagsString(Res.Flags),
- "): COMBINED_SAMPLER is the only valid flag for a texture SRV.");
- }
- break;
-
- case SHADER_RESOURCE_TYPE_BUFFER_SRV:
- if ((Res.Flags & ~(PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS | PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER)) != 0)
- {
- LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags (", GetPipelineResourceFlagsString(Res.Flags),
- "): NO_DYNAMIC_BUFFERS and FORMATTED_BUFFER are the only valid flags for a buffer SRV.");
- }
- break;
-
- case SHADER_RESOURCE_TYPE_TEXTURE_UAV:
- if (Res.Flags != PIPELINE_RESOURCE_FLAG_UNKNOWN)
- {
- LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags (", GetPipelineResourceFlagsString(Res.Flags),
- "): UNKNOWN is the only valid flag for a texture UAV.");
- }
- break;
-
- case SHADER_RESOURCE_TYPE_BUFFER_UAV:
- if ((Res.Flags & ~(PIPELINE_RESOURCE_FLAG_NO_DYNAMIC_BUFFERS | PIPELINE_RESOURCE_FLAG_FORMATTED_BUFFER)) != 0)
- {
- LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags (", GetPipelineResourceFlagsString(Res.Flags),
- "): NO_DYNAMIC_BUFFERS and FORMATTED_BUFFER are the only valid flags for a buffer UAV.");
- }
- break;
-
- case SHADER_RESOURCE_TYPE_SAMPLER:
- if (Res.Flags != PIPELINE_RESOURCE_FLAG_UNKNOWN)
- {
- LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags (", GetPipelineResourceFlagsString(Res.Flags),
- "): UNKNOWN is the only valid flag for a sampler.");
- }
- break;
-
- case SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT:
- if (Res.Flags != PIPELINE_RESOURCE_FLAG_UNKNOWN)
- {
- LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags (", GetPipelineResourceFlagsString(Res.Flags),
- "): UNKNOWN is the only valid flag for an input attachment.");
- }
- break;
-
- case SHADER_RESOURCE_TYPE_ACCEL_STRUCT:
- if (Res.Flags != PIPELINE_RESOURCE_FLAG_UNKNOWN)
- {
- LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags (", GetPipelineResourceFlagsString(Res.Flags),
- "): UNKNOWN is the only valid flag for an acceleration structure.");
- }
- break;
-
- default:
- UNEXPECTED("Unexpected resource type");
+ auto AllowedResourceFlags = GetValidPipelineResourceFlags(Res.ResourceType);
+ if ((Res.Flags & ~AllowedResourceFlags) != 0)
+ {
+ LOG_PRS_ERROR_AND_THROW("Incorrect Desc.Resources[", i, "].Flags (", GetPipelineResourceFlagsString(Res.Flags),
+ "). Only the following flags are valid for a ", GetShaderResourceTypeLiteralName(Res.ResourceType),
+ ": ", GetPipelineResourceFlagsString(AllowedResourceFlags, false, ", "), ".");
}
ResourcesByName.emplace(Res.Name, Res);