vk: Batch query copy requests to reduce number of vulkan commands used #14032
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RPCS3 emits query begin/end pairs corresponding to PS3 occlusion queries. Some PS3 games spam occlussion queries quite a lot, and we can end up generating hundreds of these per frame. We then read the data back using vkCmdCopyQueryResults with VK_RESULT_WAIT_BIT set to copy over the data to a buffer when available.
Unfortunately, this command and flag combo has an unusually high cost on NVIDIA drivers. We can't bring down the number of queries requested, but we can exploit the fact that our query generator uses a stack-based allocator which almost guarantees that every set of query objects will have adjacent descending query indices. This setup allows us to group the indices into larger batches for the copy operation which results in a major speedup.
Fixes the unbearable single-digit hitching in Spiderman: Web of Shadows and brings it up to a 60fps lock in most scenes.