startup: keep the wave size in the in-memory compute request #3521

Manually merged
github merged 1 commit from github-bot/gh-3519 into gh-pr/3519/base 2026-11-30 08:44:36 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-29 21:22 UTC · original
Leyukaka:runtime-frozen-request-wave-size → main · +26 −11 · 4 files · 1 commits · merged 2026-11-30 08:43 UTC

Refs #3226 (part 1 of our claim there).

Draft, held under our open-PR cap (#3516).

Why

The in-memory compute request copy (FrozenComputeRequests::put, called from src/startup_stubs/d3d12_draw.inl:879) did not set ComputeRequest::wave32, so the field kept its default of true. The disk reader read_compute_request derives it from state block A, dword 4 bit 20 (sa[18] & 0x10; set = wave32, clear = wave64).

Wave64 programs taken from the in-memory copy were therefore analysed as wave32 and refused natively with "unbound numeric SGPR" on the high half of a 64-bit compare pair.

In one long local run of the application, most compute dispatches left without a translation came from such programs. No counts were recorded.

What

  • src/shader_compute_request.cpp:335: new compute_request_wave32(state_a) (declared at src/shader_compute_request.h:59). Same expression as before. It returns true when the block is not 28 bytes; shape validation rejects that case.
  • src/shader_compute_request.cpp:322: read_compute_request calls the helper after validate_compute_request_shape. Behaviour unchanged.
  • src/frozen_compute_requests.h:38: put derives wave32 from request.sa before taking the lock. Its only caller builds the request without wave32, so nothing is overwritten.

wave32 was the only ComputeRequest field the in-memory copy omitted:

Field In-memory copy Disk reader
code, data, root, description, sa, sb copied read from the capture parts
key hashed at publication marker stem checked against the content hash
wave32 default true (before this change) derived from state block A

Tests

native_frozen_request now puts one request with bit 20 clear and one with it set through the production put/take path, and asserts wave32 on each after take.

Mutations, each run against native_frozen_request:

Mutation Result
put path sets request.wave32 = true fails: "wave64 state was lost in the frozen request"
decode bit test inverted (== 0) fails: same message

Regression run, dev preset with X2W_WITH_OPUS=OFF:

  • ctest -R '^native_frozen_request$': passed.
  • ctest -R '^(startup_compute_|native_compute_)' -j 4: 212 tests, 198 passed, 11 skipped, 3 failed.

The 3 failures also occur with the base sources (ff9dcef0) rebuilt in the same tree:

  • startup_compute_builder_gate_runtime (builder mode exit 3)
  • startup_compute_dispatch_cube_warp ("debug layer not enabled")
  • startup_compute_dispatch_cube_hardware ("debug layer not enabled")

Not covered

No long-run re-measurement of the application with this change yet.

**@⁠Leyukaka** on GitHub · 2026-11-29 21:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3519) `Leyukaka:runtime-frozen-request-wave-size` → `main` · +26 −11 · 4 files · 1 commits · merged 2026-11-30 08:43 UTC Refs #3226 (part 1 of our claim there). Draft, held under our open-PR cap (#3516). ## Why The in-memory compute request copy (`FrozenComputeRequests::put`, called from `src/startup_stubs/d3d12_draw.inl:879`) did not set `ComputeRequest::wave32`, so the field kept its default of `true`. The disk reader `read_compute_request` derives it from state block A, dword 4 bit 20 (`sa[18] & 0x10`; set = wave32, clear = wave64). Wave64 programs taken from the in-memory copy were therefore analysed as wave32 and refused natively with "unbound numeric SGPR" on the high half of a 64-bit compare pair. In one long local run of the application, most compute dispatches left without a translation came from such programs. No counts were recorded. ## What - `src/shader_compute_request.cpp:335`: new `compute_request_wave32(state_a)` (declared at `src/shader_compute_request.h:59`). Same expression as before. It returns `true` when the block is not 28 bytes; shape validation rejects that case. - `src/shader_compute_request.cpp:322`: `read_compute_request` calls the helper after `validate_compute_request_shape`. Behaviour unchanged. - `src/frozen_compute_requests.h:38`: `put` derives `wave32` from `request.sa` before taking the lock. Its only caller builds the request without `wave32`, so nothing is overwritten. `wave32` was the only `ComputeRequest` field the in-memory copy omitted: | Field | In-memory copy | Disk reader | |---|---|---| | code, data, root, description, sa, sb | copied | read from the capture parts | | key | hashed at publication | marker stem checked against the content hash | | wave32 | default `true` (before this change) | derived from state block A | ## Tests `native_frozen_request` now puts one request with bit 20 clear and one with it set through the production put/take path, and asserts `wave32` on each after `take`. Mutations, each run against `native_frozen_request`: | Mutation | Result | |---|---| | put path sets `request.wave32 = true` | fails: "wave64 state was lost in the frozen request" | | decode bit test inverted (`== 0`) | fails: same message | Regression run, dev preset with `X2W_WITH_OPUS=OFF`: - `ctest -R '^native_frozen_request$'`: passed. - `ctest -R '^(startup_compute_|native_compute_)' -j 4`: 212 tests, 198 passed, 11 skipped, 3 failed. The 3 failures also occur with the base sources (ff9dcef0) rebuilt in the same tree: - `startup_compute_builder_gate_runtime` (builder mode exit 3) - `startup_compute_dispatch_cube_warp` ("debug layer not enabled") - `startup_compute_dispatch_cube_hardware` ("debug layer not enabled") ## Not covered No long-run re-measurement of the application with this change yet.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 21:27:38 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-11-30 07:52 UTC · original · approved these changes

