runtime: preserve Compute texture views with Agility SDK headers #3223
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3223"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-27T23:21:51Z.
Change
Fixes #3165. Refs #3160. The translated Compute rebind path used a 40-byte temporary array and asserted that the desktop SDK's UAV descriptor was also 40 bytes. Agility 1.620.2 adds a larger union member, making the desktop UAV descriptor 48 bytes. The guest view record still supplies 40 bytes.
Use typed and aligned SRV/UAV storage for the desktop call. Check and copy the guest prefix into a zero-initialized desktop descriptor. The size-only prototype built with Agility but treated every explicit 40-byte UAV as absent. The existing fixtures then sent both 2D writes to mip 0 and refused the 3D view. The final patch preserves the selected mip and view dimensions.
Verification
Tested
9a01053fa67a00fc6642a83a05ddd4d545738f4abased on2e12dd8e4d7cd38bce5b4917cc2ea5653782a63f. Checked clean merges withmainat9345c21fand current #3049 and #3154 heads. Windows 1126300.10075, Visual Studio 2026 18.12.1, Windows SDK 10.0.26100, DXC 1.9.2602.17, RTX 4070 driver32.0.16.2124.10.0.26100.10068.1.0.22.0and RTX 4070. The two-mip test matched 1,280 halfwords and the swapped-view control changed 64 on both adapters. The 1D, 2D, array and 3D view fixtures passed.shader_wave32_warpand the stocknative_image_atomic_warppassed with the debug layer enabled. All seven atomic readbacks matched and the three GLC mutations were detected.Evidence and follow-up
The experiment note records the signed Microsoft package versions, absolute configuration paths, and the synthetic fixture coverage. The partial-wave ballot and shuffle observations are tracked in #3160 and #145.
I used Codex to prepare the change and ran verification locally.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T23:35:25Z.
LGTM - this fix correctly handles the Agility SDK header size mismatch.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T23:39:08Z.
Review: APPROVED
Independently reviewed
9a01053fintegrated overmainfad97f47(tree78a938c8). The merge is clean (d3d12_xs_device.cppauto-merged) andgit diff --cached --checkis clean.I read the dispatch changes against the two header layouts the PR describes. Both views keep their type in a union. Both are "described" when the record holds the 40-byte guest prefix. That prefix is copied into a zero-initialised desktop description, and
CreateShaderResourceView/CreateUnorderedAccessViewget the member that matches the input/output branch. Thestatic_asserts now only require the desktop type to hold the guest prefix, so a 48-byte Agility UAV no longer stops the build. Thedescribed_byteschange ind3d12_xs_device.cpponly names the existing 40-byte values, so with the default headers the change preserves behaviour.What I ran. I built
startup_stream_consumerandd3d12_xs_shimindevandrelease, then ran:textureandtwo_mipspass on WARP and on hardware, in Debug and Release/O2, with no skips.startup_compute_dispatch_*_warpneighbours pass.startup_compute_dispatch_native_warpfails in both presets withthe native route left ['revision.txt'] in the cache. It fails identically onmainfad97f47in this tree, so it is unrelated to this PR. CI passes it, so I take it to be local to my setup.Mutants (dev,
texture_warpandtwo_mips_warp):desc_bytes > 40(the Agility failure: every 40-byte UAV treated as absent)texturedesc_bytes > 40The surviving SRV mutant does not count against this PR. Its 2D input view matches the default view of its texture, so a null description gives the same result. The same mutant would survive on
main, and the SRV is 40 bytes under both headers, so the PR does not change that path's behaviour. A 2D SRV with a nonzeroMostDetailedMip, or a format different from the resource's, would cover it. That can be a separate change.Not run: the Agility SDK configuration (
-DOFFSCREEN_AGILITY_620_DIR). I don't have the SDK locally. The UAV threshold mutant above reproduces the reported failure under the default headers, and the fix removes it. The Agility build itself is unverified by me.Follow-up, non-blocking (unconfirmed without an Agility build): the draw path still compares the guest record with the desktop UAV size.
d3d12_draw.inl:2499hasconst bool described = record.desc_bytes >= sizeof(title_view);and then refuses with "truncated view description". With 48-byte Agility headers, every 40-byte UAV record bound in a draw table would be refused there. This is untouched by this PR and already onmain.d3d12_xs_device.cpp:5124/5130and:5166readsizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC)bytes from the guest description, which would be 8 bytes past the 40-byte prefix.The same
ViewRecord::uav_desc_bytestreatment would likely apply to both. It is a separate behaviour, so it belongs in its own PR.Verdict: approved on
9a01053f, with the Agility configuration not reproduced locally.Environment: AMD Ryzen 7 9800X3D, NVIDIA GeForce RTX 5090 driver 32.0.16.1088, WARP 10.0.26100.9818, Windows 11 25H2 build 26200.9974, Windows SDK headers (not Agility), MSVC 19.52.37029, Python 3.12.10. The tests report the debug layer enabled with no error messages.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on9a01053f.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T23:40:08Z.
Review: APPROVED
Independently tested
9a01053fovermainfad97f47(clean trial tree78a938c8). I confirmed unmodifiedmainfails with Agility 1.620.2 headers at the 40-byte assertion inrecord_translated_dispatch(MSVC C2607). This head builds and explicitly copies the 40-byte guest prefix into zero-initialized, correctly aligned desktop SRV/UAV descriptors. The intervening #3222 and #3178 merges leave these paths unchanged.Stock Debug and Release /O2 each passed 4/4 with
ctest --test-dir <build> --no-tests=error -j1 -V -R '^startup_compute_dispatch_(texture|two_mips)_(warp|hardware)$'. Agility 1.620.2 headers plus app-local WARP 1.0.22 passed the same four plusshader_wave32_warpandnative_image_atomic_warp(6/6). The two-mip controls matched 1,280 halfwords and changed 64 when swapped. Windows 11 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, inbox WARP 10.0.26100.9818 and app-local WARP 1.0.22.0; the texture fixtures enabled the debug layer with zero errors. Required hosted Windows passed.Separate graphics follow-up: now that the Agility build runs,
native_pixel_raw_uav_warpexposes an equivalent check inresolve_pixel_uavs: a 40-byte guest record is refused astruncated view description (0x28)by thesizeof(title_view)check, leaving the first 16 expected UAV writes untouched. With a local-only change to validate and copyViewRecord::uav_desc_bytesthere, all fournative_pixel_(raw_uav|atomic)_(warp|hardware)tests passed under Agility. Please keep that graphics change in a separate follow-up so this Compute fix stays focused; coordinate with the view-validation work in #3200.Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T23:40:28Z.
Correction to my review:
startup_compute_dispatch_native_warpfailing withthe native route left ['revision.txt'] in the cacheis not local to my setup. It has failed onmainsince #2820 (14d56502) and is reported there. It is still unrelated to this PR, which writes no new cache output.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T23:41:55Z.
Review: APPROVED
Review of PR #3223 — runtime: preserve Compute texture views with Agility SDK headers
Summary
This PR fixes an Agility SDK compatibility bug where UAV headers report 48 bytes instead of 40, causing valid 40-byte UAV records to be treated as absent and leading to incorrect view recreation (default mip 0 or refused explicit 3D views).
Changes reviewed
src/startup_stubs/d3d12_capture.inl: AddsViewRecord::srv_desc_bytes = 40anduav_desc_bytes = 40constants — captures the guest descriptor layout independent of desktop SDK headers.src/startup_stubs/d3d12_compute_dispatch.inl: Uses new constants instead of hardcodedsizeof()checks; changesunsigned char desc[40]to a typed union of SRV/UAV structs; updates all memcpy/reinterpret_cast calls accordingly.src/startup_stubs/d3d12_xs_device.cpp: Uses the new constants in view slot function.docs/experiments/agility-compute-views.md: New documentation with issue explanation, reproduction steps, and test results across both SDK header configurations.Assessment
The approach of using fixed-size constants matching the guest descriptor layout (rather than desktop header sizes) is correct — it ensures captured data is always interpreted consistently regardless of which SDK headers build the shim. The union type change in
ViewRecordis a nice improvement over raw bytes, making the code self-documenting and type-safe for the recreation path.Verdict: Approve