Use actual pipeline recursion depth when computing stack size
Use the maximum recursion depth as set in the used pipeline,
rather than the maximum recursion depth supported by a physical
device to avoid overflowing uint32 when computing the dynamic
stack size and/or creating exceptionally large stack, not needed by
the pipeline used in this test.
Components: Vulkan
Affects: dEQP-VK.ray_tracing_pipeline.misc.callableshaderstress*
VK-GL-CTS Issue: 2880
Change-Id: Ia4feee82099d34300c70af8eab13245d29d037d9
diff --git a/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingMiscTests.cpp b/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingMiscTests.cpp
index 87cf2c3..40cb7eb 100644
--- a/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingMiscTests.cpp
+++ b/external/vulkancts/modules/vulkan/ray_tracing/vktRayTracingMiscTests.cpp
@@ -987,10 +987,12 @@
return {"chit"};
}
- virtual deUint32 getDynamicStackSize() const
+ virtual deUint32 getDynamicStackSize(deUint32 maxPipelineRayRecursionDepth) const
{
DE_ASSERT(false);
+ DE_UNREF(maxPipelineRayRecursionDepth);
+
return 0;
}
@@ -1720,7 +1722,6 @@
m_gridSizeXYZ (tcu::UVec3 (128, 1, 1) ),
m_nMaxCallableLevels ( (useDynamicStackSize) ? 8
: 2 /* as per spec */),
- m_maxPipelineRayRecursionDepth (0),
m_useDynamicStackSize (useDynamicStackSize),
m_ahitShaderStackSize (0),
m_callableShaderStackSize (0),
@@ -1757,7 +1758,7 @@
return tcu::UVec3(m_gridSizeXYZ[0], m_gridSizeXYZ[1], m_gridSizeXYZ[2]);
}
- deUint32 getDynamicStackSize() const final
+ deUint32 getDynamicStackSize(const deUint32 maxPipelineRayRecursionDepth) const final
{
deUint32 result = 0;
const auto maxStackSpaceNeededForZerothTrace = static_cast<deUint32>(de::max(de::max(m_chitShaderStackSize, m_missShaderStackSize), m_isectShaderStackSize + m_ahitShaderStackSize) );
@@ -1766,8 +1767,8 @@
DE_ASSERT(m_useDynamicStackSize);
result = static_cast<deUint32>(m_raygenShaderStackSize) +
- de::min(1u, m_maxPipelineRayRecursionDepth) * maxStackSpaceNeededForZerothTrace +
- de::max(0u, m_maxPipelineRayRecursionDepth - 1) * maxStackSpaceNeededForNonZerothTraces +
+ de::min(1u, maxPipelineRayRecursionDepth) * maxStackSpaceNeededForZerothTrace +
+ de::max(0u, maxPipelineRayRecursionDepth - 1) * maxStackSpaceNeededForNonZerothTraces +
m_nMaxCallableLevels * static_cast<deUint32>(m_callableShaderStackSize);
DE_ASSERT(result != 0);
@@ -1800,8 +1801,7 @@
bool init( vkt::Context& /* context */,
RayTracingProperties* rtPropertiesPtr) final
{
- m_maxPipelineRayRecursionDepth = rtPropertiesPtr->getMaxRecursionDepth();
-
+ DE_UNREF(rtPropertiesPtr);
return true;
}
@@ -2332,7 +2332,6 @@
const tcu::UVec3 m_gridSizeXYZ;
const deUint32 m_nMaxCallableLevels;
- deUint32 m_maxPipelineRayRecursionDepth;
const bool m_useDynamicStackSize;
std::unique_ptr<TopLevelAccelerationStructure> m_tlPtr;
@@ -7794,7 +7793,7 @@
if (m_testPtr->usesDynamicStackSize() )
{
deviceInterface.cmdSetRayTracingPipelineStackSizeKHR( *cmdBufferPtr,
- m_testPtr->getDynamicStackSize() );
+ m_testPtr->getDynamicStackSize(m_testPtr->getMaxRecursionDepthUsed()) );
}
for (deUint32 nInvocation = 0; nInvocation < nTraceRaysInvocationsNeeded; ++nInvocation)