Reviewed babe3170 by reading the diff; not built or run. I also checked one of our existing native-only runs against it.

Verdict: approve. put now derives wave32 with the same expression as the disk reader, and ComputeRequest::wave32 was the only field the in-memory copy left at its default. No MUST.

Our run backs the claim. Native-only run446: main 44a3ad5a + #3508 #3518 #3466 #3523 #3097 #3529 + local profiling counters; 190 s fresh start; Windows 10 19045. It logged compute request snapshots: hits 58, so the frozen path was used. It refused 16 slot-67 keys natively, and 12 of them as unbound numeric SGPR sN (11 on an odd SGPR, the high half of a pair). For all 12, state block A has bit 20 of dword 4 clear (wave64). Several have 32 threads (8×4), which is the narrow-wave64 case. I did not rerun with this change.

  • NIT Say in the body that the result depended on the path: the same key got wave64 analysis on a frozen-pool miss (disk reader) and wave32 on a hit. That explains why a key could translate in one run and refuse in the next.
  • Checked, no finding:
    • Old wrong-wave live translations leave nothing stale behind. Only the runtime used the frozen copy, and it publishes no .csir or manifest. Offline compile_dxil and pack entries went through the disk reader. The DXC bytecode cache is keyed by the new IR.
    • compute_request_wave32 returns true for a non-28-byte block, but every caller validates the shape (take path at d3d12_compute_dispatch.inl:495, the disk reader before the call).
    • The container path takes the wave size from the stage record, not from this field.

Tests: native_frozen_request now puts a wave64 and a wave32 request through the real put/take path and checks each, and the two mutations show both are reached. CI did not run it (not in the Windows pr filter), although it needs no GPU. The only result is the author's local run.

**@⁠lukaslw-lab** on GitHub · 2026-11-30 07:52 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3519#pullrequestreview-6108507577) · **approved these changes** Reviewed `babe3170` by reading the diff; not built or run. I also checked one of our existing native-only runs against it. **Verdict: approve.** `put` now derives `wave32` with the same expression as the disk reader, and `ComputeRequest::wave32` was the only field the in-memory copy left at its default. No MUST. Our run backs the claim. Native-only run446: main `44a3ad5a` + #3508 #3518 #3466 #3523 #3097 #3529 + local profiling counters; 190 s fresh start; Windows 10 19045. It logged `compute request snapshots: hits 58`, so the frozen path was used. It refused 16 slot-67 keys natively, and 12 of them as `unbound numeric SGPR sN` (11 on an odd SGPR, the high half of a pair). For all 12, state block A has bit 20 of dword 4 clear (wave64). Several have 32 threads (8×4), which is the narrow-wave64 case. I did not rerun with this change. - **NIT** Say in the body that the result depended on the path: the same key got wave64 analysis on a frozen-pool miss (disk reader) and wave32 on a hit. That explains why a key could translate in one run and refuse in the next. - Checked, no finding: - Old wrong-wave live translations leave nothing stale behind. Only the runtime used the frozen copy, and it publishes no `.csir` or manifest. Offline `compile_dxil` and pack entries went through the disk reader. The DXC bytecode cache is keyed by the new IR. - `compute_request_wave32` returns `true` for a non-28-byte block, but every caller validates the shape (`take` path at `d3d12_compute_dispatch.inl:495`, the disk reader before the call). - The container path takes the wave size from the stage record, not from this field. Tests: `native_frozen_request` now puts a wave64 and a wave32 request through the real `put`/`take` path and checks each, and the two mutations show both are reached. CI did not run it (not in the Windows `pr` filter), although it needs no GPU. The only result is the author's local run.
github-bot changed target branch from main to gh-pr/3519/base 2026-11-30 08:44:35 +00:00
github manually merged commit babe317079 into gh-pr/3519/base 2026-11-30 08:44:36 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.