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

Closed
opened 2026-11-22 09:16:41 +00:00 by Trwthh · 2 comments
Trwthh commented 2026-11-22 09:16:41 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by Trwthh on 2026-11-22T09:16:41Z.


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.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6540685794 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/issues/103). Originally posted by [Trwthh](https://github.com/Trwthh) on 2026-11-22T09:16:41Z. --- **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.
QuentinDanblon commented 2026-11-22 11:03:26 +00:00 (Migrated from github.com)
Author

Imported from omonkeyz/xbox-emulator. Originally posted by QuentinDanblon on 2026-11-22T11:03:26Z.


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.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7078190268 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/issues/103#issuecomment-7078190268). Originally posted by [QuentinDanblon](https://github.com/QuentinDanblon) on 2026-11-22T11:03:26Z. --- 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.
omonkeyz commented 2026-11-23 13:12:16 +00:00 (Migrated from github.com)
Author

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-23T13:12:16Z.


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.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7102203137 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/issues/103#issuecomment-7102203137). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-23T13:12:16Z. --- 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.
Sign in to join this conversation.
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
omonkeyz/xbox-emulator#103
No description provided.