tombox-xshader: fix two translator panics; sweep the decoder and translator over LLVM's GFX10 vectors #51
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!51
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/51/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@realkodr on GitHub · 2026-11-21 21:33 UTC · original
realkodr:xshader/translator-panics→main· +41332 −0 · 6 files · 90 commits · closed without mergingLibrary / area: tombox-xshader (translator, decoder tests)
Exports changed (exports.txt rows): none
Source of the behaviour: instruction encodings from the LLVM Project's AMDGPU assembler and disassembler tests (llvm-project
901520f, Apache-2.0 WITH LLVM-exception). No new instruction semantics: the two fixes turn panics into refusals or into the translation the neighbouring registers already get.Two translator panics
Both are on encodings LLVM's assembler accepts. The workspace keeps overflow checks on in release, so they panic there too.
d3d12_xscatches the unwind, so a title would see "translator panicked", not a crash.s_buffer_loadpath, where1 << (op - 8)overflows: a subtract overflow for the scratch loads (5..7) and a shift overflow from 0x28 up (s_dcache_discard,s_get_waveid_in_workgroup, every atomic). Stores (0x10..0x1a) did not panic but were reported as "unresolved constant buffer". All are now refused as "unsupported SMEM op".hi64()added 1 to the register number of every operand, including the 32-bit ones, sov_cvt_f64_i32 v[5:6], v255orv_ldexp_f64 v[5:6], v[1:2], v255overflowed au8. These now translate. A 64-bit operand based at v255 would need v256 and is refused.How they were found, and the test that keeps them fixed
tools/dev/llvm_vectors.pycollects every (encoding, assembly) pair that LLVM's GFX10 MC tests check: 40,984 unique encodings.tests/llvm_vectors.rsruns them with no title dump, DXC or GPU:On
mainthe last check reports 358 panics. With the fix all six tests pass in about 2 s in a debug build. The decoder had no length errors.Overlap
#49 checks opcode names per opcode against gfx1013, so this PR does not check names. The two add different files and touch different parts of
hlsl.rs.Notes
tools/publish_source.pyskips files over 2 MB. They are test data only, credited incrates/tombox-xshader/THIRD_PARTY.hlsl.rsstill has two moreOpnd::Vgpr(n + 1)sites (64-bit vector shifts,buffer_atomic_cmpswap). No LLVM vector reaches them with v255, so I left them alone.Tests
cargo test -p tombox-xshader --test llvm_vectors: 6 pass, both natively on Linux and as a Windows binary under Wine 11.21.--lib --test opcodes --test synthetic: 12 / 22 / 9 pass on Linux.cargo check -p tombox-xshader --all-targets --target x86_64-pc-windows-msvcpasses.Not run on native Windows. The GPU suites (
exec,isa_sweep) were not run for this change.cargo test -p tombox-xshader --test llvm_vectorspassesNo game or console files and no binaries included
No fake success; anything not possible is left
missingwith a note🤖 Generated with Claude Code
@QuentinDanblon on GitHub · 2026-11-21 21:44 UTC · original
Overlap note with #49 (mine): both use LLVM's GFX10 MC vectors, for different checks. #49 commits a gfx1013 opcode→name reference (LLVM + AMD RDNA1/2 XML) and checks every name in
rdna2/mnem.rs. That found the VOP2 0x36-0x38 f16 ops arev_fmac/fmamk/fmaak_f16(fused), notv_mac/madmk/madak_f16, plus a few non-existent VOP3 fallback names. This PR sweeps the decoder and translator for panics. They look complementary; if one lands first I'll rebase #49 to share the vector source, so the repo doesn't end up with two copies.@realkodr on GitHub · 2026-11-21 23:18 UTC · original
Agreed, they're complementary. #49 is welcome to reuse
tools/dev/llvm_vectors.pyand the vectors undertests/data/llvm_gfx10/. If #49 lands first, I'll rebase this onto whatever vector source it uses instead.@omonkeyz on GitHub · 2026-11-22 13:12 UTC · original
Main's history was rewritten, which auto-closed this PR (sorry for the noise). The two panic fixes are good. Please send them as their own PR. valu.txt is over the 1 MiB file limit: split it, or generate it at build time. Strip comment lines. To resubmit:
git fetchthis repo, branch from the currentmain, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.Pull request closed