GPU/Shaders: a slot picked by index is read as a constant buffer only if it holds one #1216

Open
github-bot wants to merge 1 commit from github-bot/gh-1216 into main AGit
Owner

@⁠GamingRipperDoc on GitHub · 2026-11-26 00:19 UTC · original
GamingRipperDoc:fix/constant-slot-marks → main · +90 −5 · 4 files · 1 commits · open

A 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 _Prev passes (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 over slot_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-shader emit/shader.rs: SLOT_STRIDE_CONSTANT (u32::MAX), the table entry of a constant buffer slot, and constant_marks(). VICTORY_CONSTANT_MARKS=0 goes back to the old reading. The switch is in the shader cache key, like every VICTORY_* switch the translator reads.
  • emit/lower.rs: slot_stride turns 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-gpu descriptor/host.rs: note_buffer writes the mark for View::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.

  • Unit tests on this branch (main 32b31f7 + 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_draws fails on main too, because no Agility runtime is staged on Windows 10. With parallel threads, the test binary exits with an access violation on main too, 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).
    • Clippy reports nothing in the changed files, and rustfmt finds nothing to change in the changed lines.
  • Game runs on main 32b31f7 + this commit: for these runs, merged locally with #420 (without it nothing draws on Windows 10). Each run used VICTORY_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:
run VICTORY_CONSTANT_MARKS result
26 default (on) no device loss for the full 10 min; both _Prev programs bound from frame 1659; about 33 submissions sent ahead a frame
27 0 (as main) device removed at 279 s, indirect kind 2 of fc5e66f8f873d3bb, page fault at 0x400002513000
  • Earlier runs on my test stack (c96b4f2 + #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 _Prev programs 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 00:19 UTC · [original](https://github.com/fxceless/victory-fork/pull/1216) `GamingRipperDoc:fix/constant-slot-marks` → `main` · +90 −5 · 4 files · 1 commits · open A 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 `_Prev` passes (`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 over `slot_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-shader` `emit/shader.rs`: `SLOT_STRIDE_CONSTANT` (`u32::MAX`), the table entry of a constant buffer slot, and `constant_marks()`. `VICTORY_CONSTANT_MARKS=0` goes back to the old reading. The switch is in the shader cache key, like every `VICTORY_*` switch the translator reads. - `emit/lower.rs`: `slot_stride` turns 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-gpu` `descriptor/host.rs`: `note_buffer` writes the mark for `View::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. - **Unit tests on this branch** (`main` `32b31f7` + 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_draws` fails on `main` too, because no Agility runtime is staged on Windows 10. With parallel threads, the test binary exits with an access violation on `main` too, 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). - Clippy reports nothing in the changed files, and rustfmt finds nothing to change in the changed lines. - **Game runs on `main` `32b31f7` + this commit:** for these runs, merged locally with #420 (without it nothing draws on Windows 10). Each run used `VICTORY_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: | run | `VICTORY_CONSTANT_MARKS` | result | |---|---|---| | 26 | default (on) | **no device loss for the full 10 min**; both `_Prev` programs bound from frame 1659; about 33 submissions sent ahead a frame | | 27 | `0` (as `main`) | device removed at 279 s, `indirect kind 2` of `fc5e66f8f873d3bb`, page fault at `0x400002513000` | - **Earlier runs on my test stack** (`c96b4f2` + #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 `_Prev` programs 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](https://claude.com/claude-code)
Shaders that pick buffers from the view heap by index read a slot raw when
the table of strides gives it a stride, and as a constant buffer otherwise.
A slot that holds a texture then had its descriptor read as a buffer's; on
AMD that is the image's base shifted down by 8, an address near zero, and
the card page-faulted in the meshlet culling _Prev passes when work was sent
ahead (issue #3).

The table now marks constant buffer views (SLOT_STRIDE_CONSTANT); only a
marked slot is read as a constant buffer, and any other non-buffer reads
zeros. VICTORY_CONSTANT_MARKS=0 goes back to the old reading.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:59:42 +00:00
Author
Owner

@⁠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 on main's asset-policy check (the run logs under diagnostics/), as #1242 notes.

No game data in this comment.

AI-assisted (Claude Code)

**@⁠GamingRipperDoc** on GitHub · 2026-11-26 01:35 UTC · [original](https://github.com/fxceless/victory-fork/pull/1216#issuecomment-7179927178) Once CI runs here, its Clippy steps will fail on errors already on `main` (`03f0002`), not on this change. #1242 (https://git.gtahub.st/github/fxceless--victory-fork/pulls/1242) fixes those. The test step will still fail on `main`'s asset-policy check (the run logs under `diagnostics/`), as #1242 notes. No game data in this comment. AI-assisted (Claude Code)
Author
Owner

@⁠GamingRipperDoc on GitHub · 2026-11-26 07:06 UTC · original

My comment above is out of date: 97f8dbc fixed the Clippy errors on main and gave the run logs under diagnostics/ their own asset-policy rule, so CI on main is green again (latest run I checked: 46bf535). I closed #1242 as no longer needed. This PR still merges cleanly on current main.

No game data in this comment.

AI-assisted (Claude Code).

**@⁠GamingRipperDoc** on GitHub · 2026-11-26 07:06 UTC · [original](https://github.com/fxceless/victory-fork/pull/1216#issuecomment-7185102222) My comment above is out of date: `97f8dbc` fixed the Clippy errors on `main` and gave the run logs under `diagnostics/` their own asset-policy rule, so CI on `main` is green again (latest run I checked: `46bf535`). I closed #1242 as no longer needed. This PR still merges cleanly on current `main`. No game data in this comment. AI-assisted (Claude Code).
github-bot force-pushed github-bot/gh-1216 from 4f72b6c8f1 to 1e0f9e5b28 2026-11-26 18:40:01 +00:00 Compare
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1216/head:github-bot/gh-1216'
git switch 'github-bot/gh-1216'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1216'
git switch 'github-bot/gh-1216'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1216'
git switch 'github-bot/gh-1216'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1216'
git switch 'main'
git merge --squash 'github-bot/gh-1216'
git switch 'main'
git merge --ff-only 'github-bot/gh-1216'
git switch 'main'
git merge 'github-bot/gh-1216'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.