5
5
#define NBL_LOG_FUNCTION m_logger.log
6
6
#include " nbl/logging_macros.h"
7
7
8
+ #include " nbl/builtin/hlsl/indirect_commands.hlsl"
9
+
8
10
namespace nbl ::video
9
11
{
10
12
@@ -992,6 +994,11 @@ bool IGPUCommandBuffer::bindRayTracingPipeline(const IGPURayTracingPipeline* con
992
994
return false ;
993
995
}
994
996
997
+ if (!pipeline->getCachedCreationParams ().dynamicStackSize )
998
+ {
999
+ m_haveRtPipelineStackSize = false ;
1000
+ }
1001
+
995
1002
m_boundRayTracingPipeline = pipeline;
996
1003
997
1004
m_noCommands = false ;
@@ -1892,6 +1899,10 @@ bool IGPUCommandBuffer::setRayTracingPipelineStackSize(uint32_t pipelineStackSiz
1892
1899
{
1893
1900
if (!checkStateBeforeRecording (queue_flags_t ::COMPUTE_BIT,RENDERPASS_SCOPE::OUTSIDE))
1894
1901
return false ;
1902
+ if (m_boundRayTracingPipeline != nullptr && m_boundRayTracingPipeline->getCachedCreationParams ().dynamicStackSize )
1903
+ {
1904
+ NBL_LOG_ERROR (" Cannot set dynamic state when state is not mark as dynamic on bound pipeline!" );
1905
+ }
1895
1906
m_haveRtPipelineStackSize = true ;
1896
1907
return setRayTracingPipelineStackSize_impl (pipelineStackSize);
1897
1908
}
@@ -1967,12 +1978,7 @@ bool IGPUCommandBuffer::traceRays(
1967
1978
width, height, depth);
1968
1979
}
1969
1980
1970
- bool IGPUCommandBuffer::traceRaysIndirect (
1971
- const asset::SBufferRange<const IGPUBuffer>& raygenGroupRange,
1972
- const asset::SBufferRange<const IGPUBuffer>& missGroupsRange, uint32_t missGroupStride,
1973
- const asset::SBufferRange<const IGPUBuffer>& hitGroupsRange, uint32_t hitGroupStride,
1974
- const asset::SBufferRange<const IGPUBuffer>& callableGroupsRange, uint32_t callableGroupStride,
1975
- const asset::SBufferBinding<const IGPUBuffer>& indirectBinding)
1981
+ bool IGPUCommandBuffer::traceRaysIndirect (const asset::SBufferBinding<const IGPUBuffer>& indirectBinding)
1976
1982
{
1977
1983
if (!checkStateBeforeRecording (queue_flags_t ::COMPUTE_BIT,RENDERPASS_SCOPE::OUTSIDE))
1978
1984
return false ;
@@ -1982,15 +1988,16 @@ bool IGPUCommandBuffer::traceRaysIndirect(
1982
1988
NBL_LOG_ERROR (" invalid bound pipeline for traceRays command!" );
1983
1989
return false ;
1984
1990
}
1985
- const auto flags = m_boundRayTracingPipeline->getCreationFlags ();
1986
1991
1987
- if (invalidShaderGroups (raygenGroupRange,
1988
- missGroupsRange, missGroupStride,
1989
- hitGroupsRange, hitGroupStride,
1990
- callableGroupsRange, callableGroupStride,
1991
- flags))
1992
+ // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdTraceRaysIndirectKHR.html#VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634
1993
+ // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdTraceRaysIndirectKHR.html#VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03633
1994
+ if (invalidBufferBinding (indirectBinding, 4u ,IGPUBuffer::EUF_INDIRECT_BUFFER_BIT | IGPUBuffer::EUF_SHADER_DEVICE_ADDRESS_BIT))
1995
+ return false ;
1996
+
1997
+ https:// docs.vulkan.org/spec/latest/chapters/raytracing.html#VUID-vkCmdTraceRaysIndirect2KHR-indirectDeviceAddress-03633
1998
+ if (indirectBinding.buffer ->getSize () - indirectBinding.offset <= sizeof (hlsl::TraceRaysIndirectCommand_t))
1992
1999
{
1993
- NBL_LOG_ERROR (" invalid shader groups for traceRays command !" );
2000
+ NBL_LOG_ERROR (" buffer size - offset must be at least the size of TraceRaysIndirectCommand_t !" );
1994
2001
return false ;
1995
2002
}
1996
2003
@@ -2002,29 +2009,15 @@ bool IGPUCommandBuffer::traceRaysIndirect(
2002
2009
}
2003
2010
2004
2011
if (!m_cmdpool->m_commandListPool .emplace <IGPUCommandPool::CTraceRaysIndirectCmd>(m_commandList,
2005
- core::smart_refctd_ptr<const IGPUBuffer>(raygenGroupRange.buffer ),
2006
- core::smart_refctd_ptr<const IGPUBuffer>(missGroupsRange.buffer ),
2007
- core::smart_refctd_ptr<const IGPUBuffer>(hitGroupsRange.buffer ),
2008
- core::smart_refctd_ptr<const IGPUBuffer>(callableGroupsRange.buffer ),
2009
2012
core::smart_refctd_ptr<const IGPUBuffer>(indirectBinding.buffer )))
2010
2013
{
2011
2014
NBL_LOG_ERROR (" out of host memory!" );
2012
2015
return false ;
2013
2016
}
2014
2017
2015
- // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdTraceRaysIndirectKHR.html#VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634
2016
- // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdTraceRaysIndirectKHR.html#VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03633
2017
- if (invalidBufferBinding (indirectBinding, 4u ,IGPUBuffer::EUF_INDIRECT_BUFFER_BIT | IGPUBuffer::EUF_SHADER_DEVICE_ADDRESS_BIT))
2018
- return false ;
2019
-
2020
2018
m_noCommands = false ;
2021
2019
2022
- return traceRaysIndirect_impl (
2023
- raygenGroupRange,
2024
- missGroupsRange, missGroupStride,
2025
- hitGroupsRange, hitGroupStride,
2026
- callableGroupsRange, callableGroupStride,
2027
- indirectBinding);
2020
+ return traceRaysIndirect_impl (indirectBinding);
2028
2021
}
2029
2022
2030
2023
bool IGPUCommandBuffer::executeCommands (const uint32_t count, IGPUCommandBuffer* const * const cmdbufs)
0 commit comments