GPU/Shaders: a slot picked by index is read as a constant buffer only if it holds one #1216
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1216
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1216"
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?
@GamingRipperDoc on GitHub · 2026-11-26 00:19 UTC · original
GamingRipperDoc:fix/constant-slot-marks→main· +90 −5 · 4 files · 1 commits · openA slot a shader picks from the view heap by index is read as a constant buffer only if it holds one. Any other non-buffer slot reads zeros. This stops the AMD page faults of the meshlet culling
_Prevpasses (fc5e66f8f873d3bb,0452fc2d2e2fc4c3) when work is sent ahead (#3).Why
Translated programs that pick buffers from the whole view heap (
ResourceHeap) choose their load by the host's table of strides (SLOT_STRIDES). A slot with a stride is read raw. Any other slot is read as a constant buffer (emit/lower.rs, the scalar load overslot_stride). A slot holding a texture has stride 0, so its descriptor was read as a constant buffer's. On AMD that takes the image descriptor (T#) as a buffer descriptor (V#): the image's base shifted down by 8, an address near zero, and the card page-faults. @IxMxAMAR decoded the fault addresses on #3 this way. Every one reported there lands in the band of the host's heaps.The race they suggested (a stride written before its view) wasn't the cause. With every buffer/non-buffer slot change waiting for what was sent ahead, the fault still came at 156 s (details on #3).
What
victory-shaderemit/shader.rs:SLOT_STRIDE_CONSTANT(u32::MAX), the table entry of a constant buffer slot, andconstant_marks().VICTORY_CONSTANT_MARKS=0goes back to the old reading. The switch is in the shader cache key, like everyVICTORY_*switch the translator reads.emit/lower.rs:slot_strideturns the mark back into stride 0 for the raw path, and keeps whether the slot is marked. The constant-buffer load runs only where the mark is. A slot that is neither a buffer nor a constant buffer gives zeros, as the existing guarded blocks give for lanes that don't run.victory-gpudescriptor/host.rs:note_bufferwrites the mark forView::Constant. Buffer views keep their stride, and everything else writes 0. Test:constant_buffer_slots_are_marked_in_the_stride_table.Not covered: which slot those passes pick that holds a texture, and why only when work is sent ahead. I haven't checked whether zeros are what should be drawn there either; nothing in the logs looked wrong, but I didn't compare the picture.
Tested
Windows 10 22H2 (19045), AMD RX 9070 XT (Adrenalin 32.0.32015.7029), Rust 1.98.1.
main32b31f7+ this commit):cargo test -p victory-gpu --lib --locked -- --test-threads=1 --skip depth_bounds: 185 passed, 1 failed. The new test passed. The failure,indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields, is the WARP budget test that #1110 and #1098 fix.depth_bounds_pipeline_loads_and_filters_drawsfails onmaintoo, because no Agility runtime is staged on Windows 10. With parallel threads, the test binary exits with an access violation onmaintoo, without this commit.cargo test -p victory-shader --lib --locked: 193 passed, 23 failed. All 23 find no SM 6.6 device (Windows 10 without the Agility runtime for tests).main32b31f7+ this commit: for these runs, merged locally with #420 (without it nothing draws on Windows 10). Each run usedVICTORY_SHADER_OPT=59, because with pass 4 the driver's compiler crashes first (amdxc64.dll+0x85fd0f, #422). Diag build, the default relay (stage 2), nothing skipped, their own cache and data folders, same machine:VICTORY_CONSTANT_MARKS_Prevprograms bound from frame 1659; about 33 submissions sent ahead a frame0(asmain)indirect kind 2offc5e66f8f873d3bb, page fault at0x400002513000c96b4f2+ #420 + #51 + #58 + #203 + the pass-4 patch from #120): two runs with the marks, 463 s and 600 s, with no device loss. The 463 s run ended at the title's own pool stop of #378. Before them, 15 of 15 runs that sent work ahead and ran both_Prevprograms lost the device, within 88–291 s.No game data used.
AI-assisted (Claude Code); I ran the checks above on my machine.
🤖 Generated with Claude Code
@GamingRipperDoc on GitHub · 2026-11-26 01:35 UTC · original
Once CI runs here, its Clippy steps will fail on errors already on
main(03f0002), not on this change. #1242 (#1242) fixes those. The test step will still fail onmain's asset-policy check (the run logs underdiagnostics/), as #1242 notes.No game data in this comment.
AI-assisted (Claude Code)
@GamingRipperDoc on GitHub · 2026-11-26 07:06 UTC · original
My comment above is out of date:
97f8dbcfixed the Clippy errors onmainand gave the run logs underdiagnostics/their own asset-policy rule, so CI onmainis green again (latest run I checked:46bf535). I closed #1242 as no longer needed. This PR still merges cleanly on currentmain.No game data in this comment.
AI-assisted (Claude Code).
4f72b6c8f1to1e0f9e5b28View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.