Shaders: rebuild all descriptor slices of merged s_load_dwordx8/x16 loads #2046

Closed
github-bot wants to merge 1 commit from gh-pr/2046/head into gh-pr/2046/base
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 04:06 UTC · original
fuzeofficlal:fix/shader-buffer-stride-and-merged-loads → main · +654 −139 · 3 files · 1 commits · closed without merging

Summary

  • Rebuild every consumed resource slice within a merged s_load_dwordx8 or s_load_dwordx16 load in Lower::descriptor_data (crates/victory-shader/src/emit/lower.rs):
    • On main, descriptor_data stops at the first use_of match and sets all other loaded dwords to Val::Missing, so any shader reading dimensions or record counts from a second slice of a merged s_load_dwordx8 / s_load_dwordx16 (or across split reloads from the same base) fails lowering.
    • Union direct resource slices (load == site) with same-base reload slices (same_base with delta inside [0, 4 * count)), ranking image and indexed-buffer uses above raw/scalar buffer uses.
    • Isolate per-slice refusals over that slice's 0..span registers so an unread failing slice (such as a CBV) does not poison sibling SRV/UAV slices.
    • Support sampled/sized cube image slices (dim == 3, !uav, kind = 5, GFX10 TYPE = 11 in dwords 1..3) alongside 1D/2D/3D/array views, while keeping main's buffer dword 0..3 and NUM_RECORDS semantics unchanged.

Verification

  • emit::descriptor_tests::merged_loads_and_split_reloads_rebuild_all_buffer_slices (dxil.dll validated, hardware GPU + WARP): covers s_load_dwordx8 multi-slice buffer rebuilding, s_load_dwordx16 split same-base reloads, and unread buffer dword refusal.
  • emit::descriptor_tests::merged_cube_and_2d_slices_sample_and_read_dimensions (dxil.dll validated, hardware GPU + WARP): covers merged s_load_dwordx16 with 4x4 cube (dim == 3) + 6x3 2D (dim == 1) slices and per-slice CBV refusal isolation.
  • cargo clippy -p victory-shader --tests --locked -- -D warnings and cargo xtask policy: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 04:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/2046) `fuzeofficlal:fix/shader-buffer-stride-and-merged-loads` → `main` · +654 −139 · 3 files · 1 commits · closed without merging ### Summary - Rebuild every consumed resource slice within a merged `s_load_dwordx8` or `s_load_dwordx16` load in `Lower::descriptor_data` (`crates/victory-shader/src/emit/lower.rs`): - On `main`, `descriptor_data` stops at the first `use_of` match and sets all other loaded dwords to `Val::Missing`, so any shader reading dimensions or record counts from a second slice of a merged `s_load_dwordx8` / `s_load_dwordx16` (or across split reloads from the same base) fails lowering. - Union direct resource slices (`load == site`) with same-base reload slices (`same_base` with `delta` inside `[0, 4 * count)`), ranking image and indexed-buffer uses above raw/scalar buffer uses. - Isolate per-slice refusals over that slice's `0..span` registers so an unread failing slice (such as a CBV) does not poison sibling SRV/UAV slices. - Support sampled/sized cube image slices (`dim == 3`, `!uav`, `kind = 5`, GFX10 `TYPE = 11` in dwords 1..3) alongside 1D/2D/3D/array views, while keeping `main`'s buffer dword 0..3 and `NUM_RECORDS` semantics unchanged. ### Verification - `emit::descriptor_tests::merged_loads_and_split_reloads_rebuild_all_buffer_slices` (`dxil.dll` validated, hardware GPU + WARP): covers `s_load_dwordx8` multi-slice buffer rebuilding, `s_load_dwordx16` split same-base reloads, and unread buffer dword refusal. - `emit::descriptor_tests::merged_cube_and_2d_slices_sample_and_read_dimensions` (`dxil.dll` validated, hardware GPU + WARP): covers merged `s_load_dwordx16` with 4x4 cube (`dim == 3`) + 6x3 2D (`dim == 1`) slices and per-slice CBV refusal isolation. - `cargo clippy -p victory-shader --tests --locked -- -D warnings` and `cargo xtask policy`: passed.
Rebuild every consumed resource slice within a merged s_load_dwordx8 or s_load_dwordx16 load by unioning direct slices with same-base reload slices whose offsets fall in the loaded range (ranking image and indexed buffer uses above raw/scalar ones), isolate per-slice refusals so an unread failing slice does not poison sibling slices, and reconstruct sampled/sized cube image slices (dim == 3, TYPE = 11) alongside 1D/2D/3D/array views while leaving buffer dword 0..3 and record-count semantics unchanged.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:52:47 +00:00
github-bot closed this pull request 2026-11-26 04:52:47 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 04:09 UTC · original

Triage verdict — Keep, cover split reloads and mixed descriptor slices (8df2ae4)

