Repository navigation
compute: size an output token's view against the record, not the desktop header - #3510
Conversation
…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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
Change
compute_token_output()judged a slot-19 UAV view by comparing the guest record's width withsizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC). The record isViewRecord::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 materializedexplicit 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.mddocuments the same 40/48 difference for the SRV/UAVtemporary description (#3223). This is the same trap on the output-token path.
Verification
Base:
upstream/main5b86df1d6. The behaviour was measured on the fork's tree with369143792merged, using the agility configuration (
-DOFFSCREEN_AGILITY_620_DIRand-DOFFSCREEN_WARP_DIR,Agility SDK 1.620.2, WARP 1.0.22) on an RTX 4070 Ti SUPER.
Before:
After:
No in-box regression (default
devpreset, no Agility):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 greencheck cannot confirm the Agility behaviour; the before/after above is the evidence.
The fixture is the existing
tests/startup_compute_indexed_atomic_uav_check.pyand its typed-buffertwin. The guest record format is unchanged at 40 bytes; only the comparison width changed.