Shaders: s_ttracedata_imm is SOPP opcode 0x28, not 0x26 #276

Merged
Dufftwt merged 1 commit from upstream-pr/276 into main 2026-11-24 07:59:21 +00:00
Dufftwt commented 2026-11-24 01:59:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dufftwt on 2026-11-24T01:59:23Z.


What's wrong

The SOPP opcode table in gfx10/opcodes.rs has s_ttracedata_imm at opcode 0x26. RDNA2 encodes it at 0x28:

  • AMD's RDNA2 ISA lists S_TTRACEDATA_IMM as SOPP opcode 40 (0x28).
  • LLVM's GFX10 tables have S_TTRACEDATA_IMM : SOPP_Real_32_gfx10_gfx13<0x028>, and its disassembler tests (gfx10_sopp.txt) decode 0x34,0x12,0xa8,0xbf as s_ttracedata_imm 0x1234.
  • The table is generated from Mesa's aco_opcodes.py, which has 0x26. That's where the wrong number came from.

s_ttracedata_imm is a thread-trace marker, and ir.rs already lists it in DROPPED as having no effect. But the real encoding (0xBFA8xxxx) decodes with no name, so ir::build refuses the whole shader with "unknown opcode":

0xBFA81234 s_ttracedata_imm 0x1234  ->  name None  ->  Unsupported { what: "unknown opcode" }  ->  the shader does not translate

What the fix does

The table entry moves from 0x026 to 0x028. The table stays sorted, and nothing else changes.

How it behaves after the fix

A shader with a thread-trace marker decodes it as s_ttracedata_imm. The IR drops it as intended, and the shader translates. Nothing else encodes 0x26, so nothing that decoded before decodes differently now.

Tests

The new test s_ttracedata_imm_is_sopp_0x28 (in opcodes.rs) decodes 0xBFA81234 and checks two things: the name is s_ttracedata_imm, and ir::build accepts a program containing it.

I ran cargo test --workspace on GitHub's windows-latest with Rust 1.98.1 from rust-toolchain.toml:

  • This PR: everything passes. victory-shader has 70 passed, the other crates have 0 failed.
  • The new test alone on main: it fails at the decode: left: None (no name for 0xBFA81234), right: Some("s_ttracedata_imm").
  • I ran with --test-threads=1. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (#181, #244).

Not tested: a title shader that carries the marker.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6572878501 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/276). Originally posted by [Dufftwt](https://github.com/Dufftwt) on 2026-11-24T01:59:23Z. --- ## What's wrong The SOPP opcode table in `gfx10/opcodes.rs` has `s_ttracedata_imm` at opcode `0x26`. RDNA2 encodes it at **`0x28`**: - AMD's RDNA2 ISA lists `S_TTRACEDATA_IMM` as SOPP opcode 40 (`0x28`). - LLVM's GFX10 tables have `S_TTRACEDATA_IMM : SOPP_Real_32_gfx10_gfx13<0x028>`, and its disassembler tests (`gfx10_sopp.txt`) decode `0x34,0x12,0xa8,0xbf` as `s_ttracedata_imm 0x1234`. - The table is generated from Mesa's `aco_opcodes.py`, which has `0x26`. That's where the wrong number came from. `s_ttracedata_imm` is a thread-trace marker, and `ir.rs` already lists it in `DROPPED` as having no effect. But the real encoding (`0xBFA8xxxx`) decodes with no name, so `ir::build` refuses the whole shader with "unknown opcode": ``` 0xBFA81234 s_ttracedata_imm 0x1234 -> name None -> Unsupported { what: "unknown opcode" } -> the shader does not translate ``` ## What the fix does The table entry moves from `0x026` to `0x028`. The table stays sorted, and nothing else changes. ## How it behaves after the fix A shader with a thread-trace marker decodes it as `s_ttracedata_imm`. The IR drops it as intended, and the shader translates. Nothing else encodes `0x26`, so nothing that decoded before decodes differently now. ## Tests The new test `s_ttracedata_imm_is_sopp_0x28` (in `opcodes.rs`) decodes `0xBFA81234` and checks two things: the name is `s_ttracedata_imm`, and `ir::build` accepts a program containing it. I ran `cargo test --workspace` on GitHub's `windows-latest` with Rust 1.98.1 from `rust-toolchain.toml`: - **This PR:** everything passes. `victory-shader` has 70 passed, the other crates have 0 failed. - **The new test alone on `main`:** it fails at the decode: `left: None` (no name for `0xBFA81234`), `right: Some("s_ttracedata_imm")`. - I ran with `--test-threads=1`. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (#181, #244). **Not tested:** a title shader that carries the marker.
jeremygold02 commented 2026-11-24 06:55:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:11:46Z.


Tested PR #276 at head 79fb722a530056ce1f193b2a4476901de414a8d7 (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at 79fb722a530056ce1f193b2a4476901de414a8d7.

  • cargo test --locked -p victory-shader s_ttracedata_imm_is_sopp_0x28 — passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 69 filtered out; finished in 0.00s ); cases: gfx10::opcodes::tests::s_ttracedata_imm_is_sopp_0x28.

Behavior covered: Checks the GFX10 opcode table decodes s_ttracedata_imm as SOPP opcode 0x28.
Code: crates/victory-shader/src/gfx10/opcodes.rs

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121795148 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/276#issuecomment-7121795148). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T04:11:46Z. --- Tested PR #276 at head `79fb722a530056ce1f193b2a4476901de414a8d7` (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at `79fb722a530056ce1f193b2a4476901de414a8d7`. - `cargo test --locked -p victory-shader s_ttracedata_imm_is_sopp_0x28` — passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 69 filtered out; finished in 0.00s ); cases: gfx10::opcodes::tests::s_ttracedata_imm_is_sopp_0x28. Behavior covered: Checks the GFX10 opcode table decodes s_ttracedata_imm as SOPP opcode 0x28. Code: [crates/victory-shader/src/gfx10/opcodes.rs](https://github.com/Marvisak/VIctory/blob/79fb722a530056ce1f193b2a4476901de414a8d7/crates/victory-shader/src/gfx10/opcodes.rs)
mercuryVM commented 2026-11-24 07:32:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T07:32:33Z.

Review: APPROVED


Tested 79fb722 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed), including s_ttracedata_imm_is_sopp_0x28. victory translate <title exe> --validate --pipelines gives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines.

  • 0x28 matches the RDNA2 ISA and LLVM's GFX10 SOPP tables. After the change the table has nothing at 0x26 and no second entry at 0x28, so it introduces no collision.
  • The test decodes the LLVM disassembler-test word, and also checks that ir::build accepts it, which is where the "unknown opcode" refusal came from.

No issues found. If the table really comes from Mesa's aco_opcodes.py, it may be worth reporting the 0x26 there too.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6035308384 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/276#pullrequestreview-6035308384). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T07:32:33Z. **Review:** APPROVED --- Tested 79fb722 on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (265 passed, 0 failed), including `s_ttracedata_imm_is_sopp_0x28`. `victory translate <title exe> --validate --pipelines` gives the same counts before and after: 12 of 12 programs emitted, 12 validated, 12 pipelines. - 0x28 matches the RDNA2 ISA and LLVM's GFX10 SOPP tables. After the change the table has nothing at 0x26 and no second entry at 0x28, so it introduces no collision. - The test decodes the LLVM disassembler-test word, and also checks that `ir::build` accepts it, which is where the "unknown opcode" refusal came from. No issues found. If the table really comes from Mesa's `aco_opcodes.py`, it may be worth reporting the 0x26 there too. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 08:02:01 +00:00
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!276
No description provided.