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

Manually merged
github merged 3 commits from github-bot/gh-3510 into main 2026-11-30 02:22:18 +00:00 AGit
Owner

@⁠KelboLive on GitHub · 2026-11-29 19:50 UTC · original
KelboLive:compute/output-token-view-size → main · +7 −2 · 1 files · 3 commits · merged 2026-11-30 02:20 UTC

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 (#3225). 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.

**@⁠KelboLive** on GitHub · 2026-11-29 19:50 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3510) `KelboLive:compute/output-token-view-size` → `main` · +7 −2 · 1 files · 3 commits · merged 2026-11-30 02:20 UTC ## 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 (#3225). 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.
The guest record is ViewRecord::uav_desc_bytes wide, but the check used sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC): 40 bytes with the in-box header and 48 with the Agility SDK 1.620.2 header. Under Agility every output token was judged unmaterialized and the dispatch was refused, so the UAV kept the sentinel fill. Compare against the record width and copy only the bytes the record has.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 19:51:35 +00:00
Author
Owner

@⁠Not-Saii on GitHub · 2026-11-29 20:58 UTC · original · reviewed

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.

**@⁠Not-Saii** on GitHub · 2026-11-29 20:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3510#pullrequestreview-6104774224) · **reviewed** 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.
Review follow-up: the guard already holds desc_bytes to at least ViewRecord::uav_desc_bytes and the record is 64 bytes wide, so a fixed 40-byte copy needs no clamp. Same form as d3d12_compute_dispatch.inl:952.
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 23:06 UTC · original · approved these changes

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 #3525. 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 #3525, 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.

**@⁠Leyukaka** on GitHub · 2026-11-29 23:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3510#pullrequestreview-6105278144) · **approved these changes** 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 #3525. 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 #3525, 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.
github manually merged commit 3fa46b2036 into main 2026-11-30 02:22:18 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.