Evidence

  • @⁠fuzeofficlal’s patch adds merged-load and known-stride handling. #329 addresses a different case: a static structured binding with no resource consumer to match.
  • Same-address recovery runs only when a load has no direct slices and stops at the first matching reload. If reload A supplies the first slice and reload B supplies the second, a scalar read through A can still miss the second slice’s record count. Reload search
  • Reconstruction iterates every consumed slice. A cube slice used only for sampling can hit the metadata dimension refusal even if the scalar read targets the other, 2D slice. Ordinary image lowering accepts cube samples. Reconstruction · Cube sampling

Checks and limits

  • These are source-review findings. The author’s descriptor test results cover the submitted fixtures. I did not run the two cases above.

Next step

  • Add a merged s_load_dwordx8 pair with one distinct resource consumer per reload and a scalar read of the other slice’s record count. Also cover a merged 2D metadata read plus a cube handle used only for sampling. These cases check that recovery combines compatible evidence without imposing metadata restrictions on unrelated slices.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7152579422) **Triage verdict — Keep, cover split reloads and mixed descriptor slices** (`8df2ae4`) **Evidence** - @⁠fuzeofficlal’s patch adds merged-load and known-stride handling. #329 addresses a different case: a static structured binding with no resource consumer to match. - Same-address recovery runs only when a load has no direct slices and stops at the first matching reload. If reload A supplies the first slice and reload B supplies the second, a scalar read through A can still miss the second slice’s record count. [Reload search](https://github.com/Marvisak/VIctory/blob/8df2ae4e544276a20691a308ea2f19f1fc834cc7/crates/victory-shader/src/emit/lower.rs#L4071-L4084) - Reconstruction iterates every consumed slice. A cube slice used only for sampling can hit the metadata dimension refusal even if the scalar read targets the other, 2D slice. Ordinary image lowering accepts cube samples. [Reconstruction](https://github.com/Marvisak/VIctory/blob/8df2ae4e544276a20691a308ea2f19f1fc834cc7/crates/victory-shader/src/emit/lower.rs#L4092-L4113) · [Cube sampling](https://github.com/Marvisak/VIctory/blob/8df2ae4e544276a20691a308ea2f19f1fc834cc7/crates/victory-shader/src/emit/lower.rs#L7743-L7757) **Checks and limits** - These are source-review findings. The author’s descriptor test results cover the submitted fixtures. I did not run the two cases above. **Next step** - Add a merged `s_load_dwordx8` pair with one distinct resource consumer per reload and a scalar read of the other slice’s record count. Also cover a merged 2D metadata read plus a cube handle used only for sampling. These cases check that recovery combines compatible evidence without imposing metadata restrictions on unrelated slices. This verification was AI-assisted.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 05:02 UTC · original

Updated in 51eecad4 — thanks @⁠jeremygold02 for catching both cases:

  • Union across all same-base reloads: descriptor_data now scans every Role::Resource slice whose load matches site or shares same_base(a, b) with an offset inside [b.offset, b.offset + 4 * count), merging slices by relative dword offset and rank rather than stopping at the first reload.
  • Cube slice reconstruction & per-slice isolation: sampled/sized cube slices (dim == 3, !uav) now map to kind = 5 (TextureCube, TYPE = 11 in dwords 1..=3), and per-slice refusals (such as an unread CBV or unsupported image slice inside a merged s_load_dwordx16) mark only that slice's span as Val::Missing so sibling slices still reconstruct.
  • Added end-to-end GPU/WARP dxil.dll-validated tests merged_reload_slices_supply_all_record_counts_and_strides_on_all_gpus and merged_cube_and_2d_slices_sample_and_read_dimensions_on_all_gpus.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 05:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7153390665) Updated in `51eecad4` — thanks @⁠jeremygold02 for catching both cases: - **Union across all same-base reloads**: `descriptor_data` now scans every `Role::Resource` slice whose load matches `site` or shares `same_base(a, b)` with an offset inside `[b.offset, b.offset + 4 * count)`, merging slices by relative dword offset and `rank` rather than stopping at the first reload. - **Cube slice reconstruction & per-slice isolation**: sampled/sized cube slices (`dim == 3`, `!uav`) now map to `kind = 5` (`TextureCube`, `TYPE = 11` in `dwords 1..=3`), and per-slice refusals (such as an unread CBV or unsupported image slice inside a merged `s_load_dwordx16`) mark only that slice's span as `Val::Missing` so sibling slices still reconstruct. - Added end-to-end GPU/WARP `dxil.dll`-validated tests `merged_reload_slices_supply_all_record_counts_and_strides_on_all_gpus` and `merged_cube_and_2d_slices_sample_and_read_dimensions_on_all_gpus`.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 09:18 UTC · original · edited 2026-11-25 11:23 UTC

Automated triage for the maintainers.

Needs work. It is close now.

