summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-12-23 04:53:07 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-12-23 04:53:07 +0000
commit6d151d4cdd7448465d0fee093c2fd030cf9ed040 (patch)
tree66e108982f2e2df04f150d359dad9564a18b63f6 /Graphics/GraphicsEngine
parentPipelineStateVkImpl: reworked ray tracing shader group initialization (diff)
downloadDiligentCore-6d151d4cdd7448465d0fee093c2fd030cf9ed040.tar.gz
DiligentCore-6d151d4cdd7448465d0fee093c2fd030cf9ed040.zip
Fixed some issues with PSO create info validation
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/PipelineStateBase.hpp30
-rw-r--r--Graphics/GraphicsEngine/src/PipelineStateBase.cpp47
2 files changed, 52 insertions, 25 deletions
diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
index 127d46dd..2c46f314 100644
--- a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
+++ b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp
@@ -103,7 +103,15 @@ public:
bool bIsDeviceInternal = false) :
PipelineStateBase{pRefCounters, pDevice, GraphicsPipelineCI.PSODesc, bIsDeviceInternal}
{
- ValidateGraphicsPipelineCreateInfo(GraphicsPipelineCI);
+ try
+ {
+ ValidateGraphicsPipelineCreateInfo(GraphicsPipelineCI);
+ }
+ catch (...)
+ {
+ Destruct();
+ throw;
+ }
}
/// Initializes the object as compute pipeline
@@ -119,7 +127,15 @@ public:
bool bIsDeviceInternal = false) :
PipelineStateBase{pRefCounters, pDevice, ComputePipelineCI.PSODesc, bIsDeviceInternal}
{
- ValidateComputePipelineCreateInfo(ComputePipelineCI);
+ try
+ {
+ ValidateComputePipelineCreateInfo(ComputePipelineCI);
+ }
+ catch (...)
+ {
+ Destruct();
+ throw;
+ }
}
/// Initializes the object as ray tracing pipeline
@@ -135,7 +151,15 @@ public:
bool bIsDeviceInternal = false) :
PipelineStateBase{pRefCounters, pDevice, RayTracingPipelineCI.PSODesc, bIsDeviceInternal}
{
- ValidateRayTracingPipelineCreateInfo(pDevice, pDevice->GetProperties().MaxRayTracingRecursionDepth, RayTracingPipelineCI);
+ try
+ {
+ ValidateRayTracingPipelineCreateInfo(pDevice, pDevice->GetProperties().MaxRayTracingRecursionDepth, RayTracingPipelineCI);
+ }
+ catch (...)
+ {
+ Destruct();
+ throw;
+ }
}
diff --git a/Graphics/GraphicsEngine/src/PipelineStateBase.cpp b/Graphics/GraphicsEngine/src/PipelineStateBase.cpp
index cb25f257..f7e4048d 100644
--- a/Graphics/GraphicsEngine/src/PipelineStateBase.cpp
+++ b/Graphics/GraphicsEngine/src/PipelineStateBase.cpp
@@ -266,23 +266,34 @@ void ValidateRayTracingPipelineCreateInfo(IRenderDevice* pDevice, Uint32 MaxRecu
if (CreateInfo.RayTracingPipeline.MaxRecursionDepth > MaxRecursion)
{
- LOG_PSO_ERROR_AND_THROW("MaxRecursionDepth must not exceed the ", MaxRecursion);
+ LOG_PSO_ERROR_AND_THROW("MaxRecursionDepth (", Uint32{CreateInfo.RayTracingPipeline.MaxRecursionDepth},
+ ") exceeds device limit (", MaxRecursion, ").");
}
std::unordered_set<HashMapStringKey, HashMapStringKey::Hasher> GroupNames;
+ auto VerifyShaderGroupName = [&](const char* MemberName, // "pGeneralShaders", "pTriangleHitShaders", or "pProceduralHitShaders"
+ Uint32 GroupInd,
+ const char* GroupName) {
+ if (GroupName == nullptr)
+ LOG_PSO_ERROR_AND_THROW(MemberName, "[", GroupInd, "].Name must not be null.");
+
+ if (*GroupName == 0)
+ LOG_PSO_ERROR_AND_THROW(MemberName, "[", GroupInd, "].Name must not be empty.");
+
+ const bool IsNewName = GroupNames.emplace(HashMapStringKey{GroupName}).second;
+ if (!IsNewName)
+ LOG_PSO_ERROR_AND_THROW(MemberName, "[", GroupInd, "].Name ('", GroupName, "') has already been assigned to another group. All group names must be unique.");
+ };
+
for (Uint32 i = 0; i < CreateInfo.GeneralShaderCount; ++i)
{
const auto& Group = CreateInfo.pGeneralShaders[i];
- if (Group.pShader == nullptr)
- LOG_PSO_ERROR_AND_THROW("pGeneralShaders[", i, "].pShader must not be null.");
- if (Group.Name == nullptr)
- LOG_PSO_ERROR_AND_THROW("pGeneralShaders[", i, "].Name must not be null.");
- const bool IsNewName = GroupNames.emplace(HashMapStringKey{Group.Name}).second;
- if (!IsNewName)
- LOG_PSO_ERROR_AND_THROW("pGeneralShaders[", i, "].Name ('", Group.Name, "') has already been assigned to another group. All group names must be unique.");
+ VerifyShaderGroupName("pGeneralShaders", i, Group.Name);
+ if (Group.pShader == nullptr)
+ LOG_PSO_ERROR_AND_THROW("pGeneralShaders[", i, "].pShader must not be null.");
switch (Group.pShader->GetDesc().ShaderType)
{
case SHADER_TYPE_RAY_GEN:
@@ -296,15 +307,11 @@ void ValidateRayTracingPipelineCreateInfo(IRenderDevice* pDevice, Uint32 MaxRecu
for (Uint32 i = 0; i < CreateInfo.TriangleHitShaderCount; ++i)
{
const auto& Group = CreateInfo.pTriangleHitShaders[i];
- if (Group.pClosestHitShader == nullptr)
- LOG_PSO_ERROR_AND_THROW("pTriangleHitShaders[", i, "].pClosestHitShader must not be null.");
- if (Group.Name == nullptr)
- LOG_PSO_ERROR_AND_THROW("pTriangleHitShaders[", i, "].Name must not be null.");
- const bool IsNewName = GroupNames.emplace(HashMapStringKey{Group.Name}).second;
- if (!IsNewName)
- LOG_PSO_ERROR_AND_THROW("pTriangleHitShaders[", i, "].Name ('", Group.Name, "') has already been assigned to another group. All group names must be unique.");
+ VerifyShaderGroupName("pTriangleHitShaders", i, Group.Name);
+ if (Group.pClosestHitShader == nullptr)
+ LOG_PSO_ERROR_AND_THROW("pTriangleHitShaders[", i, "].pClosestHitShader must not be null.");
VALIDATE_SHADER_TYPE(Group.pClosestHitShader, SHADER_TYPE_RAY_CLOSEST_HIT, "ray tracing triangle closest hit.");
if (Group.pAnyHitShader != nullptr)
@@ -314,15 +321,11 @@ void ValidateRayTracingPipelineCreateInfo(IRenderDevice* pDevice, Uint32 MaxRecu
for (Uint32 i = 0; i < CreateInfo.ProceduralHitShaderCount; ++i)
{
const auto& Group = CreateInfo.pProceduralHitShaders[i];
- if (Group.pIntersectionShader == nullptr)
- LOG_PSO_ERROR_AND_THROW("pProceduralHitShaders[", i, "].pIntersectionShader must not be null.");
- if (Group.Name == nullptr)
- LOG_PSO_ERROR_AND_THROW("pProceduralHitShaders[", i, "].Name must not be null.");
- const bool IsNewName = GroupNames.emplace(HashMapStringKey{Group.Name}).second;
- if (!IsNewName)
- LOG_PSO_ERROR_AND_THROW("pProceduralHitShaders[", i, "].Name ('", Group.Name, "') has already been assigned to another group. All group names must be unique.");
+ VerifyShaderGroupName("pProceduralHitShaders", i, Group.Name);
+ if (Group.pIntersectionShader == nullptr)
+ LOG_PSO_ERROR_AND_THROW("pProceduralHitShaders[", i, "].pIntersectionShader must not be null.");
VALIDATE_SHADER_TYPE(Group.pIntersectionShader, SHADER_TYPE_RAY_INTERSECTION, "ray tracing procedural intersection.");
if (Group.pClosestHitShader != nullptr)