Shaders: SP3 text names a discard's address and position target four #2798

Open
Moon0755 wants to merge 1 commit from upstream-pr/2800 into main
Moon0755 commented 2026-11-25 20:50:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Moon0755 on 2026-11-25T20:50:53Z.


Found by running LLVM's GFX10 MC test vectors (64,006 runs of 38,981 encodings from llvm/test/MC/AMDGPU) through gfx10::decode and Instruction::text, and sorting out the spelling differences. Two forms lost information in the text.

Problem

  • s_dcache_discard and s_dcache_discard_x2 have no data operand but do have an address (LLVM: s_dcache_discard s[2:3], 0x64). The SMEM arm of the text wrote the base and offset only beside data, so these two printed bare, like s_dcache_inv, which really has none.
  • Export target 16 is pos4 on GFX10 (LLVM ET_POS4); the text had pos0..pos3 and printed <target 16>.

Both are in the text only: Fields already holds the operands.

Fix

The SMEM arm computes the offset before the data, and prints base, offset for the two discards. The export arm names targets 12 to 16.

Test

gfx10::sp3::tests::discards_name_their_address_and_position_four_its_target: three encodings from LLVM's gfx10_asm_smem.s (immediate offset, SGPR offset, SGPR plus immediate) and one from exp-gfx10.s. The project spells the immediate 0x000064 where LLVM has 0x64.

Verification

GitHub Actions on windows-latest, on the fork, with the jobs narrowed to victory-shader and xtask:

  • with the change (run 45698042818): clippy in both profiles passed, 271 passed; 0 failed; 3 ignored;
  • the test without the change (run 45698042759): only the new test fails, with s_dcache_discard bare and exp <target 16>.

The vector run itself is a throwaway test on a branch of the fork (run 45695432351); it is not part of this change. No decoded length differed from LLVM's and nothing panicked in the 64,006 runs.

Notes

  • Text only: nothing the lowering reads changes.
  • Independent of #2761, #2765 and #2771, which touch fields.rs; the test is in another place of sp3.rs and the four merge together without conflict.

— Fable

<!-- greyfinch-sync:Marvisak/VIctory:issue:6613500643 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2800). Originally posted by [Moon0755](https://github.com/Moon0755) on 2026-11-25T20:50:53Z. --- Found by running LLVM's GFX10 MC test vectors (64,006 runs of 38,981 encodings from `llvm/test/MC/AMDGPU`) through `gfx10::decode` and `Instruction::text`, and sorting out the spelling differences. Two forms lost information in the text. ### Problem - `s_dcache_discard` and `s_dcache_discard_x2` have no data operand but do have an address (LLVM: `s_dcache_discard s[2:3], 0x64`). The SMEM arm of the text wrote the base and offset only beside data, so these two printed bare, like `s_dcache_inv`, which really has none. - Export target 16 is `pos4` on GFX10 (LLVM `ET_POS4`); the text had `pos0`..`pos3` and printed `<target 16>`. Both are in the text only: `Fields` already holds the operands. ### Fix The SMEM arm computes the offset before the data, and prints `base, offset` for the two discards. The export arm names targets 12 to 16. ### Test `gfx10::sp3::tests::discards_name_their_address_and_position_four_its_target`: three encodings from LLVM's `gfx10_asm_smem.s` (immediate offset, SGPR offset, SGPR plus immediate) and one from `exp-gfx10.s`. The project spells the immediate `0x000064` where LLVM has `0x64`. ### Verification GitHub Actions on `windows-latest`, on the fork, with the jobs narrowed to `victory-shader` and `xtask`: - with the change ([run 45698042818](https://github.com/Moon0755/VIctory/actions/runs/45698042818)): clippy in both profiles passed, `271 passed; 0 failed; 3 ignored`; - the test without the change ([run 45698042759](https://github.com/Moon0755/VIctory/actions/runs/45698042759)): only the new test fails, with `s_dcache_discard` bare and `exp <target 16>`. The vector run itself is a throwaway test on a branch of the fork ([run 45695432351](https://github.com/Moon0755/VIctory/actions/runs/45695432351)); it is not part of this change. No decoded length differed from LLVM's and nothing panicked in the 64,006 runs. ### Notes - Text only: nothing the lowering reads changes. - Independent of #2761, #2765 and #2771, which touch `fields.rs`; the test is in another place of `sp3.rs` and the four merge together without conflict. — Fable
kotekompotek commented 2026-11-25 22:04:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:13:39Z.

Review: COMMENTED


Correct: s_dcache_discard has no data operand, so hoisting the off computation out of the if let Some(data) block lets the no-data arm emit base, off — matching LLVM's spelling (s_dcache_discard s[2:3], 0x000064, register and immediate offsets). target 16 => pos4 matches the exp encoding. Encodings cited from LLVM's MC tests. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6065066191 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2800#pullrequestreview-6065066191). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T21:13:39Z. **Review:** COMMENTED --- Correct: `s_dcache_discard` has no data operand, so hoisting the `off` computation out of the `if let Some(data)` block lets the no-data arm emit `base, off` — matching LLVM's spelling (`s_dcache_discard s[2:3], 0x000064`, register and immediate offsets). `target 16 => pos4` matches the exp encoding. Encodings cited from LLVM's MC tests. LGTM.
fuzeofficlal commented 2026-11-25 22:04:26 +00:00 (Migrated from github.com)

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


Reviewed and verified 604b0291 on Windows 11 against main (13f91ca).

  • Formatting SMEM off before if let Some(data) properly prints {base}, {off} for dataless s_dcache_discard / s_dcache_discard_x2 (leaving s_dcache_inv unchanged), and extending EXP position targets 12..=15 -> 12..=16 covers pos4 with zero IR/lowering changes.
  • cargo test --locked -p victory-shader --lib -- gfx10::: 17/17 passed (including discards_name_their_address_and_position_four_its_target).
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --features host): 0 warnings; cargo xtask policy: 184 files ok; clean git merge-tree vs 13f91ca.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7174946622 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2800#issuecomment-7174946622). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T21:20:32Z. --- Reviewed and verified `604b0291` on Windows 11 against `main` (`13f91ca`). - Formatting `SMEM` `off` before `if let Some(data)` properly prints `{base}, {off}` for dataless `s_dcache_discard` / `s_dcache_discard_x2` (leaving `s_dcache_inv` unchanged), and extending `EXP` position targets `12..=15` -> `12..=16` covers `pos4` with zero IR/lowering changes. - `cargo test --locked -p victory-shader --lib -- gfx10::`: **17/17 passed** (including `discards_name_their_address_and_position_four_its_target`). - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default & `--features host`): **0 warnings**; `cargo xtask policy`: **184 files ok**; clean `git merge-tree` vs `13f91ca`.
oni-swr commented 2026-11-25 22:04:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T21:27:33Z.


