tombox-xshader: translate gfx7 MTBUF dfmt/nfmt to RDNA2 unified formats #37

Closed
github-bot wants to merge 1 commit from gh-pr/37/head into gh-pr/37/base
Owner

@⁠dea7hsmiless on GitHub · 2026-11-21 18:52 UTC · original
xshader/gfx7-mtbuf → main · +127 −1 · 1 files · 102 commits · closed without merging

Library / area: crates/tombox-xshader (Durango/gfx7 to RDNA2 lowering)

Exports changed (exports.txt rows): none

Source of the behaviour: LLVM AMDGPU encoding definitions and tables:

  • BUFInstructions.td: Base_MTBUF_Real_gfx6_gfx7_gfx10 keeps gfx7's
    offset/offen/idxen/glc/op/SLC/TFE positions on GFX10;
    MTBUF_Real_gfx10 puts the unified format in bits 25:19 and DLC in bit 15.
  • Utils/AMDGPUAsmUtils.cpp: DfmtNfmt2UFmtGFX10 (78 pairs, ID = table
    index); UfmtSymbolicGFX10 ID 0x16 is BUF_FMT_32_FLOAT.
  • AMDGPUBaseInfo.cpp: convertDfmtNfmt2Ufmt returns that index for GFX10.
  • src/hlsl/mtbuf.rs::ufmt already decodes the same GFX10 IDs from
    (word >> 19) & 0x7f.

What changed: to_rdna2 no longer rejects every gfx7 MTBUF. It:

  • rejects addr64 (bit 15), which has no RDNA2 equivalent (bit 15 is DLC
    on GFX10);
  • converts (dfmt, nfmt) to the GFX10 unified ID and writes it to bits 25:19;
  • preserves dword1 and every non-format bit.

Unsupported (dfmt, nfmt) pairs still return an explicit error instead of
guessing.

Tests and results:

  • cargo test -p tombox-xshader --lib gcn::tests::mtbuf -> 6 passed, 0 failed.
  • cargo test -p tombox-xshader --lib -> 14 passed, 0 failed.
  • cargo build -p tombox-xshader -> exit 0 (only the pre-existing
    AS_ABI_UNKNOWN dead-code warning).
  • Independent parse of LLVM AMDGPUAsmUtils.cpp against the Rust table ->
    78/78 entries match, in ID order.
  • cargo test -p tombox-xshader --no-fail-fast: opcodes 22/22 and
    synthetic 7/7 pass; exec 56 passed, 4 failed, 1 ignored. The four
    failures are vop::basic cases targeted by open PRs #24, #29, #33 and #34.
    amp, fixtures and the mesh fixture test require private
    analysis/shaders/ fixtures that are not present in a public checkout,
    and are addressed by PR #13; mesh_refusals_are_explicit is addressed by
    PR #19. Integration tests do not call to_rdna2 (grep: no matches), so
    this diff cannot affect them.

Negative control: with the old unconditional MTBUF rejection restored,
5 of the 6 new tests failed (only the static table-order test passed). After
restoring the conversion, all 6 passed.

Environment: Windows 11 Pro 10.0.26300, rustc/cargo 1.99.1, NVIDIA
RTX 3070 driver 32.0.16.2124.

Proven / inferred / not tested:

  • Proven: encoding conversion and error paths with synthetic instructions;
    the table matches LLVM exactly.
  • Inferred: real gfx7 shaders using these formats will now lower, because
    the HLSL backend consumes the same unified IDs.
  • Not tested: a real title or dump (none available), and WARP execution
    starting from gfx7 MTBUF (the execution harness constructs RDNA2 ISA
    directly).
  • addr64 and format pairs absent from LLVM's GFX10 table remain explicit
    errors.

Dependencies: none.

  • cargo test -p tombox-xshader passes

    Unchecked: the crate has pre-existing failures on this checkout. amp,
    fixtures and the mesh fixture test need private analysis/shaders/
    fixtures that are not present in a public checkout;
    the vop::basic failures are targeted by open PRs #24, #29, #33 and
    #34; mesh_refusals_are_explicit is targeted by PR #19. The changed
    module's tests and the crate's --lib tests pass, and the failing
    integration tests never call to_rdna2.

  • No game or console files and no binaries included

  • No fake success; anything not possible is left missing with a note

No game files, console DLLs, assets or binaries are included.

