Textures picked by index: shaders mark the slots they sample (VICTORY_SAMPLED_MARKS=1, off by default) #1074
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1074"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by psttt432454 on 2026-11-28T12:44:58Z.
Why
Slot eviction (
VICTORY_SLOT_EVICT=1, on in the launchers) can't take a texture if a slot that shaders pick by index shows it, because nothing says whether a shader still reads it. On an RTX 5070 Laptop 8 GB, #943 measured that 7,904 of 7,918 idle-looking textures were left out for that reason, and only 5 MB were freed in a whole session. The card stays full,no room, new textures wait, and textures come in late or not at all (houses without textures here; #1030, #984 and #955 look related).This is step 1: measure whether shaders could tell us. Nothing that eviction does changes.
The change
VICTORY_SAMPLED_MARKS=1turns it on. It's off by default; unset, no shader and no draw changes.image_*, not stores) through a slot picked from the view heap sets that slot's bit in a root UAV of ours,u251in space 1 (SLOT_SAMPLED, 2^22 bits, 512 KiB).imageemits into the block it began in. Branching inside it broke block order ("forward reference outside a phi"), which the new test caught.translation_fingerprintand translations are cached apart.SLOT_SAMPLEDis one of our root descriptors, likeSLOT_FAULTS, anddraw.rsbinds it.mapped_card_buffer,GPU_UPLOAD) where there is some, and in the PC's memory otherwise (slow, see below; logged within_card).evictable_slots) also notes, of the textures it may not take, those that no shader marked and no table showed since its idle cutoff. A line every 5 s:Measured
RTX 5070 Laptop 8 GB (DXGI budget ~7.1 GB), Ryzen 9 HX, 32 GB, Windows 11.
victory play --series-s, same save and spot, shader cache warm, about 3 minutes in the world each.63b902feGPU time rises by a few ms, but the frame waits for preparing (25-30 ms), so the frame rate doesn't move. The picture had no new faults, and no new errors were logged. The one shader that does not translate (
6b82bc7d22016cb5, wave64) is the same on main.What the marks say (three runs, lines from the world):
Shaders sample about 2,000-3,500 of those slots in a sweep of 32 frames. So on this card, about 0.5-1.2 GB is held by textures that nothing reads.
Next step (not in this PR)
Let slot eviction take those textures too: a texture picked by index whose slots no shader marked within the idle time. A texture taken this way and then sampled again reads its null slot until it is made again, so step 2 needs that path, and it has to be measured with the picture watched. One caveat for it: a shared slot index across two heaps reads as marked for both, which only keeps a texture longer. A mark lost between the CPU's read and its clear waits for the next read, at most one sweep later.
Tests
emit::waterfall_tests::a_picked_texture_marks_its_slot_with_sampled_marks: with marks on, a sample through a picked slot addsu251, and the shader passes the DXIL validator; with marks off, nothing changes.sampled::tests::a_stamp_counts_from_the_cutoff_on(including the wrap of the low 32 bits), and the ignoredmarks_read_cost(by hand: whether card memory the CPU maps is there, and what reading the buffer costs).cargo test -p victory-shader -p victory-gpu --lib --locked: all pass (victory-gpu 454 passed, 36 ignored; victory-shader 294 passed, 5 ignored).--all-targets: nothing in the changed lines. It stops on main's ownmanual_is_multiple_of(shadow.rs:1708) andlet_and_return(emit/mod.rs).Not tested: other cards (AMD, Intel, cards without a resizable BAR, where the buffer falls back to the PC's memory and costs a lot), Series X, frame generation.
No game files, dumps or extracted data are included.
🤖 Generated with Claude Code