Independent WARP/CPU verification of head 604b0291eadd296f01c2d8ddee475e8cb020dfc6, merged onto origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca (clean merge).

Environment: Windows 11 Pro 26200, WARP only (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), Windows SDK 10.0.26100.0 x64 dxil.dll 1.8.2502.11 (VICTORY_DXIL).

  • cargo test -j 4 -p victory-shader: 268 passed, 3 failed, 3 ignored. The baseline on origin/main was 267/3/3, so there is 1 new passing test.
    • The 3 failures are the same pre-existing WARP failures as on the baseline: two synthetic_tests with no pipeline for a wave of 32, plus gathers_at_a_level_match_the_hardware.
  • Negative controls (each one makes discards_name_their_address_and_position_four_its_target fail):
    • Restoring 12..=15 for the export target.
    • Disabling the new s_dcache_discard arm. The output then shows the bare s_dcache_discard, s_dcache_discard, s_dcache_discard_x2.
  • cargo clippy -p victory-shader --all-targets -- -D warnings was clean, with and without --all-features.
  • cargo fmt --all --check: 891 hunks, the same as the baseline (no new hunks).

Diff review: no findings. The change is text only. Moving the off computation ahead of the data branch doesn't change what is printed for forms that have data. s_dcache_inv and friends still print bare, and pos4 matches GFX10's export target 16. The test words are short encodings taken from LLVM's MC test files (interoperability constants), not title data.

Not tested: physical GPU, retail title.

AI use: Claude Code (Claude Opus 5.5)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175103950 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2800#issuecomment-7175103950). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T21:27:33Z. --- Independent WARP/CPU verification of head `604b0291eadd296f01c2d8ddee475e8cb020dfc6`, merged onto `origin/main` `13f91caee25f2fdf2c062be5f7a27f058e51cbca` (clean merge). Environment: Windows 11 Pro 26200, WARP only (`VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`), Windows SDK 10.0.26100.0 x64 `dxil.dll` 1.8.2502.11 (`VICTORY_DXIL`). - `cargo test -j 4 -p victory-shader`: 268 passed, 3 failed, 3 ignored. The baseline on `origin/main` was 267/3/3, so there is 1 new passing test. - The 3 failures are the same pre-existing WARP failures as on the baseline: two `synthetic_tests` with `no pipeline for a wave of 32`, plus `gathers_at_a_level_match_the_hardware`. - Negative controls (each one makes `discards_name_their_address_and_position_four_its_target` fail): - Restoring `12..=15` for the export target. - Disabling the new `s_dcache_discard` arm. The output then shows the bare `s_dcache_discard`, `s_dcache_discard`, `s_dcache_discard_x2`. - `cargo clippy -p victory-shader --all-targets -- -D warnings` was clean, with and without `--all-features`. - `cargo fmt --all --check`: 891 hunks, the same as the baseline (no new hunks). Diff review: no findings. The change is text only. Moving the `off` computation ahead of the data branch doesn't change what is printed for forms that have data. `s_dcache_inv` and friends still print bare, and `pos4` matches GFX10's export target 16. The test words are short encodings taken from LLVM's MC test files (interoperability constants), not title data. Not tested: physical GPU, retail title. AI use: Claude Code (Claude Opus 5.5)
Marvisak commented 2026-11-26 00:03:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:23:51Z.


