From 02e45047040fc114f879fd4778d1f282987b9c7d Mon Sep 17 00:00:00 2001 From: Duff <19514584+Dufftwt@users.noreply.github.com> Date: Tue, 24 Nov 2026 02:45:09 +0100 Subject: [PATCH] Shaders: s_ttracedata_imm is SOPP opcode 0x28, not 0x26 The SOPP table had s_ttracedata_imm at 0x26, as Mesa's opcode list does; RDNA2 encodes it at 0x28 (AMD's RDNA2 ISA, LLVM's GFX10 tables and disassembler tests). A shader with the thread-trace marker decoded it as an unknown opcode and failed to translate, though the IR drops the marker as harmless. --- crates/victory-shader/src/gfx10/opcodes.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/victory-shader/src/gfx10/opcodes.rs b/crates/victory-shader/src/gfx10/opcodes.rs index 18dac4f..d1ba275 100644 --- a/crates/victory-shader/src/gfx10/opcodes.rs +++ b/crates/victory-shader/src/gfx10/opcodes.rs @@ -236,7 +236,7 @@ pub(super) const SOPP: &[(u16, &str)] = &[ (0x023, "s_waitcnt_depctr"), (0x024, "s_round_mode"), (0x025, "s_denorm_mode"), - (0x026, "s_ttracedata_imm"), + (0x028, "s_ttracedata_imm"), ]; pub(super) const SMEM: &[(u16, &str)] = &[ @@ -1313,3 +1313,21 @@ pub(super) const SCRATCH: &[(u16, &str)] = &[ (0x024, "scratch_load_short_d16"), (0x025, "scratch_load_short_d16_hi"), ]; + +#[cfg(test)] +mod tests { + fn bytes(words: &[u32]) -> Vec { + words.iter().flat_map(|w| w.to_le_bytes()).collect() + } + + /// `s_ttracedata_imm 0x1234` as LLVM's GFX10 disassembler tests have it + /// (`gfx10_sopp.txt`: `0x34,0x12,0xa8,0xbf`), SOPP opcode 0x28 as in + /// AMD's RDNA2 ISA. A thread-trace marker, which translation drops. + #[test] + fn s_ttracedata_imm_is_sopp_0x28() { + let code = bytes(&[0xBFA8_1234, 0xBF81_0000]); + let decoded = super::super::decode(&code).unwrap(); + assert_eq!(decoded[0].name(), Some("s_ttracedata_imm")); + assert!(crate::ir::build(&code, false, 1).is_ok()); + } +}