Skip to content

Commit cff672c

Browse files
author
kevyuu
committed
Add more validation for trace ray dimensions.
1 parent 41ffc50 commit cff672c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/nbl/video/IGPUCommandBuffer.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1903,12 +1903,23 @@ bool IGPUCommandBuffer::traceRays(
19031903
if (!checkStateBeforeRecording(queue_flags_t::COMPUTE_BIT,RENDERPASS_SCOPE::OUTSIDE))
19041904
return false;
19051905

1906-
if (width == 0 || height == 0 || depth == 0)
1906+
const auto& limits = getOriginDevice()->getPhysicalDevice()->getLimits();
1907+
const auto maxWidth = limits.maxComputeWorkGroupCount[0] * limits.maxWorkgroupSize[0];
1908+
const auto maxHeight = limits.maxComputeWorkGroupCount[1] * limits.maxWorkgroupSize[1];
1909+
const auto maxDepth = limits.maxComputeWorkGroupCount[2] * limits.maxWorkgroupSize[2];
1910+
if (width == 0 || height == 0 || depth == 0 || width > maxWidth || height > maxHeight || depth > maxDepth)
19071911
{
19081912
NBL_LOG_ERROR("invalid work counts (%d, %d, %d)!", width, height, depth);
19091913
return false;
19101914
}
19111915

1916+
const auto invocationCount = width * height * depth;
1917+
if (invocationCount > limits.maxRayDispatchInvocationCount)
1918+
{
1919+
NBL_LOG_ERROR("invalid invocation count (%d)!", invocationCount);
1920+
return false;
1921+
}
1922+
19121923
if (m_boundRayTracingPipeline == nullptr)
19131924
{
19141925
NBL_LOG_ERROR("invalid bound pipeline for traceRays command!");

0 commit comments

Comments
 (0)