Automated triage for the maintainers.

A text-only fix in operands (crates/victory-shader/src/gfx10/sp3.rs): the SMEM offset is now formatted before the data branch so s_dcache_discard / s_dcache_discard_x2 print their base, offset instead of printing bare, and export target 16 is named pos4 (the 12..=15 range becomes 12..=16). I checked that forms with data print the same as before, s_dcache_inv still prints bare, and nothing the lowering reads changes; the new test uses short instruction encodings from LLVM's MC tests. CI (check) passes.

This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177503483 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2800#issuecomment-7177503483). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:23:51Z. --- <!-- victory-triage v1 head=604b0291eadd296f01c2d8ddee475e8cb020dfc6 verdict=merge-candidate at=2026-11-25T23:23:46Z --> Automated triage for the maintainers. A text-only fix in `operands` (`crates/victory-shader/src/gfx10/sp3.rs`): the SMEM offset is now formatted before the data branch so `s_dcache_discard` / `s_dcache_discard_x2` print their `base, offset` instead of printing bare, and export target 16 is named `pos4` (the `12..=15` range becomes `12..=16`). I checked that forms with data print the same as before, `s_dcache_inv` still prints bare, and nothing the lowering reads changes; the new test uses short instruction encodings from LLVM's MC tests. CI (`check`) passes. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 03:04:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T02:51:00Z.

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-shader --lib gfx10::sp3::tests: 9 passed, 0 failed (including new discards_name_their_address_and_position_four_its_target).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6067904596 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2800#pullrequestreview-6067904596). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T02:51:00Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - `cargo test -p victory-shader --lib gfx10::sp3::tests`: **9 passed, 0 failed** (including new `discards_name_their_address_and_position_four_its_target`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
futurepro62 commented 2026-11-26 10:05:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T10:02:20Z.


NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head 604b029 (on its base 13f91ca).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 774 passed, 0 failed, 9 ignored.
  • The new tests ran and passed: discards_name_their_address_and_position_four_its_target.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7188824842 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2800#issuecomment-7188824842). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T10:02:20Z. --- NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head `604b029` (on its base `13f91ca`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **774 passed, 0 failed, 9 ignored**. - The new tests ran and passed: `discards_name_their_address_and_position_four_its_target`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
fuzeofficlal commented 2026-11-26 11:03:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T10:46:20Z.

Review: APPROVED


Clean text-only fix in crates/victory-shader/src/gfx10/sp3.rs: hoisting the SMEM off formatting ahead of if let Some(data) prints {base}, {off} for s_dcache_discard / s_dcache_discard_x2 while leaving s_dcache_inv and data-bearing SMEM ops unchanged, and extending 12..=15 to 12..=16 formats export target 16 as pos4. git merge-tree against 63bcca43 is clean.

Verified locally on Windows 11 x64 (604b0291):

  • rustfmt --edition 2024 --check crates/victory-shader/src/gfx10/sp3.rs: clean
  • cargo run --locked -p xtask -- policy: passed (184 files ok)
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default and --all-features): clean
  • cargo test -p victory-shader --lib --locked gfx10::: 17 passed, 0 failed
<!-- greyfinch-sync:Marvisak/VIctory:review:6072737112 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2800#pullrequestreview-6072737112). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T10:46:20Z. **Review:** APPROVED --- Clean text-only fix in `crates/victory-shader/src/gfx10/sp3.rs`: hoisting the SMEM `off` formatting ahead of `if let Some(data)` prints `{base}, {off}` for `s_dcache_discard` / `s_dcache_discard_x2` while leaving `s_dcache_inv` and data-bearing SMEM ops unchanged, and extending `12..=15` to `12..=16` formats export target 16 as `pos4`. `git merge-tree` against `63bcca43` is clean. Verified locally on Windows 11 x64 (`604b0291`): - `rustfmt --edition 2024 --check crates/victory-shader/src/gfx10/sp3.rs`: clean - `cargo run --locked -p xtask -- policy`: passed (`184 files ok`) - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default and `--all-features`): clean - `cargo test -p victory-shader --lib --locked gfx10::`: 17 passed, 0 failed
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2800:upstream-pr/2800'
git switch 'upstream-pr/2800'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2800'
git switch 'upstream-pr/2800'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2800'
git switch 'upstream-pr/2800'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2800'
git switch 'main'
git merge --squash 'upstream-pr/2800'
git switch 'main'
git merge --ff-only 'upstream-pr/2800'
git switch 'main'
git merge 'upstream-pr/2800'
git push origin 'main'
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!2798
No description provided.