Read compute NumThreads from PSVRuntimeInfo2 #139

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

@⁠Yeetbot159 on GitHub · 2026-11-22 15:14 UTC · original
Yeetbot159:yeet/psv-numthreads → main · +78 −1 · 14 files · 1 commits · closed without merging

Summary

  • Compute NumThreadsX/Y/Z are the first fields of PSVRuntimeInfo2, at offsets 36, 40 and 44 of the runtime info (the dword before that is the info size). The stage union at the start of the info is not the thread count.
  • Each dimension must be 1..=1024 and the product must be at most 1024. A runtime info shorter than 48 bytes is ignored.
  • A non-zero ISA preamble still supplies [numthreads]. The PSV size is used only when those preamble dwords are zero. Otherwise the translator keeps the previous 1,1,1 fallback.

Test plan

  • cargo test -p tombox-xshader --lib cs_thread_counts -- --exact meta::tests::cs_thread_counts_reject_a_bad_group_size passed. The blob with stage-union dwords 8,8,1 and NumThreads 4,2,1 returns [4, 2, 1].
  • cargo test -p tombox-xshader --test synthetic compute_numthreads -- --exact compute_numthreads_come_from_psv_when_the_preamble_is_zero passed. Preamble [0, 8, 1, 1] wins over PSV [4, 2, 1].
  • cargo test -p tombox-xshader --tests --no-run and cargo test -p d3d12_xs --lib --no-run compiled. Every ShaderExtract literal gained psv_numthreads: None.
**@⁠Yeetbot159** on GitHub · 2026-11-22 15:14 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/139) `Yeetbot159:yeet/psv-numthreads` → `main` · +78 −1 · 14 files · 1 commits · closed without merging ## Summary - Compute `NumThreadsX/Y/Z` are the first fields of `PSVRuntimeInfo2`, at offsets 36, 40 and 44 of the runtime info (the dword before that is the info size). The stage union at the start of the info is not the thread count. - Each dimension must be 1..=1024 and the product must be at most 1024. A runtime info shorter than 48 bytes is ignored. - A non-zero ISA preamble still supplies `[numthreads]`. The PSV size is used only when those preamble dwords are zero. Otherwise the translator keeps the previous 1,1,1 fallback. ## Test plan - `cargo test -p tombox-xshader --lib cs_thread_counts -- --exact meta::tests::cs_thread_counts_reject_a_bad_group_size` passed. The blob with stage-union dwords 8,8,1 and NumThreads 4,2,1 returns `[4, 2, 1]`. - `cargo test -p tombox-xshader --test synthetic compute_numthreads -- --exact compute_numthreads_come_from_psv_when_the_preamble_is_zero` passed. Preamble `[0, 8, 1, 1]` wins over PSV `[4, 2, 1]`. - `cargo test -p tombox-xshader --tests --no-run` and `cargo test -p d3d12_xs --lib --no-run` compiled. Every `ShaderExtract` literal gained `psv_numthreads: None`.
NumThreadsX/Y/Z sit at offsets 36, 40 and 44. The dwords at the start of the runtime info are the stage union, so a geometry or mesh blob must not be treated as a thread-group size. A non-zero preamble still wins.

Co-authored-by: Cursor <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:11:30 +00:00
github-bot closed this pull request 2026-11-26 06:11:30 +00:00
Author
Owner

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

Applied in 57b24e7 (merged in 9865896) with your authorship kept, thanks! I fixed a merge conflict in synthetic.rs with the #136/#137 tests and kept all of them.

**@⁠omonkeyz** on GitHub · 2026-11-22 15:29 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/139#issuecomment-7081337539) Applied in 57b24e7 (merged in 9865896) with your authorship kept, thanks! I fixed a merge conflict in synthetic.rs with the #136/#137 tests and kept all of them.

Pull request closed

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