vk: cache sampler_for's samplers until a sampler registration changes #901
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!901
Loading…
Reference in a new issue
No description provided.
Delete branch "sampler-cache"
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?
What
sampler_for(vk_draw.cpp) runs for every texture slot of every descriptor build. Each call tookreg_muinsampler_of, copied the sampler registration, hashed it word by word and looked the hash up in a thread map: ~48,000 times a frame at ~3,000 draws.It now keeps a thread table indexed by
[compare][id](ids are 12 bits), stamped with a new sampler registration generation (vk_bank.cpp).register_sampler_copybumps that generation only when the registration's contents change, so rewrites of the same sampler don't empty the cache. The generation is read before the lookup, so a registration that lands during a miss makes the next call miss again. Samplers are never destroyed (as the existing per-thread map already assumes), so a cachedVkSamplerstays valid.RX_VK_SAMPLER_CACHE=0turns it off. 24 lines in two files; no shader stamp change (neither file is translator input).Tested
main(b234b43) with the release builder's llvm-mingw toolchain (nx2/build.py --standalone,RX_VK_ONLY=1).RX_VK_PROF_FINE"textures" section 1.76 -> 1.17 ms a frame. No visual issues, no device errors, an area load recovered to 60 quickly.Context and the full profile: #384.
🤖 Generated with Claude Code