Repository navigation
P3: Reuse texture upload fences in the Vulkan renderer - #8082
Open
dustinspace217 wants to merge 1 commit into
Open
dustinspace217 wants to merge 1 commit into
dustinspace217 wants to merge 1 commit into
Conversation
Every async texture upload created a fence and destroyed it when the upload completed. On at least one driver both calls are slow (about 0.5 ms each), so each streamed animation frame, such as a message portrait, paid about a millisecond, and mission load paid it once per texture. Keep completed fences and reuse them for later uploads.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What?
The Vulkan renderer now reuses the fences that track texture uploads, instead of creating and destroying one for every upload.
Why?
On my machine (RTX 5080, NVIDIA 615.78.08 open kernel module, Fedora) creating a fence takes about 0.5 ms and destroying one takes about the same. Every texture upload paid both:
I found this while looking at HUD rendering cost after #8060. I have only measured this one GPU and driver; where fences are already cheap, this changes nothing.
How?
VulkanTextureManagerkeeps completed upload fences in a list.submitUploadAsyncresets and takes one, or creates one when the list is empty, andshutdown()destroys them. The list cannot outgrow the existing limit of 64 pending uploads, which is now a class constant with an assertion.Testing?
Fedora, MediaVPs 5.0.3 plus the GOTY Mission Pack 1.0.3, 1920x1080, master from November 18 against this branch.
-vulkan -gr_debug: load, 100 seconds of SM1-01 with a portrait, the intro cutscene and a normal quit gave no validation message about fences and none left undestroyed. Without the reset the same run reportsVUID-vkQueueSubmit-fence-00063; without the shutdown cleanup,VUID-vkDestroyDevice-device-05137.Anything Else?
The two readback paths in
VulkanRenderer.cppalso create a fence per use. They are rare and already wait on the GPU, so I left them alone.I used Claude Code to help write and test this.