**@⁠dea7hsmiless** on GitHub · 2026-11-21 18:52 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/37) `xshader/gfx7-mtbuf` → `main` · +127 −1 · 1 files · 102 commits · closed without merging **Library / area:** `crates/tombox-xshader` (Durango/gfx7 to RDNA2 lowering) **Exports changed (exports.txt rows):** none **Source of the behaviour:** LLVM AMDGPU encoding definitions and tables: - `BUFInstructions.td`: `Base_MTBUF_Real_gfx6_gfx7_gfx10` keeps gfx7's offset/offen/idxen/glc/op/SLC/TFE positions on GFX10; `MTBUF_Real_gfx10` puts the unified format in bits 25:19 and DLC in bit 15. - `Utils/AMDGPUAsmUtils.cpp`: `DfmtNfmt2UFmtGFX10` (78 pairs, ID = table index); `UfmtSymbolicGFX10` ID 0x16 is `BUF_FMT_32_FLOAT`. - `AMDGPUBaseInfo.cpp`: `convertDfmtNfmt2Ufmt` returns that index for GFX10. - `src/hlsl/mtbuf.rs::ufmt` already decodes the same GFX10 IDs from `(word >> 19) & 0x7f`. **What changed:** `to_rdna2` no longer rejects every gfx7 MTBUF. It: - rejects `addr64` (bit 15), which has no RDNA2 equivalent (bit 15 is DLC on GFX10); - converts `(dfmt, nfmt)` to the GFX10 unified ID and writes it to bits 25:19; - preserves dword1 and every non-format bit. Unsupported `(dfmt, nfmt)` pairs still return an explicit error instead of guessing. **Tests and results:** - `cargo test -p tombox-xshader --lib gcn::tests::mtbuf` -> 6 passed, 0 failed. - `cargo test -p tombox-xshader --lib` -> 14 passed, 0 failed. - `cargo build -p tombox-xshader` -> exit 0 (only the pre-existing `AS_ABI_UNKNOWN` dead-code warning). - Independent parse of LLVM `AMDGPUAsmUtils.cpp` against the Rust table -> 78/78 entries match, in ID order. - `cargo test -p tombox-xshader --no-fail-fast`: `opcodes` 22/22 and `synthetic` 7/7 pass; `exec` 56 passed, 4 failed, 1 ignored. The four failures are `vop::basic` cases targeted by open PRs #24, #29, #33 and #34. `amp`, `fixtures` and the mesh fixture test require private `analysis/shaders/` fixtures that are not present in a public checkout, and are addressed by PR #13; `mesh_refusals_are_explicit` is addressed by PR #19. Integration tests do not call `to_rdna2` (grep: no matches), so this diff cannot affect them. **Negative control:** with the old unconditional MTBUF rejection restored, 5 of the 6 new tests failed (only the static table-order test passed). After restoring the conversion, all 6 passed. **Environment:** Windows 11 Pro 10.0.26300, rustc/cargo 1.99.1, NVIDIA RTX 3070 driver 32.0.16.2124. **Proven / inferred / not tested:** - Proven: encoding conversion and error paths with synthetic instructions; the table matches LLVM exactly. - Inferred: real gfx7 shaders using these formats will now lower, because the HLSL backend consumes the same unified IDs. - Not tested: a real title or dump (none available), and WARP execution starting from gfx7 MTBUF (the execution harness constructs RDNA2 ISA directly). - `addr64` and format pairs absent from LLVM's GFX10 table remain explicit errors. **Dependencies:** none. - [ ] `cargo test -p tombox-xshader` passes Unchecked: the crate has pre-existing failures on this checkout. `amp`, `fixtures` and the mesh fixture test need private `analysis/shaders/` fixtures that are not present in a public checkout; the `vop::basic` failures are targeted by open PRs #24, #29, #33 and #34; `mesh_refusals_are_explicit` is targeted by PR #19. The changed module's tests and the crate's `--lib` tests pass, and the failing integration tests never call `to_rdna2`. - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note No game files, console DLLs, assets or binaries are included.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:08:05 +00:00
github-bot closed this pull request 2026-11-26 06:08:05 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 13:18 UTC · original

Main's history was rewritten, which auto-closed this PR. It is applied in 73c5103 (merged in 99f48e3) with your authorship kept, thanks! The added comment lines were stripped on the applied copy, and LLVM's DfmtNfmt2UFmtGFX10 table is credited in THIRD_PARTY/CREDITS.

**@⁠omonkeyz** on GitHub · 2026-11-22 13:18 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/37#issuecomment-7079717774) Main's history was rewritten, which auto-closed this PR. It is applied in 73c5103 (merged in 99f48e3) with your authorship kept, thanks! The added comment lines were stripped on the applied copy, and LLVM's DfmtNfmt2UFmtGFX10 table is credited in THIRD_PARTY/CREDITS.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.