shader: infer descriptor table bindings for mesh shaders without RTS0 #129

Closed
github-bot wants to merge 2 commits from gh-pr/129/head into gh-pr/129/base
Owner

@⁠ComputerScape04 on GitHub · 2026-11-22 14:04 UTC · original
ComputerScape04:feature/infer-mesh-root-sig → main · +520 −22 · 15 files · 2 commits · closed without merging

Summary

Per the design settled in #142, this is Part 1 of the root signature inference work, providing the shared inference core for shaders lacking an embedded RTS0 chunk (such as console mesh programs):

  1. Modular Location: All inference logic is localized to crates/tombox-xshader/src/hlsl/infer.rs beside rootmem.rs. Translator caller files (d3d12_xs, bin/xshader.rs,
    bin/xshader_prelaunch.rs) are untouched.
  2. Opt-in, Off by Default: Static RTS0 remains default. Inference only executes when ex.root_sig.is_none() && !ex.has_root_sig under TOMBOX_INFER_ROOT_SIG=1 or via
    translate_with_inference().
  3. Shared Core:
  • Walks disassembled RDNA2 instructions to track user-SGPR origins (s_mov_b32/s_mov_b64).
  • Identifies scalar loads for root CBVs and descriptor table ranges for buffer resources (t#/u#/s#).
  • Reconciles inferred bindings against embedded PSV0 resource metadata when present.

Tests

  • mesh_root_signature_inference_binds_scalar_buffer_load: Verifies scalar load inference, root CBV placement, and successful DXIL bytecode compilation via DXC.
  • mesh_root_signature_inference_binds_typed_buffer_table: Verifies descriptor table range deduction and DXC compilation.
  • mesh_root_signature_inference_matches_psv_metadata: Verifies descriptor table alignment with PSV0 metadata.
  • All 23 mesh unit tests pass.

Scope

  • Total diff: ~325 lines across 4 files in crates/tombox-xshader/.
  • Rebased onto current main.
**@⁠ComputerScape04** on GitHub · 2026-11-22 14:04 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/129) `ComputerScape04:feature/infer-mesh-root-sig` → `main` · +520 −22 · 15 files · 2 commits · closed without merging ### Summary Per the design settled in #142, this is Part 1 of the root signature inference work, providing the shared inference core for shaders lacking an embedded `RTS0` chunk (such as console mesh programs): 1. **Modular Location**: All inference logic is localized to `crates/tombox-xshader/src/hlsl/infer.rs` beside `rootmem.rs`. Translator caller files (`d3d12_xs`, `bin/xshader.rs`, `bin/xshader_prelaunch.rs`) are untouched. 2. **Opt-in, Off by Default**: Static `RTS0` remains default. Inference only executes when `ex.root_sig.is_none() && !ex.has_root_sig` under `TOMBOX_INFER_ROOT_SIG=1` or via `translate_with_inference()`. 3. **Shared Core**: - Walks disassembled RDNA2 instructions to track user-SGPR origins (`s_mov_b32`/`s_mov_b64`). - Identifies scalar loads for root CBVs and descriptor table ranges for buffer resources (`t#`/`u#`/`s#`). - Reconciles inferred bindings against embedded `PSV0` resource metadata when present. ### Tests - `mesh_root_signature_inference_binds_scalar_buffer_load`: Verifies scalar load inference, root CBV placement, and successful DXIL bytecode compilation via DXC. - `mesh_root_signature_inference_binds_typed_buffer_table`: Verifies descriptor table range deduction and DXC compilation. - `mesh_root_signature_inference_matches_psv_metadata`: Verifies descriptor table alignment with `PSV0` metadata. - All 23 mesh unit tests pass. ### Scope - Total diff: ~325 lines across 4 files in `crates/tombox-xshader/`. - Rebased onto current `main`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:11:02 +00:00
github-bot closed this pull request 2026-11-26 06:11:02 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 15:45 UTC · original

Thanks for the update, there's a lot of good work here! Since then we've settled the direction for shaders without RTS0 in #142, and this PR should fold into that design:

  1. Opt-in, off by default. The static RTS0 path stays the default. Inference runs only when a shader has no RTS0, or behind a switch.
  2. Location. Put it in hlsl/rootmem.rs, or a module beside it, not spread across the existing translator files.
  3. Tests. Add one WARP test for each kind of binding you infer.
  4. Split. Please break it into smaller PRs of a few hundred lines each, starting with the shared inference core, and add each binding kind on top of that.

Please also cherry-pick or rebase each piece onto current main.