On your reply: b329b1f does narrow the PR to the merged-load part. Val::Bits/bits_op, the 64-bit select merge, the readfirstlane flag and the buffer stride/NUM_RECORDS changes are all gone from the diff, and crates/victory-shader/src/emit/lower.rs now differs from main only in descriptor_data. I read the rewrite:

  • Every Role::Resource leaf loaded at site, or from a same_base load whose dword offset falls inside the loaded range, gives a slice. Image beats buffer beats SMEM via rank.
  • Each slice is rebuilt with the existing GFX10 layout, and a refusal now marks only that slice's dwords Val::Missing(why).
  • The new cube case writes type 11 into dword 3 and leaves dword 4 missing. That matches the public RDNA image-resource type table (1D 8, 2D 9, 3D 10, cube 11, 1D array 12, 2D array 13), and the other entries are unchanged from main.

What is still missing is the evidence the earlier review asked for: that the title reaches these paths. The only measurement in the thread (sinan-cmyk, on the earlier and larger head) shows no change in translate --validate counts, and a validation count would not show whether the output changed anyway. Please give counts only, no shader names or data:

  • how many title programs have a merged s_load_dwordx8/x16 where a slice other than the first used one is now rebuilt,
  • how many have a sampled cube slice in such a load,
  • whether any program's lowered output changes against main.

If those programs exist, this is a reasonable merge. The two descriptor tests do check rebuilt values against the host view's dimensions on GPU and WARP, not just against what the code emits. CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 09:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7158158154) · edited 2026-11-25 11:23 UTC <!-- victory-triage v1 head=b329b1f9ccd8e1698bb525d490da60403ec33e07 verdict=needs-work at=2026-11-25T11:23:06Z --> Automated triage for the maintainers. **Needs work.** It is close now. On your reply: `b329b1f` does narrow the PR to the merged-load part. `Val::Bits`/`bits_op`, the 64-bit select merge, the readfirstlane flag and the buffer stride/`NUM_RECORDS` changes are all gone from the diff, and `crates/victory-shader/src/emit/lower.rs` now differs from main only in `descriptor_data`. I read the rewrite: - Every `Role::Resource` leaf loaded at `site`, or from a `same_base` load whose dword offset falls inside the loaded range, gives a slice. Image beats buffer beats SMEM via `rank`. - Each slice is rebuilt with the existing GFX10 layout, and a refusal now marks only that slice's dwords `Val::Missing(why)`. - The new cube case writes type 11 into dword 3 and leaves dword 4 missing. That matches the public RDNA image-resource type table (1D 8, 2D 9, 3D 10, cube 11, 1D array 12, 2D array 13), and the other entries are unchanged from main. What is still missing is the evidence the earlier review asked for: that the title reaches these paths. The only measurement in the thread (sinan-cmyk, on the earlier and larger head) shows no change in `translate --validate` counts, and a validation count would not show whether the output changed anyway. Please give counts only, no shader names or data: - how many title programs have a merged `s_load_dwordx8/x16` where a slice other than the first used one is now rebuilt, - how many have a sampled cube slice in such a load, - whether any program's lowered output changes against main. If those programs exist, this is a reasonable merge. The two descriptor tests do check rebuilt values against the host view's dimensions on GPU and WARP, not just against what the code emits. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 09:33 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head 51eecad4 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 09:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7158493863) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 51eecad4 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 10:08 UTC · original

Updated in b329b1f9 per triage feedback:

  • Split out the independent changes and narrowed this PR strictly to Part 1 (Lower::descriptor_data rebuilding all consumed slices of merged s_load_dwordx8 / s_load_dwordx16 loads, including across same-base reloads and sampled/sized dim == 3 cube slices, with per-slice refusal isolation).
  • Completely reverted Val::Bits / bits_op, the v_readfirstlane_b32 wave-ops flag change, the merged 64-bit select changes, and all buffer dword-1 stride / NUM_RECORDS changes (main's buffer record-count behaviour is preserved unchanged).
  • Trimmed descriptor_tests.rs to the two focused GPU + WARP (dxil.dll validated) tests covering merged buffer slices, split reloads, mixed cube + 2D image slices, and per-slice CBV refusal isolation.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 10:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7159291442) Updated in `b329b1f9` per triage feedback: - Split out the independent changes and narrowed this PR strictly to Part 1 (`Lower::descriptor_data` rebuilding all consumed slices of merged `s_load_dwordx8` / `s_load_dwordx16` loads, including across same-base reloads and sampled/sized `dim == 3` cube slices, with per-slice refusal isolation). - Completely reverted `Val::Bits` / `bits_op`, the `v_readfirstlane_b32` wave-ops flag change, the merged 64-bit select changes, and all buffer dword-1 stride / `NUM_RECORDS` changes (`main`'s buffer record-count behaviour is preserved unchanged). - Trimmed `descriptor_tests.rs` to the two focused GPU + WARP (`dxil.dll` validated) tests covering merged buffer slices, split reloads, mixed cube + 2D image slices, and per-slice CBV refusal isolation.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 17:20 UTC · original

Closing this PR: as noted in triage, confirming a measurable hit on real title shader corpora is needed before merging, and I only test with synthetic shaders locally.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 17:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7169358548) Closing this PR: as noted in triage, confirming a measurable hit on real title shader corpora is needed before merging, and I only test with synthetic shaders locally.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2046
No description provided.