Repository navigation
pixel uav: size the view record against its own width, not the desktop struct - #3523
Conversation
…p struct resolve_pixel_uavs() ordered its 'described' test by sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC). The guest record is ViewRecord::uav_desc_bytes wide, so with the Agility SDK 1.620.2 header, where that struct is 48 bytes, every described pixel UAV view read as truncated and every pixel UAV draw was refused: the texture kept its previous contents and the refusals the fixture expects were never logged.
Leyukaka
left a comment
There was a problem hiding this comment.
Read at 2913c07 (diff only, not built here). The fix is right: a described UAV record is always 40 bytes (ViewRecord::uav_desc_bytes, src/startup_stubs/d3d12_capture.inl:56, written with that width at d3d12_xs_device.cpp:5456-5457), so comparing desc_bytes with the sizeof of a 48-byte desktop struct rejected every described view. The copy is now 40 bytes into a zero-initialised struct, guarded by the static_assert; it is the same pattern as d3d12_compute_dispatch.inl:952-953.
With the in-box header sizeof is already 40, so nothing changes there. CI builds only that configuration (no Agility build in windows.yml), so it would not fail on a revert; the proof is the before/after in the description.
Minor: the follow-up line numbers in the description point elsewhere on main 2ff74a6a. In src/startup_stubs/d3d12_xs_device.cpp the 3D/1D UAV checks are at 5507/5509 and 5513/5515, and the desc_copy width is at 5549-5553.
Approving.
Not-Saii
left a comment
There was a problem hiding this comment.
Reviewed at head 2913c076c3 (base 2ff74a6ac3). Read statically, then built and run in an isolated, networkless Windows Sandbox in the Agility configuration. Verdict: COMMENT. The code change looks right and the fixtures pass with it. My revert control did not rebuild, though (details below), so this run does not show on its own that these tests tell the fix from base. No code changes requested.
Code
The fix is correct. Slot-19 records are only ever written at ViewRecord::uav_desc_bytes = 40 (note_view via d3d12_xs_device.cpp:5456-5459; content tokens never carry slot 19, view_content_token.h:45-75). So desc_bytes is 0 or 40, and with the 48-byte Agility struct the old comparison rejected every described view. The 40-byte copy fits record.desc[64], the tail stays zero, and the static_assert rules out an overrun. With in-box headers the generated code is unchanged. I agree with the existing approval on these points and won't repeat its line-number note.
Findings
SHOULD 1. The body says the compute path "already carries the fix" in compute_token_output(). On main it does not.
d3d12_compute_dispatch.inl:697 and :706 still compare against sizeof(output.view) at 2ff74a6a. That site is fixed by your open #3510. On main, the record-width pattern exists only at d3d12_compute_dispatch.inl:952-953. Please correct the sentence and link #3510.
SHOULD 2. #3510 and this PR fix the same 40/48 problem with two slightly different copies.
#3510 copies min(desc_bytes, sizeof) after a >= uav_desc_bytes check. This PR copies exactly uav_desc_bytes under a static_assert. The files differ, so there is no conflict. You already suggest a shared helper. Whichever of the two lands second could add it: one function that holds the width check, the copy and the static_assert, used at both sites. Not blocking here.
SHOULD 3. Evidence fields (AGENTS.md "Evidence").
The body gives the base, adapter, driver, debug-layer status, before/after and the in-box command. It is missing the Windows build, the exact configure and ctest lines for the Agility tree (only the cache variable names are given), and the head commit the after-run used.
NIT 1. The d3d12_xs_device.cpp follow-up sites are a read-size problem, not only "the same assumption".
At :5506-5517 and :5550 the code reads sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC) bytes from the guest pointer. Under the Agility headers that is 48 bytes from a 40-byte guest description. readable() can then fail at a page end, and the 8 bytes past the guest struct reach the driver through desc_copy. Worth saying in the follow-up.
NIT 2. No configuration that CI builds can catch a revert.
Both Windows jobs use in-box headers, and the static_assert only guards the overrun direction. Consider listing this site, and #3510's, in docs/experiments/agility-compute-views.md. That note already documents the 40/48 difference and the Agility reproduction steps.
What each test proves
startup_pixel_uav_{warp,hardware}: the translated pixel-stage image store, bound from the guest table entry. It reads back the written texel and checks every other word of four textures, plus each refusal by its reason. This is the direct test ofresolve_pixel_uavs().native_pixel_atomic_{warp,hardware}andnative_pixel_raw_uav_{warp,hardware}: the raw-UAV branch. It needsdescribed == true(d3d12_draw.inl:2855), so a rejected description refuses the draw.startup_indirect_translated_targets_{warp,hardware}: a nearby test, run to check for regressions.
CI
Run 46317165966 at 2913c076: the Windows pr preset passed 82/82, the Linux Python checks pass, and the gfx1013 assemble job passes. The /O2 job was skipped. The pr preset filter includes none of the tests above. CI only shows that the change compiles with in-box headers, where it is a no-op.
Sandbox run
- Commit:
2913c076c38d28a232f54fd567e620a600dcbb7e, exported withgit archiveand mapped read-only. Networking disabled (an outbound request failed inside the sandbox). - Configure:
cmake --preset dev -DX2W_WITH_OPUS=OFF -DINTAKE_PYTHON=<venv python> -DOFFSCREEN_AGILITY_620_DIR=<Agility SDK 1.620.2 dir with sdk.nupkg> -DOFFSCREEN_WARP_DIR=<WARP 1.0.22 x64 dir> - Build:
cmake --build --preset dev --target d3d12_xs_shim startup_stream_consumer compile_dxil startup_indirect_draw_indexed - Test:
ctest --preset dev --no-tests=error --output-on-failure -V -R '^(startup_pixel_uav|native_pixel_atomic|native_pixel_raw_uav|startup_indirect_translated_targets)_(warp|hardware)$' - Environment: Windows 11 Enterprise 10.0.26100 (sandbox; host build 26300). Hardware adapter: NVIDIA GeForce RTX 4090 through the sandbox vGPU, driver 32.0.16.1088 as the fixture reports it. Software adapter: WARP 1.0.22 (app-local). Debug layer: unavailable/absent in every fixture's output.
- Result at head: 8 passed, 0 failed, 0 skipped (77). That covers
startup_pixel_uav_{warp,hardware},native_pixel_atomic_{warp,hardware},native_pixel_raw_uav_{warp,hardware}andstartup_indirect_translated_targets_{warp,hardware}.arr-ok.lastdrew on both adapters, and no log contains "truncated view description".startup_indirect_translated_targets_hardwarepassed here, so I could not reproduce the unrelated failure you report for it.
Mutation: not exercised
I put the base d3d12_draw.inl (the exact revert of this PR) into a scratch copy and rebuilt. My copy step kept the base file's older timestamp, so ninja did not recompile d3d12_xs_device.cpp. The "mutant" leg therefore re-ran the head binary and passed 8/8. That is not a catch, and not evidence against one either. The run above therefore shows that the fixtures pass with the fix in the Agility configuration. It does not independently show that they fail without it. Your before/after log in the description is still the only evidence of that. A rerun with the timestamp fixed would settle it, and I can follow up with it.
|
Body updated for the three SHOULDs and both NITs: the compute sentence now points at #3510 instead of claiming \main\ already carries it, the Windows build, the exact configure and \ctest\ lines and the measured head commit are in, and the \d3d12_xs_device.cpp\ follow-up now says it is a read-size problem (48 bytes from a 40-byte guest description reaching \desc_copy) rather than just the same assumption. I also recorded your sandbox result as independent confirmation. No code changes, as you noted. Thanks for building it in the Agility configuration — your 8/8 is better evidence than my two-test slice. |
Not-Saii
left a comment
There was a problem hiding this comment.
Follow-up at the same head 2913c076c3 (base 2ff74a6ac3). I reran the sandbox with a working revert control. This section replaces the "Mutation: not exercised" section of my earlier review. The revert is now caught, so I'm approving. The earlier SHOULD/NIT items (body wording about #3510, a shared helper with #3510, missing evidence fields, the read-size note for the d3d12_xs_device.cpp follow-up sites) still apply. None of them block.
Rerun
- Commit:
2913c076c38d28a232f54fd567e620a600dcbb7e, exported withgit archiveand mapped read-only into a Windows Sandbox. Networking disabled (an outbound request failed inside the sandbox). - Configure:
cmake --preset dev -DX2W_WITH_OPUS=OFF -DOFFSCREEN_AGILITY_620_DIR=<Agility SDK 1.620.2 dir with sdk.nupkg> -DOFFSCREEN_WARP_DIR=<WARP 1.0.22 x64 dir>. That is the configuration where the 48-byte UAV description exists. Fixtures ran withX2W_D3D12_DEBUG=1. - Build:
cmake --build --preset dev --target d3d12_xs_shim startup_stream_consumer compile_dxil startup_indirect_draw_indexed - Test:
ctest --preset dev --no-tests=error --output-on-failure -V -R '^(startup_pixel_uav|native_pixel_atomic|native_pixel_raw_uav|startup_indirect_translated_targets)_(warp|hardware)$' - Environment: Windows 11 Enterprise 10.0.26100 (sandbox; host build 26300). Hardware adapter: NVIDIA GeForce RTX 4090 through the sandbox vGPU, driver 32.0.16.1088 as the fixtures report it. Software adapter: WARP 1.0.22 (app-local), reported as 1.0.22.0. Debug layer: on. The fixtures report "debug layer: on, errors: 0", and
D3D12GetDebugInterfacereturned0x00000000.
| Leg | Passed | Failed | Skipped (77) |
|---|---|---|---|
| head | 8 | 0 | 0 |
revert (base d3d12_draw.inl) |
2 | 6 | 0 |
| restored head | 8 | 0 | 0 |
Revert control: caught
The mutant is the base d3d12_draw.inl, which is the exact revert of this PR, applied to a scratch copy. The rebuild was real. The mutant build log shows Building CXX object CMakeFiles\d3d12_xs_shim.dir\src\startup_stubs\d3d12_xs_device.cpp.obj and then Linking CXX shared library d3d12_xs.dll. The restored build shows the same two steps. (My harness also has an automatic output-timestamp check. It only looked at the executables, not the shim DLL, so it wrongly logged "no output changed". The build log lines above are the direct evidence.)
These tests failed on the revert:
startup_pixel_uav_warpstartup_pixel_uav_hardwarenative_pixel_atomic_warpnative_pixel_atomic_hardwarenative_pixel_raw_uav_warpnative_pixel_raw_uav_hardware
The ctest log has 56 occurrences of uav 0 refused: truncated view description (0x28); draw not translated, and the head and restored logs have none. 0x28 = 40, the record width, as the description says. For the raw-UAV tests, the expected words were never written, because the draw was refused. startup_indirect_translated_targets_{warp,hardware} passed in all three legs, so this run shows no regression there. The _hardware failure that the description reports for the Agility tree also did not reproduce here.
So in this configuration, these six tests tell the fix apart from base on both WARP and hardware, with the debug layer on and no debug-layer errors. CI still cannot show this: the pr preset contains none of these tests, and both Windows jobs use in-box headers, where the change is a no-op.
Change
resolve_pixel_uavs()decided whether a slot-19 view record carries a description by comparing therecord's width with
sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC). The record isViewRecord::uav_desc_bytes(40 bytes) whatever the build's headers are — slot-19 records are only everwritten at that width — but the Agility SDK 1.620.2 header makes that struct 48 bytes.
With that header every described pixel UAV view was judged truncated, the function returned
"truncated view description", and every pixel UAV draw was refused: the target kept its previous
contents, and the refusals the fixture expects were never reached.
Order the check and the copy by the record's own width, zero-initialising the tail the record does not
carry.
Verification
Base
upstream/main2ff74a6ac. Head measured:252cb1eddon the fork's main, cherry-picked hereunchanged as
2913c076c. Windows 10.0.26200, MSVC 14.44.35207, NVIDIA GeForce RTX 4070 Ti SUPER,driver 32.0.16.2101, debug layer on.
Agility configuration (Agility SDK 1.620.2, WARP 1.0.22):
The cause was measured with a log diff of one failing case (
arr-ok.last), normalised to stripaddresses:
0x28is 40: the record's own width.Six tests fail without this change and pass with it — three on hardware and three on the Agility
WARP — in the same configuration.
Hardware:
Agility WARP:
In-box tree (default
devpreset, no Agility), no regression:Independently confirmed by Not-Saii in a networkless Windows Sandbox in the Agility configuration:
8 passed, 0 failed, 0 skipped across the six tests above plus
startup_indirect_translated_targets_{warp,hardware}.Evidence and follow-up
CI cannot confirm this change: both Windows jobs build the in-box configuration, where
sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC)is already 40 and the change is a no-op. Theprpresetcontains none of these tests. The before/after above and the sandbox run are the evidence.
Same problem, still open on
main, in the compute path.compute_token_output()compares againstsizeof(output.view)atd3d12_compute_dispatch.inl:697and:706, so it rejects described outputtokens under the Agility headers. That site is fixed by #3510, not here; the only record-width site
already on
mainisd3d12_compute_dispatch.inl:952-953.Two remaining sites in
d3d12_xs_device.cppare a read-size problem, not just the same assumption.Around
:5326-5344and:5368the code readssizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC)bytes from theguest description pointer. Under the Agility headers that is 48 bytes from a 40-byte guest description:
readable()can fail at a page end, and the 8 bytes past the record reach the driver throughdesc_copy. No failure has been observed there yet, so I have not changed it.Shared helper. #3510 and this PR copy the record width in slightly different forms in different files,
so there is no conflict; whichever lands second could hold the width check, the copy and the
static_assertin one function used at both sites.Both this site and #3510's could also be listed in
docs/experiments/agility-compute-views.md, whichalready documents the 40/48 difference and the Agility reproduction steps, so a reverted fix is visible
from a configuration CI does not build.