compute: size an output token's view against the record, not the desktop header #3510

Merged
KelboLive merged 3 commits from upstream-pr/3510 into main 2026-11-30 02:20:14 +00:00
KelboLive commented 2026-11-29 19:50:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-29T19:50:37Z.


Change

compute_token_output() judged a slot-19 UAV view by comparing the guest record's width with
sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC). The record is ViewRecord::uav_desc_bytes (40 bytes)
whatever the build's headers are, but the Agility SDK 1.620.2 header makes that struct 48 bytes.

Under an Agility configuration every output token was therefore judged unmaterialized,
record_translated_dispatch() refused the dispatch with "an output token lacks a materialized
explicit counterless UAV"
, and the UAV kept its sentinel fill.

Compare against the record width and copy only the bytes the record carries into the zero-initialised
view, so the check no longer depends on the build's headers.

docs/experiments/agility-compute-views.md documents the same 40/48 difference for the SRV/UAV
temporary description (#3223). This is the same trap on the output-token path.

Verification

Base: upstream/main 5b86df1d6. The behaviour was measured on the fork's tree with 369143792
merged, using the agility configuration (-DOFFSCREEN_AGILITY_620_DIR and -DOFFSCREEN_WARP_DIR,
Agility SDK 1.620.2, WARP 1.0.22) on an RTX 4070 Ti SUPER.

Before:

startup_compute_indexed_atomic_uav_hardware  ***Failed  4.39 sec
  raw: word 0 expected c5c5c5d1, read c5c5c5c5
  x2w-draw compute UAV ... desc-bytes=40 ... result=an output token lacks a materialized explicit counterless UAV
  x2w-draw compute ... Dispatch(3, 2, 2) refused: an output token lacks a materialized explicit counterless UAV
startup_compute_typed_buffer_uav_hardware    ***Failed  5.92 sec
  view token: word 4 expected 3f800000, read c5c5c5c5

After:

startup_compute_indexed_atomic_uav_hardware ... Passed  7.78 sec
startup_compute_typed_buffer_uav_hardware .... Passed  20.29 sec
100% tests passed out of 2

No in-box regression (default dev preset, no Agility):

ctest --preset dev -R '^(startup_compute_indexed_atomic_uav|startup_compute_typed_buffer_uav)'
100% tests passed out of 6

All 15 hardware twins of the formerly-skipped capability set pass in the agility tree, with one
correct skip: bvh_wave64_hardware (the adapter has no 64-lane waves).

Evidence and follow-up

Not measured by CI: both Windows jobs build the in-box configuration, where
sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC) is already 40. The change is a no-op there, so a green
check cannot confirm the Agility behaviour; the before/after above is the evidence.

The fixture is the existing tests/startup_compute_indexed_atomic_uav_check.py and its typed-buffer
twin. The guest record format is unchanged at 40 bytes; only the comparison width changed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5554465078 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3510). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-29T19:50:37Z. --- ## Change `compute_token_output()` judged a slot-19 UAV view by comparing the guest record's width with `sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC)`. The record is `ViewRecord::uav_desc_bytes` (40 bytes) whatever the build's headers are, but the Agility SDK 1.620.2 header makes that struct 48 bytes. Under an Agility configuration every output token was therefore judged unmaterialized, `record_translated_dispatch()` refused the dispatch with *"an output token lacks a materialized explicit counterless UAV"*, and the UAV kept its sentinel fill. Compare against the record width and copy only the bytes the record carries into the zero-initialised view, so the check no longer depends on the build's headers. `docs/experiments/agility-compute-views.md` documents the same 40/48 difference for the SRV/UAV temporary description (#3223). This is the same trap on the output-token path. ## Verification Base: `upstream/main` `5b86df1d6`. The behaviour was measured on the fork's tree with `369143792` merged, using the agility configuration (`-DOFFSCREEN_AGILITY_620_DIR` and `-DOFFSCREEN_WARP_DIR`, Agility SDK 1.620.2, WARP 1.0.22) on an RTX 4070 Ti SUPER. Before: ``` startup_compute_indexed_atomic_uav_hardware ***Failed 4.39 sec raw: word 0 expected c5c5c5d1, read c5c5c5c5 x2w-draw compute UAV ... desc-bytes=40 ... result=an output token lacks a materialized explicit counterless UAV x2w-draw compute ... Dispatch(3, 2, 2) refused: an output token lacks a materialized explicit counterless UAV startup_compute_typed_buffer_uav_hardware ***Failed 5.92 sec view token: word 4 expected 3f800000, read c5c5c5c5 ``` After: ``` startup_compute_indexed_atomic_uav_hardware ... Passed 7.78 sec startup_compute_typed_buffer_uav_hardware .... Passed 20.29 sec 100% tests passed out of 2 ``` No in-box regression (default `dev` preset, no Agility): ``` ctest --preset dev -R '^(startup_compute_indexed_atomic_uav|startup_compute_typed_buffer_uav)' 100% tests passed out of 6 ``` All 15 hardware twins of the formerly-skipped capability set pass in the agility tree, with one correct skip: `bvh_wave64_hardware` (the adapter has no 64-lane waves). ## Evidence and follow-up Not measured by CI: both Windows jobs build the in-box configuration, where `sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC)` is already 40. The change is a no-op there, so a green check cannot confirm the Agility behaviour; the before/after above is the evidence. The fixture is the existing `tests/startup_compute_indexed_atomic_uav_check.py` and its typed-buffer twin. The guest record format is unchanged at 40 bytes; only the comparison width changed.
Not-Saii commented 2026-11-29 20:58:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T20:58:35Z.