**@⁠omonkeyz** on GitHub · 2026-11-22 15:45 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/129#issuecomment-7081541999) Thanks for the update, there's a lot of good work here! Since then we've settled the direction for shaders without RTS0 in #142, and this PR should fold into that design: 1. **Opt-in, off by default.** The static RTS0 path stays the default. Inference runs only when a shader has no RTS0, or behind a switch. 2. **Location.** Put it in `hlsl/rootmem.rs`, or a module beside it, not spread across the existing translator files. 3. **Tests.** Add one WARP test for each kind of binding you infer. 4. **Split.** Please break it into smaller PRs of a few hundred lines each, starting with the shared inference core, and add each binding kind on top of that. Please also cherry-pick or rebase each piece onto current main.
Author
Owner

@⁠MeNoSkills on GitHub · 2026-11-22 16:07 UTC · original

Ran this on real hardware: NVIDIA GeForce RTX 4070 Ti, Windows 10 19045, MSVC toolchain, branch head 89269fe, TOMBOX_EXEC_HW=1 (WARP reports MeshShaderTier 0, so the gpu_mesh_* tests need the hardware device).

  • cargo test --locked -p tombox-xshader --test mesh: 23 passed, 0 failed, 1 ignored (needs title fixtures). main at the same point: 20 passed.
  • cargo test --locked -p tombox-xshader --lib --test synthetic: 70 + 18 passed, 0 failed.

I only ran the tests, I did not review the inference logic itself or run it on real mesh shaders (no dump).

**@⁠MeNoSkills** on GitHub · 2026-11-22 16:07 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/129#issuecomment-7081831939) Ran this on real hardware: NVIDIA GeForce RTX 4070 Ti, Windows 10 19045, MSVC toolchain, branch head 89269fe, TOMBOX_EXEC_HW=1 (WARP reports MeshShaderTier 0, so the gpu_mesh_* tests need the hardware device). - cargo test --locked -p tombox-xshader --test mesh: 23 passed, 0 failed, 1 ignored (needs title fixtures). main at the same point: 20 passed. - cargo test --locked -p tombox-xshader --lib --test synthetic: 70 + 18 passed, 0 failed. I only ran the tests, I did not review the inference logic itself or run it on real mesh shaders (no dump).
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 17:34 UTC · original

Applied in c697a1e (merged in 444014d) with your authorship kept, thanks. It stays opt-in. With TOMBOX_INFER_ROOT_SIG unset, translation and the shader-pack key are identical to main. With it set, d3d12_xs bypasses the pre-translate pack index (a11d361), so a shader translated with inference is never served from a pack built without it. The merge note records MeNoSkills' RTX 4070 Ti run (--test mesh 23 passed vs 20 on main).

**@⁠omonkeyz** on GitHub · 2026-11-22 17:34 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/129#issuecomment-7082939849) Applied in c697a1e (merged in 444014d) with your authorship kept, thanks. It stays opt-in. With TOMBOX_INFER_ROOT_SIG unset, translation and the shader-pack key are identical to main. With it set, d3d12_xs bypasses the pre-translate pack index (a11d361), so a shader translated with inference is never served from a pack built without it. The merge note records MeNoSkills' RTX 4070 Ti run (--test mesh 23 passed vs 20 on main).
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 14:59 UTC · original · requested changes

Thanks! Two separate things here, so please split them:

  1. Opus build skip (e70d7e2): we can't take this one. With the sources missing it still produces opus_dll with an empty exports.txt, so the build "succeeds" with a DLL that lacks the codec. The project rule is no fake success. A build that can't find third_party/opus should fail with a clear message (or the crate should be left out of the build), not ship an empty DLL.
  2. Root signature inference (7d5a758): the idea is useful for stripped mesh shaders, but match_resource falls back to (default_reg, 0) when no PSV resource matches. That silently binds a guessed register and space. Please return an error in that case, so the translation refuses instead of binding the wrong resource. Also gate translate_with_inference the same way as translate_linked (or make it the only entry point), so inference never runs unless asked for. Then a maintainer will run it against the stripped-mesh corpus on hardware.
**@⁠omonkeyz** on GitHub · 2026-11-22 14:59 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/129#pullrequestreview-6012908218) · **requested changes** Thanks! Two separate things here, so please split them: 1. **Opus build skip (e70d7e2):** we can't take this one. With the sources missing it still produces opus_dll with an empty exports.txt, so the build "succeeds" with a DLL that lacks the codec. The project rule is no fake success. A build that can't find `third_party/opus` should fail with a clear message (or the crate should be left out of the build), not ship an empty DLL. 2. **Root signature inference (7d5a758):** the idea is useful for stripped mesh shaders, but `match_resource` falls back to `(default_reg, 0)` when no PSV resource matches. That silently binds a guessed register and space. Please return an error in that case, so the translation refuses instead of binding the wrong resource. Also gate `translate_with_inference` the same way as `translate_linked` (or make it the only entry point), so inference never runs unless asked for. Then a maintainer will run it against the stripped-mesh corpus on hardware.

Pull request closed

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