tombox-xshader: keep amplification DispatchMesh Z at 1 (args dword 2 is the payload pointer) #315

Closed
enderrr9 wants to merge 2 commits from upstream-pr/315 into main
enderrr9 commented 2026-11-23 17:57:49 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by enderrr9 on 2026-11-23T17:57:49Z.


Builds on #313. The first commit here is #313's test harness. The new change is the second commit (fbb7dd9).

Bug

The console AS writes its mesh-args entry as {X, 0, payload VA >> 4 high, payload VA >> 4 low} (fixture as3; see the BLOCKERS.md #115 CHECKED line). df91928 (#136) made the translated AS call DispatchMesh(tb_args[0], max(tb_args[1], 1u), max(tb_args[2], 1u), tb_pl), so it reads dword 2 as Z.

In the translator's ring address space the payload VA is 0x20_xxxx_xxxx, so dword 2 is 2. Every amplification group therefore launched each of its mesh groups twice. The pixels don't change, because the duplicate groups draw the same primitives, so no existing test saw it.

Fix

DispatchMesh(tb_args[0], max(tb_args[1], 1u), 1u, tb_pl):

  • X comes from dword 0.
  • Y comes from dword 1, which is 0 in as3, so it stays 1 as before. I kept it so #136's Y path still works if the console ever puts a count there.
  • Z stays 1, because dword 2 is the pointer.

Test

  • render_pair() now also returns an occlusion-query sample count.
  • New: gpu_synthetic_amplification_args_entry_with_the_payload_pointer_launches_each_mesh_group_once. The synthetic AS stores the console-shaped entry with one global_store_dwordx4. Two AS groups launch 1 and 2 mesh groups, each drawing one pixel, so the test expects 3 samples. Before the fix: 6. After: 3.
  • The two existing synthetic GPU tests now also check their sample counts (3 and 4).
  • The pinned HLSL strings in tests/amp.rs / tests/synthetic.rs are updated. The synthetic test is renamed to amplification_dispatch_uses_the_y_group_count_and_not_the_payload_pointer. The BLOCKERS.md #115 line now describes the current behaviour.

cargo test -p tombox-xshader --locked --test amp --test synthetic --test mesh: all pass on WARP. The fixture tests stay ignored here. pr_gate.py: 4 files, 0 problems.

Not covered

How the console compiler encodes Y/Z > 1 in the entry is still unverified, because no console AS seen so far calls a 2D/3D DispatchMesh. If someone has such a fixture, gpu_console_amplification_... could also assert the sample count.

🤖 Generated with Claude Code

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6565540127 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/315). Originally posted by [enderrr9](https://github.com/enderrr9) on 2026-11-23T17:57:49Z. --- **Builds on #313.** The first commit here is #313's test harness. The new change is the second commit (`fbb7dd9`). ## Bug The console AS writes its mesh-args entry as `{X, 0, payload VA >> 4 high, payload VA >> 4 low}` (fixture as3; see the BLOCKERS.md #115 CHECKED line). df91928 (#136) made the translated AS call `DispatchMesh(tb_args[0], max(tb_args[1], 1u), max(tb_args[2], 1u), tb_pl)`, so it reads dword 2 as Z. In the translator's ring address space the payload VA is `0x20_xxxx_xxxx`, so dword 2 is `2`. Every amplification group therefore launched each of its mesh groups twice. The pixels don't change, because the duplicate groups draw the same primitives, so no existing test saw it. ## Fix `DispatchMesh(tb_args[0], max(tb_args[1], 1u), 1u, tb_pl)`: - X comes from dword 0. - Y comes from dword 1, which is 0 in as3, so it stays 1 as before. I kept it so #136's Y path still works if the console ever puts a count there. - Z stays 1, because dword 2 is the pointer. ## Test - `render_pair()` now also returns an occlusion-query sample count. - New: `gpu_synthetic_amplification_args_entry_with_the_payload_pointer_launches_each_mesh_group_once`. The synthetic AS stores the console-shaped entry with one `global_store_dwordx4`. Two AS groups launch 1 and 2 mesh groups, each drawing one pixel, so the test expects 3 samples. **Before the fix: 6. After: 3.** - The two existing synthetic GPU tests now also check their sample counts (3 and 4). - The pinned HLSL strings in `tests/amp.rs` / `tests/synthetic.rs` are updated. The synthetic test is renamed to `amplification_dispatch_uses_the_y_group_count_and_not_the_payload_pointer`. The BLOCKERS.md #115 line now describes the current behaviour. `cargo test -p tombox-xshader --locked --test amp --test synthetic --test mesh`: all pass on WARP. The fixture tests stay ignored here. `pr_gate.py`: 4 files, 0 problems. ## Not covered How the console compiler encodes Y/Z > 1 in the entry is still unverified, because no console AS seen so far calls a 2D/3D DispatchMesh. If someone has such a fixture, `gpu_console_amplification_...` could also assert the sample count. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
omonkeyz commented 2026-11-25 13:49:26 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-25T13:49:26Z.


Applied on main in c1ee4bf (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7164342365 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/315#issuecomment-7164342365). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-25T13:49:26Z. --- Applied on main in c1ee4bf (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

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!315
No description provided.