diff --git a/framework/decode/vulkan_replay_consumer_base.cpp b/framework/decode/vulkan_replay_consumer_base.cpp old mode 100644 new mode 100755 index dd0ae788b9..d9b28717d3 --- a/framework/decode/vulkan_replay_consumer_base.cpp +++ b/framework/decode/vulkan_replay_consumer_base.cpp @@ -5356,9 +5356,13 @@ VkResult VulkanReplayConsumerBase::OverrideAcquireNextImageKHR(PFN_vkAcquireNext // If expected result is VK_TIMEOUT, try to get a timeout by using a timeout of 0. // If expected result is anything else, use the passed in timeout value. if (original_result == VK_SUCCESS) + { timeout = std::numeric_limits::max(); + } else if (original_result == VK_TIMEOUT) + { timeout = 0; + } result = swapchain_->AcquireNextImageKHR( func, device_info, swapchain_info, timeout, semaphore_info, fence_info, captured_index, replay_index); @@ -5474,9 +5478,13 @@ VkResult VulkanReplayConsumerBase::OverrideAcquireNextImage2KHR( // If expected result is anything else, use the passed in timeout value. VkAcquireNextImageInfoKHR modified_acquire_info = *replay_acquire_info; if (original_result == VK_SUCCESS) + { modified_acquire_info.timeout = std::numeric_limits::max(); + } else if (original_result == VK_TIMEOUT) + { modified_acquire_info.timeout = 0; + } result = swapchain_->AcquireNextImage2KHR( func, device_info, swapchain_info, &modified_acquire_info, captured_index, replay_index); @@ -6703,6 +6711,90 @@ VkResult VulkanReplayConsumerBase::OverrideGetPhysicalDeviceToolProperties( } } +VkResult +VulkanReplayConsumerBase::OverrideWaitSemaphores(PFN_vkWaitSemaphores func, + VkResult original_result, + const DeviceInfo* device_info, + const StructPointerDecoder* pInfo, + uint64_t timeout) +{ + assert((device_info != nullptr) && (pInfo != nullptr) && !pInfo->IsNull() && (pInfo->GetPointer() != nullptr)); + VkDevice device = device_info->handle; + const VkSemaphoreWaitInfo* wait_info = pInfo->GetPointer(); + VkResult result; + + // If expected result is VK_SUCCESS, ensure that vkWaitSemaphores waits until semaphores + // are available by using a timeout of UINT64_MAX. + // If expected result is VK_TIMEOUT, try to get a timeout by using a timeout of 0. + // If expected result is anything else, use the passed in timeout value. + if (original_result == VK_SUCCESS) + { + timeout = std::numeric_limits::max(); + } + else if (original_result == VK_TIMEOUT) + { + timeout = 0; + } + result = func(device, wait_info, timeout); + return result; +} + +VkResult VulkanReplayConsumerBase::OverrideAcquireProfilingLockKHR( + PFN_vkAcquireProfilingLockKHR func, + VkResult original_result, + const DeviceInfo* device_info, + const StructPointerDecoder* pInfo) +{ + assert((device_info != nullptr) && (pInfo != nullptr) && !pInfo->IsNull() && (pInfo->GetPointer() != nullptr)); + VkDevice device = device_info->handle; + const VkAcquireProfilingLockInfoKHR* acquire_info = pInfo->GetPointer(); + VkResult result; + + // If expected result is VK_SUCCESS, ensure that vkAcquireProfilingLockKHR waits for locks + // using a timeout of UINT64_MAX. + // If expected result is VK_TIMEOUT, try to get a timeout by using a timeout of 0. + // If expected result is anything else, use the passed in timeout value. + VkAcquireProfilingLockInfoKHR modified_acquire_info = *acquire_info; + if (original_result == VK_SUCCESS) + { + modified_acquire_info.timeout = std::numeric_limits::max(); + } + else if (original_result == VK_TIMEOUT) + { + modified_acquire_info.timeout = 0; + } + result = func(device, &modified_acquire_info); + return result; +} + +VkResult VulkanReplayConsumerBase::OverrideWaitForPresentKHR(PFN_vkWaitForPresentKHR func, + VkResult original_result, + const DeviceInfo* device_info, + SwapchainKHRInfo* swapchain_info, + uint64_t presentid, + uint64_t timeout) +{ + assert((device_info != nullptr) && (swapchain_info != nullptr)); + VkDevice device = device_info->handle; + VkSwapchainKHR swapchain = swapchain_info->handle; + VkResult result; + + // If expected result is VK_SUCCESS, ensure that vkWaitForPresent waits for present by + // using a timeout of UINT64_MAX. + // If expected result is VK_TIMEOUT, try to get a timeout by using a timeout of 0. + // If expected result is anything else, use the passed in timeout value. + if (original_result == VK_SUCCESS) + { + timeout = std::numeric_limits::max(); + } + else if (original_result == VK_TIMEOUT) + { + timeout = 0; + } + result = func(device, swapchain, presentid, timeout); + return result; +} + void VulkanReplayConsumerBase::MapDescriptorUpdateTemplateHandles( const DescriptorUpdateTemplateInfo* update_template_info, DescriptorUpdateTemplateDecoder* decoder) { diff --git a/framework/decode/vulkan_replay_consumer_base.h b/framework/decode/vulkan_replay_consumer_base.h index 2917b53da8..fc6fc5e539 100644 --- a/framework/decode/vulkan_replay_consumer_base.h +++ b/framework/decode/vulkan_replay_consumer_base.h @@ -945,6 +945,23 @@ class VulkanReplayConsumerBase : public VulkanConsumer void OverrideCmdDebugMarkerInsertEXT(PFN_vkCmdDebugMarkerInsertEXT func, CommandBufferInfo* command_buffer_info, StructPointerDecoder* marker_info_decoder); + VkResult OverrideWaitSemaphores(PFN_vkWaitSemaphores func, + VkResult original_result, + const DeviceInfo* device_info, + const StructPointerDecoder* pInfo, + uint64_t timeout); + + VkResult OverrideAcquireProfilingLockKHR(PFN_vkAcquireProfilingLockKHR func, + VkResult original_result, + const DeviceInfo* device_info, + const StructPointerDecoder* pInfo); + + VkResult OverrideWaitForPresentKHR(PFN_vkWaitForPresentKHR func, + VkResult original_result, + const DeviceInfo* device_info, + SwapchainKHRInfo* swapchain_info, + uint64_t presentid, + uint64_t timeout); void OverrideCmdBeginRenderPass(PFN_vkCmdBeginRenderPass func, CommandBufferInfo* command_buffer_info, diff --git a/framework/generated/generated_vulkan_replay_consumer.cpp b/framework/generated/generated_vulkan_replay_consumer.cpp index 2290739c8e..3ed2b2452d 100644 --- a/framework/generated/generated_vulkan_replay_consumer.cpp +++ b/framework/generated/generated_vulkan_replay_consumer.cpp @@ -2570,11 +2570,11 @@ void VulkanReplayConsumer::Process_vkWaitSemaphores( StructPointerDecoder* pWaitInfo, uint64_t timeout) { - VkDevice in_device = MapHandle(device, &VulkanObjectInfoTable::GetDeviceInfo); - const VkSemaphoreWaitInfo* in_pWaitInfo = pWaitInfo->GetPointer(); + auto in_device = GetObjectInfoTable().GetDeviceInfo(device); + MapStructHandles(pWaitInfo->GetMetaStructPointer(), GetObjectInfoTable()); - VkResult replay_result = GetDeviceTable(in_device)->WaitSemaphores(in_device, in_pWaitInfo, timeout); + VkResult replay_result = OverrideWaitSemaphores(GetDeviceTable(in_device->handle)->WaitSemaphores, returnValue, in_device, pWaitInfo, timeout); CheckResult("vkWaitSemaphores", returnValue, replay_result); } @@ -4436,10 +4436,9 @@ void VulkanReplayConsumer::Process_vkAcquireProfilingLockKHR( format::HandleId device, StructPointerDecoder* pInfo) { - VkDevice in_device = MapHandle(device, &VulkanObjectInfoTable::GetDeviceInfo); - const VkAcquireProfilingLockInfoKHR* in_pInfo = pInfo->GetPointer(); + auto in_device = GetObjectInfoTable().GetDeviceInfo(device); - VkResult replay_result = GetDeviceTable(in_device)->AcquireProfilingLockKHR(in_device, in_pInfo); + VkResult replay_result = OverrideAcquireProfilingLockKHR(GetDeviceTable(in_device->handle)->AcquireProfilingLockKHR, returnValue, in_device, pInfo); CheckResult("vkAcquireProfilingLockKHR", returnValue, replay_result); } @@ -4811,11 +4810,10 @@ void VulkanReplayConsumer::Process_vkWaitForPresentKHR( uint64_t presentId, uint64_t timeout) { - VkDevice in_device = MapHandle(device, &VulkanObjectInfoTable::GetDeviceInfo); - VkSwapchainKHR in_swapchain = MapHandle(swapchain, &VulkanObjectInfoTable::GetSwapchainKHRInfo); - if (GetObjectInfoTable().GetSurfaceKHRInfo(GetObjectInfoTable().GetSwapchainKHRInfo(swapchain)->surface_id) == nullptr || GetObjectInfoTable().GetSurfaceKHRInfo(GetObjectInfoTable().GetSwapchainKHRInfo(swapchain)->surface_id)->surface_creation_skipped) { return; } + auto in_device = GetObjectInfoTable().GetDeviceInfo(device); + auto in_swapchain = GetObjectInfoTable().GetSwapchainKHRInfo(swapchain); - VkResult replay_result = GetDeviceTable(in_device)->WaitForPresentKHR(in_device, in_swapchain, presentId, timeout); + VkResult replay_result = OverrideWaitForPresentKHR(GetDeviceTable(in_device->handle)->WaitForPresentKHR, returnValue, in_device, in_swapchain, presentId, timeout); CheckResult("vkWaitForPresentKHR", returnValue, replay_result); } diff --git a/framework/generated/vulkan_generators/replay_overrides.json b/framework/generated/vulkan_generators/replay_overrides.json index 52b298a2f0..dc62dc1ed4 100644 --- a/framework/generated/vulkan_generators/replay_overrides.json +++ b/framework/generated/vulkan_generators/replay_overrides.json @@ -95,6 +95,9 @@ "vkCmdDebugMarkerInsertEXT": "OverrideCmdDebugMarkerInsertEXT", "vkCmdBeginRenderPass": "OverrideCmdBeginRenderPass", "vkCreateImageView": "OverrideCreateImageView", - "vkCreateFramebuffer": "OverrideCreateFramebuffer" + "vkCreateFramebuffer": "OverrideCreateFramebuffer", + "vkAcquireProfilingLockKHR": "OverrideAcquireProfilingLockKHR", + "vkWaitForPresentKHR": "OverrideWaitForPresentKHR", + "vkWaitSemaphores": "OverrideWaitSemaphores" } }