Skip to content

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

Merged
R0Y00 merged 3 commits into
R0Y00:mainfrom
KelboLive:compute/output-token-view-size
Nov 30, 2026
Merged

R0Y00 merged 3 commits into
R0Y00:mainfrom
KelboLive:compute/output-token-view-size

Conversation

@KelboLive

Copy link
Copy Markdown
Contributor

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.

…top header

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.

@Not-Saii Not-Saii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

@Leyukaka Leyukaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read at 7c52ab9 (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.

@R0Y00
R0Y00 merged commit 3fa46b2 into R0Y00:main Nov 30, 2026
5 checks passed
@KelboLive
KelboLive deleted the compute/output-token-view-size branch November 30, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants