Skip to content

Commit 85114be

Browse files
author
kevyuu
committed
Fix set stack size dynamic state handling.
1 parent b502404 commit 85114be

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

include/nbl/asset/IRayTracingPipeline.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class IRayTracingPipelineBase : public virtual core::IReferenceCounted
4545

4646
struct SCachedCreationParams final
4747
{
48-
uint32_t maxRecursionDepth;
48+
uint32_t maxRecursionDepth : 6 = 0;
49+
uint32_t dynamicStackSize : 1 = false;
4950
};
5051
};
5152

src/nbl/video/CVulkanLogicalDevice.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,15 @@ void CVulkanLogicalDevice::createRayTracingPipelines_impl(
14361436
using SGeneralShaderGroup = asset::IRayTracingPipelineBase::SGeneralShaderGroup;
14371437
using SHitShaderGroup = asset::IRayTracingPipelineBase::SHitShaderGroup;
14381438

1439+
const auto dynamicStates = std::array{ VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR };
1440+
const VkPipelineDynamicStateCreateInfo vk_dynamicStateCreateInfo = {
1441+
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
1442+
.pNext = nullptr,
1443+
.flags = 0u,
1444+
.dynamicStateCount = dynamicStates.size(),
1445+
.pDynamicStates = dynamicStates.data(),
1446+
};
1447+
14391448
const VkPipelineCache vk_pipelineCache = pipelineCache ? static_cast<const CVulkanPipelineCache*>(pipelineCache)->getInternalObject():VK_NULL_HANDLE;
14401449

14411450
size_t maxShaderStages = 0;
@@ -1512,6 +1521,10 @@ void CVulkanLogicalDevice::createRayTracingPipelines_impl(
15121521
*(outShaderGroup++) = getGeneralVkRayTracingShaderGroupCreateInfo(shaderGroup);
15131522
outCreateInfo->groupCount = 1 + shaderGroups.hits.size() + shaderGroups.misses.size() + shaderGroups.callables.size();
15141523
outCreateInfo->maxPipelineRayRecursionDepth = info.cached.maxRecursionDepth;
1524+
if (info.cached.dynamicStackSize)
1525+
{
1526+
outCreateInfo->pDynamicState = &vk_dynamicStateCreateInfo;
1527+
}
15151528
}
15161529

15171530
auto vk_pipelines = reinterpret_cast<VkPipeline*>(output);

0 commit comments

Comments
 (0)