Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vk: Batch query copy requests to reduce number of vulkan commands used #14032

Merged
merged 2 commits into from Jun 16, 2023

Conversation

kd-11
Copy link
Contributor

@kd-11 kd-11 commented Jun 16, 2023

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.

@kd-11 kd-11 added Driver: NVIDIA Proprietary NVIDIA OpenGL or Vulkan driver Enhancement Render: Vulkan labels Jun 16, 2023
@tfinnegan937
Copy link

I'm going to pull and build this now. I'll report back on whether it works on Spiderman: Web of Shadows

@MSuih
Copy link
Member

MSuih commented Jun 16, 2023

@tfinnegan937 you could also get a precompiled version from our CI. Instructions

@tfinnegan937
Copy link

@MSuih That's nifty. I was unaware that github had that feature. Thanks for letting me know!

I'm probably still going to build the solution, though. I'd like to poke around the emulator anyways.

@tfinnegan937
Copy link

This has completely fixed my performance issues. I now get a fixed 30 FPS.

@kd-11 kd-11 merged commit d5654d6 into RPCS3:master Jun 16, 2023
5 checks passed
@kd-11 kd-11 deleted the nvidia-query-pool-bug branch June 16, 2023 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Driver: NVIDIA Proprietary NVIDIA OpenGL or Vulkan driver Enhancement Render: Vulkan
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants