Skip to content

Commit 20ab6d6

Browse files
author
kevyuu
committed
Add setRayTracingStackSize validation
1 parent 85114be commit 20ab6d6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

include/nbl/video/IGPUCommandBuffer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ class NBL_API2 IGPUCommandBuffer : public IBackendObject
720720
m_boundGraphicsPipeline= nullptr;
721721
m_boundComputePipeline= nullptr;
722722
m_boundRayTracingPipeline= nullptr;
723+
m_haveRtPipelineStackSize = false;
723724

724725
m_commandList.head = nullptr;
725726
m_commandList.tail = nullptr;
@@ -736,6 +737,7 @@ class NBL_API2 IGPUCommandBuffer : public IBackendObject
736737
m_boundGraphicsPipeline= nullptr;
737738
m_boundComputePipeline= nullptr;
738739
m_boundRayTracingPipeline= nullptr;
740+
m_haveRtPipelineStackSize = false;
739741
releaseResourcesBackToPool_impl();
740742
}
741743

@@ -878,6 +880,7 @@ class NBL_API2 IGPUCommandBuffer : public IBackendObject
878880
uint64_t m_resetCheckedStamp;
879881
STATE m_state = STATE::INITIAL;
880882
bool m_noCommands = true;
883+
bool m_haveRtPipelineStackSize = false;
881884
// only useful while recording
882885
SInheritanceInfo m_cachedInheritanceInfo;
883886
core::bitflag<USAGE> m_recordingFlags = USAGE::NONE;

src/nbl/video/IGPUCommandBuffer.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,9 @@ bool IGPUCommandBuffer::resolveImage(const IGPUImage* const srcImage, const IGPU
18901890

18911891
bool IGPUCommandBuffer::setRayTracingPipelineStackSize(uint32_t pipelineStackSize)
18921892
{
1893+
if (!checkStateBeforeRecording(queue_flags_t::COMPUTE_BIT,RENDERPASS_SCOPE::OUTSIDE))
1894+
return false;
1895+
m_haveRtPipelineStackSize = true;
18931896
return setRayTracingPipelineStackSize_impl(pipelineStackSize);
18941897
}
18951898

@@ -1937,6 +1940,13 @@ bool IGPUCommandBuffer::traceRays(
19371940
return false;
19381941
}
19391942

1943+
// https://docs.vulkan.org/spec/latest/chapters/raytracing.html#VUID-vkCmdTraceRaysKHR-None-09458
1944+
if (m_boundRayTracingPipeline->getCachedCreationParams().dynamicStackSize && !m_haveRtPipelineStackSize)
1945+
{
1946+
NBL_LOG_ERROR("no setRayTracingPipelineStackSize command submitted before traceRays command with dynamic stack size pipeline!");
1947+
return false;
1948+
}
1949+
19401950
if (!m_cmdpool->m_commandListPool.emplace<IGPUCommandPool::CTraceRaysCmd>(m_commandList,
19411951
core::smart_refctd_ptr<const IGPUBuffer>(raygenGroupRange.buffer),
19421952
core::smart_refctd_ptr<const IGPUBuffer>(missGroupsRange.buffer),
@@ -1984,6 +1994,13 @@ bool IGPUCommandBuffer::traceRaysIndirect(
19841994
return false;
19851995
}
19861996

1997+
// https://docs.vulkan.org/spec/latest/chapters/raytracing.html#VUID-vkCmdTraceRaysIndirect2KHR-None-09458
1998+
if (m_boundRayTracingPipeline->getCachedCreationParams().dynamicStackSize && !m_haveRtPipelineStackSize)
1999+
{
2000+
NBL_LOG_ERROR("no setRayTracingPipelineStackSize command submitted before traceRays command with dynamic stack size pipeline!");
2001+
return false;
2002+
}
2003+
19872004
if (!m_cmdpool->m_commandListPool.emplace<IGPUCommandPool::CTraceRaysIndirectCmd>(m_commandList,
19882005
core::smart_refctd_ptr<const IGPUBuffer>(raygenGroupRange.buffer),
19892006
core::smart_refctd_ptr<const IGPUBuffer>(missGroupsRange.buffer),

0 commit comments

Comments
 (0)