Repository navigation
vk: render targets' images in VMA blocks of their own; dead targets swept every 10 presents (follow-up to #1416) - #1436
Merged
Conversation
…or each of OoT's shifting transient targets OoT makes a frame's transient targets in a scratch heap whose offsets shift with what came before them in the frame, so each shifted one is a texture with a new image, and every 60 presents the dead-target sweep (NotRexed#899) let go of 300-700 of them at once, destroyed in the next present: 20-65 ms on the replaying thread, about once a second while the camera moves (RTX 5070, Kokiri Forest: 10,500 images made and destroyed in 4.5 minutes, 17 GB). A render target's image whose texture is gone now waits in a pool by its create info, with its views, and a new texture of that create info takes it. It is still put into GENERAL from UNDEFINED and cleared as a new image is, so nothing it held shows. Uncompressed colour and depth targets only; bounded by RX_VK_TARGET_POOL_MB (default 1024, 0: off, as before), given back while VRAM is near what the driver allows, and an image unused in it for 120 presents is destroyed, at most 16 a present. tests/test_target_image_pool.py keeps the rules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wept every 10 presents; the target pool bound 256 MB Follow-up to NotRexed#1416. OoT's transient targets, made and let go all the time, shared the image pool's 128 MB blocks with the textures that stay: each one gone left a hole beside a texture that kept its block. In Kokiri Forest the pool's 47-54 blocks (6-6.9 GB) held 1.9-3.6 GB of images, VRAM sat at 93-98% of what the driver allows, and an image made then took 30-70 ms (RTX 5070). - Images texture_get makes for a target (not for sampling) come from blocks of their own (RX_VK_TARGET_BLOCKS=0: as before), and only those go to the target pool. - The dead targets are swept every 10 presents (RX_VK_DEAD_EVERY, 60 before): the pool got 300-700 at once and the new targets of the next second missed most of them. The choice is cheap (1930 textures ordered in 0.3 ms). - The target pool's bound comes down to 256 MB. - Every 600 presents the log says what the image blocks hold (vma_log_image_blocks). tests/test_target_image_pool.py checks the new rules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
This landed in the v2.0.12 branch (merged there for testing; it reaches |
Owner
|
Reopened: closing this was a mistake on my side. It was tested in the v2.0.12 branch, and it will be merged into main here, so it shows as merged. Sorry for the noise. |
…l size, target-only key and own blocks kept, with main's retries for a refused compressed image)
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.
Follow-up to #1416. Only the second commit, 7a9151b, is new. The first commit, c34f350, is #1416 as it landed in the v2.0.12 branch, with the same hash, so this applies there as it is. Against
mainthe diff shows both commits until v2.0.12 reaches it.What
#1416 took away the once-a-second burst of destroyed images. A longer play session (18 minutes on an RTX 5070) then showed the next layer, which is VRAM.
Change
gpu/vk/vk_vma.cpp: a second VMA pool,target_images_pool(), with the same memory type and block size, for render targets' images.create_image(..., target)takes its images from there.RX_VK_TARGET_BLOCKS=0puts them in the textures' blocks, as before.gpu/vk/vk_texture.cpp:create()knows whentexture_getasked for a target (!for_sampling). Only those images go to the targets' blocks and to the target pool.RX_VK_DEAD_EVERY(it was 60). The choice is cheap: 1930 textures ordered in 0.3 ms, 251 chosen in 0.2 ms.vma_log_image_blockssays what each image pool's blocks hold, and the largest free range in them.Measured
RX_VK_TARGET_BLOCKS=0 RX_VK_DEAD_EVERY=60 RX_VK_TARGET_POOL_MB=1024, which is vk: render target images reused from a pool, not made and destroyed for each of OoT's shifting transient targets #1416 as it is.Not covered
Tests
tests/test_target_image_pool.py, 9 cases, adds:RX_VK_TARGET_BLOCKS);RX_VK_DEAD_EVERY(10) presents;tests/run_all.pyon every test that readsvk_texture.cpp,vk_texture.horvk_vma.cpp: 9 passed, 2 skipped. The 2 skipped ones need the Vulkan headers, and both pass when run with them:test_vulkan_clear_mip.pyandtest_parallel_init_order.py.🤖 Generated with Claude Code