Repository navigation
runtime: preserve Compute texture views with Agility SDK headers - #3223
Conversation
|
LGTM - this fix correctly handles the Agility SDK header size mismatch. |
pigalot
left a comment
There was a problem hiding this comment.
Independently reviewed 9a01053f integrated over main fad97f47 (tree 78a938c8). The merge is clean (d3d12_xs_device.cpp auto-merged) and git diff --cached --check is 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 / CreateUnorderedAccessView get the member that matches the input/output branch. The static_asserts now only require the desktop type to hold the guest prefix, so a 48-byte Agility UAV no longer stops the build. The described_bytes change in d3d12_xs_device.cpp only names the existing 40-byte values, so with the default headers the change preserves behaviour.
What I ran. I built startup_stream_consumer and d3d12_xs_shim in dev and release, then ran:
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^startup_compute_dispatch_.*warp$'
python with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^startup_compute_dispatch_(texture|two_mips)_hardware$'textureandtwo_mipspass on WARP and on hardware, in Debug and Release/O2, with no skips.- Seven of the other eight
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_warp and two_mips_warp):
| Mutant | Result |
|---|---|
UAV described only when desc_bytes > 40 (the Agility failure: every 40-byte UAV treated as absent) |
killed by both |
| UAV prefix copy cut to 8 bytes | killed by both |
| UAV created with a null description | killed by both |
| SRV prefix copy cut to 8 bytes | killed by texture |
SRV described only when desc_bytes > 40 |
survives |
The 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 nonzero MostDetailedMip, 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_bytes treatment 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 fixtures and Run platform-independent Python checks on Linux pass on 9a01053f.
This reply was AI-assisted.
R0Y00
left a comment
There was a problem hiding this comment.
Independently tested 9a01053f over main fad97f47 (clean trial tree 78a938c8). I confirmed unmodified main fails with Agility 1.620.2 headers at the 40-byte assertion in record_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 plus shader_wave32_warp and native_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_warp exposes an equivalent check in resolve_pixel_uavs: a 40-byte guest record is refused as truncated view description (0x28) by the sizeof(title_view) check, leaving the first 16 expected UAV writes untouched. With a local-only change to validate and copy ViewRecord::uav_desc_bytes there, all four native_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.
|
Correction to my review: This reply was AI-assisted. |
KelboLive
left a comment
There was a problem hiding this comment.
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 ViewRecord is a nice improvement over raw bytes, making the code self-documenting and type-safe for the recreation path.
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.