tombox-xshader: MIMG image_load / image_store (ops 0x00-0x1F) unsupported #103

Closed
opened 2026-11-26 06:10:33 +00:00 by github-bot · 2 comments
Owner

@⁠Trwthh on GitHub · 2026-11-22 09:16 UTC · original

Component: crates/tombox-xshader/src/hlsl.rs

What happens: The MIMG handler at line 5565-5566 only accepts sample ops (0x20-0x3F) and gather ops (0x40-0x5F). Any MIMG instruction with opcode < 0x20 — including image_load, image_store, image_load_mip, image_store_mip — hits:

if !gather && !(0x20..0x40).contains(&op) {
    return Err("unsupported image op".into());
}

Impact: Console games that use image_load / image_store for unstructured UAV texture access (common in compute shaders, post-processing, and deferred rendering) will fail shader translation entirely. These are RDNA2 opcodes 0x00-0x07 (load family) and 0x08-0x0F (store family) per the ISA reference.

ISA reference: RDNA2 ISA manual, section 10.2 (MIMG), Table 56.

Suggested fix: Extend the MIMG handler to emit tex.Load() for image_load variants and tex[coord] = value for image_store variants, with proper format/component handling.

**@⁠Trwthh** on GitHub · 2026-11-22 09:16 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/103) **Component:** `crates/tombox-xshader/src/hlsl.rs` **What happens:** The MIMG handler at line 5565-5566 only accepts sample ops (0x20-0x3F) and gather ops (0x40-0x5F). Any MIMG instruction with opcode < 0x20 — including `image_load`, `image_store`, `image_load_mip`, `image_store_mip` — hits: ```rust if !gather && !(0x20..0x40).contains(&op) { return Err("unsupported image op".into()); } ``` **Impact:** Console games that use `image_load` / `image_store` for unstructured UAV texture access (common in compute shaders, post-processing, and deferred rendering) will fail shader translation entirely. These are RDNA2 opcodes 0x00-0x07 (load family) and 0x08-0x0F (store family) per the ISA reference. **ISA reference:** RDNA2 ISA manual, section 10.2 (MIMG), Table 56. **Suggested fix:** Extend the MIMG handler to emit `tex.Load()` for image_load variants and `tex[coord] = value` for image_store variants, with proper format/component handling.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:10:33 +00:00
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-22 11:03 UTC · original

These ops are already translated on main (51f5319). The check quoted in the issue is the fall-through at the end of the MIMG handler; the texel-addressed ops return earlier in the same function:

  • hlsl.rs 5412: // Texel-addressed ops (no sampler): image_load / image_store, on SRVs or UAVs. The block handles image_load, image_load_mip, image_store, image_store_mip, image_atomic_add and image_atomic_umax.
  • hlsl.rs 5372: image_get_resinfo.

They are also executed, not only translated: tests/exec_mem/mimg.rs has image_load, image_store_mip and image_get_resinfo cases, and cargo test -p tombox-xshader --release --test exec passes 73 of 73 on WARP on that commit (mimg_store_mip: 1 mnemonics verified, 0 failing, mimg_query: 2 mnemonics verified, 0 failing).

What is still refused in 0x00-0x1f is what the decoder does not name (rdna2/mnem.rs 301-303 names 0x00, 0x01, 0x08, 0x09, 0x0e, 0x11 and 0x17 only): the _pck forms and the other image atomics. tools/progress/data/mnemonics.txt lists no title use of those: the MIMG ops below 0x20 it counts are image_load, image_load_mip, image_store, image_atomic_add and image_atomic_umax, all translated.

As written, I think this one can be closed.

**@⁠QuentinDanblon** on GitHub · 2026-11-22 11:03 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/103#issuecomment-7078190268) These ops are already translated on main (51f5319). The check quoted in the issue is the fall-through at the end of the MIMG handler; the texel-addressed ops return earlier in the same function: - `hlsl.rs` 5412: `// Texel-addressed ops (no sampler): image_load / image_store, on SRVs or UAVs.` The block handles `image_load`, `image_load_mip`, `image_store`, `image_store_mip`, `image_atomic_add` and `image_atomic_umax`. - `hlsl.rs` 5372: `image_get_resinfo`. They are also executed, not only translated: `tests/exec_mem/mimg.rs` has `image_load`, `image_store_mip` and `image_get_resinfo` cases, and `cargo test -p tombox-xshader --release --test exec` passes 73 of 73 on WARP on that commit (`mimg_store_mip: 1 mnemonics verified, 0 failing`, `mimg_query: 2 mnemonics verified, 0 failing`). What is still refused in 0x00-0x1f is what the decoder does not name (`rdna2/mnem.rs` 301-303 names 0x00, 0x01, 0x08, 0x09, 0x0e, 0x11 and 0x17 only): the `_pck` forms and the other image atomics. `tools/progress/data/mnemonics.txt` lists no title use of those: the MIMG ops below 0x20 it counts are `image_load`, `image_load_mip`, `image_store`, `image_atomic_add` and `image_atomic_umax`, all translated. As written, I think this one can be closed.
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 13:12 UTC · original

image_load, image_load_mip, image_store, image_store_mip, image_atomic_add/umax and image_get_resinfo are translated on main and covered by tests/exec_mem/mimg.rs. The ops still refused in 0x00-0x1f (_pck forms, other image atomics) have no known title use; a new issue is welcome if a shader needs one.

**@⁠omonkeyz** on GitHub · 2026-11-23 13:12 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/103#issuecomment-7102203137) image_load, image_load_mip, image_store, image_store_mip, image_atomic_add/umax and image_get_resinfo are translated on main and covered by tests/exec_mem/mimg.rs. The ops still refused in 0x00-0x1f (_pck forms, other image atomics) have no known title use; a new issue is welcome if a shader needs one.
This discussion has been locked. Commenting is limited to contributors.
No description provided.