Read compute NumThreads from PSVRuntimeInfo2 #139

Closed
Yeetbot159 wants to merge 1 commit from upstream-pr/139 into main
Yeetbot159 commented 2026-11-22 15:14:29 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by Yeetbot159 on 2026-11-22T15:14:29Z.


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.
<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6544037212 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/139). Originally posted by [Yeetbot159](https://github.com/Yeetbot159) on 2026-11-22T15:14:29Z. --- ## 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`.
omonkeyz commented 2026-11-22 15:29:01 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-22T15:29:01Z.


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.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7081337539 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/139#issuecomment-7081337539). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-22T15:29:01Z. --- 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

Sign in to join this conversation.
No reviewers
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!139
No description provided.