Skip to content

Commit

Permalink
Limit the number of vkGetQueryPoolResults retries
Browse files Browse the repository at this point in the history
When replaying vkGetQueryPoolResults, limit the number of retries
performed when attempting to get the replay result to match the capture
result, to avoid a potential infinite loop.

This happened in a number of D3D11 games running with DXVK.

Signed-off-by: Danylo Piliaiev <[email protected]>
  • Loading branch information
werman authored and bradgrantham-lunarg committed Jun 28, 2021
1 parent a5bebc3 commit 75bc5b3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion framework/decode/vulkan_replay_consumer_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(decode)

const size_t kMaxEventStatusRetries = 16;
const size_t kMaxQueryPoolResultsRetries = 16;

const int32_t kDefaultWindowPositionX = 0;
const int32_t kDefaultWindowPositionY = 0;
Expand Down Expand Up @@ -2972,6 +2973,8 @@ VkResult VulkanReplayConsumerBase::OverrideGetFenceStatus(PFN_vkGetFenceStatus f
VkDevice device = device_info->handle;
VkFence fence = fence_info->handle;

// If you find this loop to be infinite consider adding a limit in the same way
// it is done for GetEventStatus and GetQueryPoolResults.
do
{
result = func(device, fence);
Expand Down Expand Up @@ -3019,11 +3022,14 @@ VkResult VulkanReplayConsumerBase::OverrideGetQueryPoolResults(PFN_vkGetQueryPoo
VkResult result;
VkDevice device = device_info->handle;
VkQueryPool query_pool = query_pool_info->handle;
size_t retries = 0;

do
{
result = func(device, query_pool, firstQuery, queryCount, dataSize, pData->GetOutputPointer(), stride, flags);
} while ((original_result == VK_SUCCESS) && (result == VK_NOT_READY));
} while ((((original_result == VK_SUCCESS) && (result == VK_NOT_READY)) ||
((original_result == VK_NOT_READY) && (result == VK_SUCCESS))) &&
(++retries <= kMaxQueryPoolResultsRetries));

return result;
}
Expand Down

0 comments on commit 75bc5b3

Please sign in to comment.