Repository navigation
vk: keep finalized textures the GPU drew once (ground streaks after long play, #107, #386) - #593
Merged
NotRexed merged 1 commit intoNov 8, 2026
Conversation
…d streaks after long play, issues 107 and 386) OoT's terrain draws each chunk's 260 x 260 RG8 normal map once, finalizes the texture when the chunk goes out of range, and when the chunk comes back makes a texture over the same storage and samples it without drawing it again. On the console the texels are still in that memory. Here they were only in the Vulkan image: 60 frames after the finalize the eviction destroyed it (no write-back for finalized ones), and the texture made again over storage the GPU rendered was not uploaded and sampled empty. The ground went to streaks in square patches (one projection stretched along X or Z) after tens of minutes, and stayed so until a restart. Traced with RX_VK_WATCH_DIM=260x260 and RX_VK_VRAM_MB=1500 (to evict sooner), walking away from the save spot in Hyrule Field and back: e.g. NotRexed#350 at 0x1168973000 drawn at frame 1437, finalized 2259, evicted 2320, made again at 2891 and "NOT uploaded (over storage the GPU rendered)". 6 such tiles in that run, 0 with this change; the same tiles are now sampled again ~1000 frames after they were drawn, with their texels. Kept: textures the GPU drew in one frame, 4 MB or less, finalized, whose storage is still the range the GPU drew them in (gpu_owned) and that no other image was drawn over. Up to RX_VK_KEEP_FINALIZED_MB (512 by default, within the texture budget; 0: evicted as before), the least recently used beyond that going as before. Not written back into guest memory instead: the game may have put other things there since, and a write-back over scene data once crashed it. Tested on an RX 9070 XT (Windows, driver 26.10.1) on a local branch; the change applies to main as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Tested on AMD: RX 6700 XT (Adrenalin driver 32.0.21045.16010), Windows 11, release v2.0.0 with this PR applied. Without it, after ~13 minutes in Hyrule Field the ground stopped drawing (flat fog-coloured terrain with only grass and rocks on it, plus vertical streaks); the log showed ~64,000 textures retired, with the texture budget squeezed to ~3.2 GB. With it, two 15+ minute sessions riding across Hyrule Field and back: the ground stayed intact. |
Closed
3 tasks done
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.
Summary
After tens of minutes of play, the ground in Hyrule Field turns into streaks in square patches (one projection stretched along X or Z) and stays that way until a restart. This is the symptom in #107 (and the "tiled pattern over Hyrule Field's path" in #386).
Cause
OoT's terrain draws each chunk's 260 x 260 RG8 normal map (NVN 0xd, 9 levels) once. It finalizes the texture when the chunk goes out of range. When the chunk comes back, it makes a texture over the same storage and samples it without drawing it again. On the console the texels are still in that memory.
In Hookshot they only exist in the Vulkan image:
Trace with
RX_VK_WATCH_DIM=260x260andRX_VK_VRAM_MB=1500(to evict sooner), walking away from a spot in Hyrule Field and back:That run had 6 such tiles.
Change (
gpu/vk/vk_texture.cpp, eviction only)A texture is kept instead of evicted when all of these hold:
the GPU drew it in one frame (
first_written == last_written)it is 4 MB or less
the game finalized it
its storage is still the range the GPU drew it in (
gpu_owned)no other image was drawn over it
Cap: up to
RX_VK_KEEP_FINALIZED_MB, 512 by default. This counts within the texture budget, so it does not add VRAM. Beyond the cap, the least recently used go as before.0restores the old behaviour.No write-back to guest memory: the game may have put other things there since, and a write-back over scene data crashed it before (the SceneLowPriority case).
Logs:
finalized textures the GPU drew once, kept for being made againevery 600 frames, by size and formatkept finalized textures over N MBwhen the cap evicts one... finalized by the game, sampled again at frame Nonce per texture sampled more than 60 frames after it was drawnRefactor: the existing "drawn over" check became a lambda so it can be shared. Its behaviour is unchanged.
Testing
mainas is, but I could not buildmainhere.RX_VK_VRAM_MB=1500. "NOT uploaded" went from 6 to 0. The same tile addresses (e.g. 0x1168973000, 0x11689a8000, 0x11699d5000) are now sampled again about 1000 frames after they were drawn, with their texels.🤖 Generated with Claude Code