Skip to content

Commit

Permalink
Always pass CAPTURE_REPLAY RT pipeline create flags
Browse files Browse the repository at this point in the history
This is required for RT pipelines when capture/replay handles are used,
both during capture and replay.
  • Loading branch information
pixelcluster committed Dec 9, 2024
1 parent 15b4126 commit 22dd0f9
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions renderdoc/driver/vulkan/wrappers/vk_shader_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,23 @@ static RDResult DeferredPipelineCompile(VkDevice device,
VkRayTracingPipelineCreateInfoKHR *unwrapped =
UnwrapStructAndChain(CaptureState::LoadingReplaying, mem, &createInfo);

// Patch in capture/replay creation flags
VkBaseOutStructure *nextStruct = (VkBaseOutStructure *)unwrapped->pNext;
while(nextStruct)
{
if(nextStruct->sType != VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR)
{
nextStruct = nextStruct->pNext;
continue;
}
VkPipelineCreateFlags2CreateInfoKHR *flagsInfo =
(VkPipelineCreateFlags2CreateInfoKHR *)nextStruct;
flagsInfo->flags |= VK_PIPELINE_CREATE_2_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR;
break;
}
if(!nextStruct)
unwrapped->flags |= VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR;

// patch in the capture/replay handles we saved
VkRayTracingShaderGroupCreateInfoKHR *groups =
(VkRayTracingShaderGroupCreateInfoKHR *)unwrapped->pGroups;
Expand Down Expand Up @@ -1464,14 +1481,37 @@ VkResult WrappedVulkan::vkCreateRayTracingPipelinesKHR(
{
VkResult ret;

// to be extra sure just in case the driver doesn't, set pipelines to VK_NULL_HANDLE first.
VkRayTracingPipelineCreateInfoKHR *unwrappedCreateInfos =
UnwrapInfos(m_State, pCreateInfos, createInfoCount);

for(uint32_t i = 0; i < createInfoCount; i++)
{
// to be extra sure just in case the driver doesn't, set pipelines to VK_NULL_HANDLE first.
pPipelines[i] = VK_NULL_HANDLE;

// Patch in capture/replay creation flags
VkBaseOutStructure *nextStruct = (VkBaseOutStructure *)unwrappedCreateInfos[i].pNext;
while(nextStruct)
{
if(nextStruct->sType != VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR)
{
nextStruct = nextStruct->pNext;
continue;
}
VkPipelineCreateFlags2CreateInfoKHR *flagsInfo =
(VkPipelineCreateFlags2CreateInfoKHR *)nextStruct;
flagsInfo->flags |= VK_PIPELINE_CREATE_2_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR;
break;
}
if(!nextStruct)
unwrappedCreateInfos[i].flags |=
VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR;
}

// deferred operations are currently not wrapped
SERIALISE_TIME_CALL(ret = ObjDisp(device)->CreateRayTracingPipelinesKHR(
Unwrap(device), VK_NULL_HANDLE, Unwrap(pipelineCache), createInfoCount,
UnwrapInfos(m_State, pCreateInfos, createInfoCount), NULL, pPipelines));
unwrappedCreateInfos, NULL, pPipelines));

if(ret == VK_SUCCESS || ret == VK_PIPELINE_COMPILE_REQUIRED)
{
Expand Down

0 comments on commit 22dd0f9

Please sign in to comment.