No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!593
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/keep-finalized-gpu-textures"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
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.