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

Closed
fuzeofficlal wants to merge 1 commit from upstream-pr/2046 into main
fuzeofficlal commented 2026-11-25 04:06:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T04:06:16Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6596971147 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2046). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T04:06:16Z. --- ### 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.
catminou4 commented 2026-11-25 05:05:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:26:02Z.

Review: APPROVED


Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

145 passed / 0 failed / 2 ignored. Buffer descriptor stride bits, merged loads and 64-bit… (+1 test) — structured-buffer descriptor decoding completeness.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051847763 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2046#pullrequestreview-6051847763). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T04:26:02Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 145 passed / 0 failed / 2 ignored. Buffer descriptor stride bits, merged loads and 64-bit… (+1 test) — structured-buffer descriptor decoding completeness.
jeremygold02 commented 2026-11-25 05:06:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:09:19Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152579422 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7152579422). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-25T04:09:19Z. --- **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.
fuzeofficlal commented 2026-11-25 05:06:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T05:02:15Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7153390665 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7153390665). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T05:02:15Z. --- 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`.
Marvisak commented 2026-11-25 10:07:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:18:38Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158158154 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7158158154). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T09:18:38Z. --- <!-- 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)_
sinan-cmyk commented 2026-11-25 10:07:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:33:36Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158493863 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7158493863). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T09:33:36Z. --- ### 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).
upstream-sync changed title from [PR #2046] Shaders: buffer descriptor stride bits, merged loads and 64-bit selects to [PR #2046] Shaders: rebuild all descriptor slices of merged s_load_dwordx8/x16 loads 2026-11-25 11:03:36 +00:00
fuzeofficlal commented 2026-11-25 11:05:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T10:08:57Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7159291442 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7159291442). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T10:08:57Z. --- 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.
upstream-sync closed this pull request 2026-11-25 18:01:45 +00:00
fuzeofficlal commented 2026-11-25 18:02:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T17:20:19Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169358548 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2046#issuecomment-7169358548). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T17:20:19Z. --- 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

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2044
No description provided.