Skip to content

Commit

Permalink
Merge branch 'davidlunarg-davidp_timeout2' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlunarg committed Aug 30, 2023
2 parents 8c5e98e + 31b6c7c commit 215926d
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 11 deletions.
92 changes: 92 additions & 0 deletions framework/decode/vulkan_replay_consumer_base.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t>::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);

Expand Down Expand Up @@ -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<uint64_t>::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);

Expand Down Expand Up @@ -6703,6 +6711,90 @@ VkResult VulkanReplayConsumerBase::OverrideGetPhysicalDeviceToolProperties(
}
}

VkResult
VulkanReplayConsumerBase::OverrideWaitSemaphores(PFN_vkWaitSemaphores func,
VkResult original_result,
const DeviceInfo* device_info,
const StructPointerDecoder<Decoded_VkSemaphoreWaitInfo>* 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<uint64_t>::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<Decoded_VkAcquireProfilingLockInfoKHR>* 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<uint64_t>::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<uint64_t>::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)
{
Expand Down
17 changes: 17 additions & 0 deletions framework/decode/vulkan_replay_consumer_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,23 @@ class VulkanReplayConsumerBase : public VulkanConsumer
void OverrideCmdDebugMarkerInsertEXT(PFN_vkCmdDebugMarkerInsertEXT func,
CommandBufferInfo* command_buffer_info,
StructPointerDecoder<Decoded_VkDebugMarkerMarkerInfoEXT>* marker_info_decoder);
VkResult OverrideWaitSemaphores(PFN_vkWaitSemaphores func,
VkResult original_result,
const DeviceInfo* device_info,
const StructPointerDecoder<Decoded_VkSemaphoreWaitInfo>* pInfo,
uint64_t timeout);

VkResult OverrideAcquireProfilingLockKHR(PFN_vkAcquireProfilingLockKHR func,
VkResult original_result,
const DeviceInfo* device_info,
const StructPointerDecoder<Decoded_VkAcquireProfilingLockInfoKHR>* 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,
Expand Down
18 changes: 8 additions & 10 deletions framework/generated/generated_vulkan_replay_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2570,11 +2570,11 @@ void VulkanReplayConsumer::Process_vkWaitSemaphores(
StructPointerDecoder<Decoded_VkSemaphoreWaitInfo>* pWaitInfo,
uint64_t timeout)
{
VkDevice in_device = MapHandle<DeviceInfo>(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);
}

Expand Down Expand Up @@ -4436,10 +4436,9 @@ void VulkanReplayConsumer::Process_vkAcquireProfilingLockKHR(
format::HandleId device,
StructPointerDecoder<Decoded_VkAcquireProfilingLockInfoKHR>* pInfo)
{
VkDevice in_device = MapHandle<DeviceInfo>(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);
}

Expand Down Expand Up @@ -4811,11 +4810,10 @@ void VulkanReplayConsumer::Process_vkWaitForPresentKHR(
uint64_t presentId,
uint64_t timeout)
{
VkDevice in_device = MapHandle<DeviceInfo>(device, &VulkanObjectInfoTable::GetDeviceInfo);
VkSwapchainKHR in_swapchain = MapHandle<SwapchainKHRInfo>(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);
}

Expand Down
5 changes: 4 additions & 1 deletion framework/generated/vulkan_generators/replay_overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
"vkCmdDebugMarkerInsertEXT": "OverrideCmdDebugMarkerInsertEXT",
"vkCmdBeginRenderPass": "OverrideCmdBeginRenderPass",
"vkCreateImageView": "OverrideCreateImageView",
"vkCreateFramebuffer": "OverrideCreateFramebuffer"
"vkCreateFramebuffer": "OverrideCreateFramebuffer",
"vkAcquireProfilingLockKHR": "OverrideAcquireProfilingLockKHR",
"vkWaitForPresentKHR": "OverrideWaitForPresentKHR",
"vkWaitSemaphores": "OverrideWaitSemaphores"
}
}

0 comments on commit 215926d

Please sign in to comment.