Review: COMMENTED


Read the diff against main. It looks right to me: the output-token path was the last place that compared a view record against the build's own sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC). The input-texture UAV path (record_translated_dispatch, around d3d12_compute_dispatch.inl:952) and both SRV paths already compare against ViewRecord::*_desc_bytes, and the static_asserts at :793-794 guarantee the desktop struct is at least 40 bytes.

One small suggestion. The copy could use the same form as the sibling path:

if (record.desc_bytes >= ViewRecord::uav_desc_bytes)
    std::memcpy(&output.view, record.desc, ViewRecord::uav_desc_bytes);

ViewRecord::desc is 64 bytes, and note_view stores whatever desc_bytes the caller passed. If a record ever carried more than 40 bytes, min(desc_bytes, sizeof(view)) would copy up to 8 bytes past the guest's 40-byte layout into the 48-byte Agility struct. Copying exactly uav_desc_bytes keeps the 40-byte guest layout as the only input, matches :953, and drops the copy local. That case doesn't happen today as far as I can see, so it's a nit, not a blocker.

I agree CI can't show this, since both jobs build in-box headers where the change is a no-op. Your before/after on the Agility tree is the evidence.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6104774224 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3510#pullrequestreview-6104774224). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-29T20:58:35Z. **Review:** COMMENTED --- Read the diff against `main`. It looks right to me: the output-token path was the last place that compared a view record against the build's own `sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC)`. The input-texture UAV path (`record_translated_dispatch`, around `d3d12_compute_dispatch.inl:952`) and both SRV paths already compare against `ViewRecord::*_desc_bytes`, and the `static_assert`s at `:793-794` guarantee the desktop struct is at least 40 bytes. One small suggestion. The copy could use the same form as the sibling path: ```cpp if (record.desc_bytes >= ViewRecord::uav_desc_bytes) std::memcpy(&output.view, record.desc, ViewRecord::uav_desc_bytes); ``` `ViewRecord::desc` is 64 bytes, and `note_view` stores whatever `desc_bytes` the caller passed. If a record ever carried more than 40 bytes, `min(desc_bytes, sizeof(view))` would copy up to 8 bytes past the guest's 40-byte layout into the 48-byte Agility struct. Copying exactly `uav_desc_bytes` keeps the 40-byte guest layout as the only input, matches `:953`, and drops the `copy` local. That case doesn't happen today as far as I can see, so it's a nit, not a blocker. I agree CI can't show this, since both jobs build in-box headers where the change is a no-op. Your before/after on the Agility tree is the evidence. AI-assisted.
Leyukaka commented 2026-11-29 23:06:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T23:06:15Z.

Review: APPROVED


Read at 7c52ab9e (diff only). The copy and the gate in compute_token_output now both use ViewRecord::uav_desc_bytes (src/startup_stubs/d3d12_compute_dispatch.inl:701-702 and :711), the same form as the sibling path at :957-958 and as #3523. The copy stays in bounds: the static_assert at :799 keeps the desktop struct at least as wide as the record, and view{} (:675) leaves the tail zero.

As with #3523, no CI test can fail on revert: with the in-box header the struct is 40 bytes and the change is a no-op, so the evidence is the Agility before/after run in the description.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6105278144 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3510#pullrequestreview-6105278144). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T23:06:15Z. **Review:** APPROVED --- Read at 7c52ab9e (diff only). The copy and the gate in `compute_token_output` now both use `ViewRecord::uav_desc_bytes` (`src/startup_stubs/d3d12_compute_dispatch.inl:701-702` and `:711`), the same form as the sibling path at `:957-958` and as #3523. The copy stays in bounds: the `static_assert` at `:799` keeps the desktop struct at least as wide as the record, and `view{}` (`:675`) leaves the tail zero. As with #3523, no CI test can fail on revert: with the in-box header the struct is 40 bytes and the change is a no-op, so the evidence is the Agility before/after run in the description.
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
R0Y00/Xbox2Windows!3510
No description provided.