@@ -50,7 +50,7 @@ namespace nbl::asset
50
50
struct SCachedCreationParams final
51
51
{
52
52
SShaderGroupsParams shaderGroups;
53
- uint64_t maxRecursionDepth;
53
+ uint32_t maxRecursionDepth;
54
54
};
55
55
};
56
56
@@ -92,27 +92,38 @@ namespace nbl::asset
92
92
if (getShaderStage (cached.shaderGroups .raygenGroup .shaderIndex ) != ICPUShader::E_SHADER_STAGE::ESS_RAYGEN)
93
93
return false ;
94
94
95
+ auto isValidShaderIndex = [this , getShaderStage](size_t index , ICPUShader::E_SHADER_STAGE expectedStage) -> bool
96
+ {
97
+ if (index == SShaderGroupsParams::ShaderUnused)
98
+ return true ;
99
+ if (index >= shaders.size ())
100
+ return false ;
101
+ if (getShaderStage (index ) != expectedStage)
102
+ return false ;
103
+ return true ;
104
+ };
105
+
95
106
for (const auto & shaderGroup : cached.shaderGroups .hitGroups )
96
107
{
97
- if (shaderGroup. anyHitShaderIndex != SShaderGroupsParams::ShaderUnused && getShaderStage (shaderGroup.anyHitShaderIndex ) != ICPUShader::E_SHADER_STAGE::ESS_ANY_HIT)
108
+ if (! isValidShaderIndex (shaderGroup.anyHitShaderIndex , ICPUShader::E_SHADER_STAGE::ESS_ANY_HIT) )
98
109
return false ;
99
110
100
- if (shaderGroup. closestHitShaderIndex != SShaderGroupsParams::ShaderUnused && getShaderStage (shaderGroup.closestHitShaderIndex ) != ICPUShader::E_SHADER_STAGE::ESS_CLOSEST_HIT)
111
+ if (! isValidShaderIndex (shaderGroup.closestHitShaderIndex , ICPUShader::E_SHADER_STAGE::ESS_CLOSEST_HIT) )
101
112
return false ;
102
113
103
- if (shaderGroup. intersectionShaderIndex != SShaderGroupsParams::ShaderUnused && getShaderStage (shaderGroup.intersectionShaderIndex ) != ICPUShader::E_SHADER_STAGE::ESS_INTERSECTION)
114
+ if (! isValidShaderIndex (shaderGroup.intersectionShaderIndex , ICPUShader::E_SHADER_STAGE::ESS_INTERSECTION) )
104
115
return false ;
105
116
}
106
117
107
118
for (const auto & shaderGroup : cached.shaderGroups .missGroups )
108
119
{
109
- if (getShaderStage (shaderGroup.shaderIndex ) != ICPUShader::E_SHADER_STAGE::ESS_MISS)
120
+ if (! isValidShaderIndex (shaderGroup.shaderIndex , ICPUShader::E_SHADER_STAGE::ESS_MISS) )
110
121
return false ;
111
122
}
112
123
113
124
for (const auto & shaderGroup : cached.shaderGroups .callableShaderGroups )
114
125
{
115
- if (getShaderStage (shaderGroup.shaderIndex ) != ICPUShader::E_SHADER_STAGE::ESS_CALLABLE)
126
+ if (! isValidShaderIndex (shaderGroup.shaderIndex , ICPUShader::E_SHADER_STAGE::ESS_CALLABLE) )
116
127
return false ;
117
128
}
118
129
return true ;
0 commit comments