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

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

@⁠Moon0755 on GitHub · 2026-11-25 20:50 UTC · original
Moon0755:fix/sp3-text-llvm → main · +33 −9 · 1 files · 1 commits · open

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

**@⁠Moon0755** on GitHub · 2026-11-25 20:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2800) `Moon0755:fix/sp3-text-llvm` → `main` · +33 −9 · 1 files · 1 commits · open 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
`s_dcache_discard` and `s_dcache_discard_x2` have no data operand but
do have an address; the text printed neither, because the address was
only written beside data. Export target 16 is `pos4` on GFX10 and was
printed as `<target 16>`.

Test: `discards_name_their_address_and_position_four_its_target`,
encodings from LLVM's gfx10_asm_smem.s and exp-gfx10.s.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:14:32 +00:00
Author
Owner

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

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 21:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2800#issuecomment-7174946622) 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`.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 21:27 UTC · original

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)

**@⁠oni-swr** on GitHub · 2026-11-25 21:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2800#issuecomment-7175103950) 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)
Author
Owner

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

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

**@⁠Marvisak** on GitHub · 2026-11-25 23:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2800#issuecomment-7177503483) <!-- 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)_
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 21:13 UTC · original · reviewed

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.

**@⁠kotekompotek** on GitHub · 2026-11-25 21:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2800#pullrequestreview-6065066191) · **reviewed** 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.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 02:51 UTC · original · approved these changes

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

**@⁠Dukestar69** on GitHub · 2026-11-26 02:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/2800#pullrequestreview-6067904596) · **approved these changes** 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).
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 10:02 UTC · original

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.
**@⁠futurepro62** on GitHub · 2026-11-26 10:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2800#issuecomment-7188824842) 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.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 10:46 UTC · original · approved these changes

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
**@⁠fuzeofficlal** on GitHub · 2026-11-26 10:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/2800#pullrequestreview-6072737112) · **approved these changes** 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 can be merged automatically.
This branch is out-of-date with the base branch
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/2800/head:github-bot/gh-2800'
git switch 'github-bot/gh-2800'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2800'
git switch 'github-bot/gh-2800'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2800'
git switch 'github-bot/gh-2800'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2800'
git switch 'main'
git merge --squash 'github-bot/gh-2800'
git switch 'main'
git merge --ff-only 'github-bot/gh-2800'
git switch 'main'
git merge 'github-bot/gh-2800'
git push origin 'main'
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!2800
No description provided.