gpu: explicitly clear the pixel-history fixture target #2860

Merged
chadhyatt merged 1 commit from upstream-pr/2868 into main 2026-11-27 03:01:12 +00:00
chadhyatt commented 2026-11-26 15:01:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chadhyatt on 2026-11-26T15:01:35Z.


AI-assisted backport patch from x2w-microlift.

The optimized clear value passed to CreateCommittedResource does not initialize the texture contents (API contract). The fixture currently assumes black initial pixels. Clear explicitly once before each independent sequence and keep the existing readback/history oracle unchanged. Refs #1268; follows #2828, separate from #2851.

Verification at bd84fbff20 on macOS ARM64: Clang x64 Windows cross -std=c++17 -fms-extensions -fsyntax-only tests/startup_pixel_history.cpp with MinGW headers passed. Windows MSVC and GPU execution not available; relevant native check: cmake --build --preset dev --target startup_pixel_history and ctest --preset dev --no-tests=error -R "^startup_pixel_history_(warp|hardware)$" -V.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5512377237 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2868). Originally posted by [chadhyatt](https://github.com/chadhyatt) on 2026-11-26T15:01:35Z. --- AI-assisted backport patch from x2w-microlift. The optimized clear value passed to CreateCommittedResource does not initialize the texture contents ([API contract](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-createcommittedresource)). The fixture currently assumes black initial pixels. Clear explicitly once before each independent sequence and keep the existing readback/history oracle unchanged. Refs #1268; follows #2828, separate from #2851. Verification at `bd84fbff20` on macOS ARM64: Clang x64 Windows cross `-std=c++17 -fms-extensions -fsyntax-only tests/startup_pixel_history.cpp` with MinGW headers passed. Windows MSVC and GPU execution not available; relevant native check: `cmake --build --preset dev --target startup_pixel_history` and `ctest --preset dev --no-tests=error -R "^startup_pixel_history_(warp|hardware)$" -V`.
thepatrickworld commented 2026-11-27 01:20:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-27T01:20:24Z.


Independent Windows/AMD result on bd84fbff — measurements only, not a code change.

Environment

Windows 11, build 26200.9974. MSVC toolset 14.44.35207 (BuildTools 2022). ctest -N reports Total Tests: 2442. D3D12 debug layer not installed (d3d12SDKLayers.dll absent from System32 and from the Windows Kits bin tree, no Tools.Graphics.DirectX capability package), so this run carries no validation output. Adapters: WARP Microsoft Basic Render Driver (1414:008c) and AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010). The fixture compiles its HLSL through D3DCompile, not DXC.

Commands

cmake --preset dev "-DINTAKE_PYTHON=C:/Users/walde/Downloads/x2w-pr641/out/pe-env/Scripts/python.exe"
cmake --build --preset dev --target startup_pixel_history
ctest --preset dev --no-tests=error -R "^startup_pixel_history_(warp|hardware)$" -V

Observed

Head, three consecutive runs, both entries pass on both adapters. The fixture's own lines are the same in all six runs (three on the base, three on the head); only ctest's per-test durations vary between runs:

adapter=Microsoft Basic Render Driver vendor=0x1414 device=0x8c
draw 1: draw=1 frame=7 x=1 y=1 key=1111111111111111 count=3 format=28 raw=00000000 rgba=0,0,0,0
draw 2: draw=2 frame=7 x=1 y=1 key=2222222222222222 count=3 format=28 raw=ff00ff00 rgba=0,255,0,255
draw 3: draw=3 frame=7 x=1 y=1 key=3333333333333333 count=3 format=28 raw=ff00ff00 rgba=0,255,0,255
control without draw 2: draw=3 frame=7 x=1 y=1 key=3333333333333333 count=3 format=28 raw=00000000 rgba=0,0,0,0
checks: first_black=1 second_green=1 third_green=1 second_key=1 no_second=1 control_black=1
PASS: the history names draw 2; without it the texel stays black
adapter=AMD Radeon RX 9070 XT vendor=0x1002 device=0x7550
the same six lines, then
100% tests passed out of 2

The base commit b505c32b passes the same two entries, three runs out of three, with the same fixture lines. So on this machine the PR repairs no observable failure: it removes a dependency.

Controls (mine, not in the PR)

  • Base, both D3D12_CLEAR_VALUE initialisers (tests/startup_pixel_history.cpp:101 and :125) set to opaque magenta {1,0,1,1}: still raw=00000000 at draw 1 and in the control, PASS on both adapters. On these adapters the optimised clear value does not show up in the readback, so the black the old fixture watched was not produced by the field it declared.
  • Head, ClearRenderTargetView(target.rtv, black, ...) (:120) changed to magenta: both entries fail on both adapters, draw 1: ... raw=ffff00ff and control without draw 2: ... raw=ffff00ff, first_black=0 ... control_black=0. Magenta is the colour of no draw, so that word cannot come from one. Each mutation is traced in the logs (sha256 before and after, the edited line, git status --porcelain --untracked-files=no showing M tests/startup_pixel_history.cpp), and the file was restored to 0a4203ac… afterwards.

What this leaves

Nothing reads the target between the clear and draw 1, so the added clear is only observed after a draw — and with black a no-op clear is indistinguishable from memory that already reads zero, which is what this allocation does on both adapters. The control sequence is the only place where the clear is observable, and only because draw 2 would otherwise leave green there. Clearing to a colour no draw uses and asserting the texel straight after clear_target would turn the dependency into a guard; the copy and decode path is already there in record_draw.

CI

startup_pixel_history is absent from the pr configure preset's target list, so on a pull_request this file is not even compiled, and no job names the entry. After merge, the dev sweep runs ctest --preset dev -E '_hardware$' (windows.yml:494): _warp runs, _hardware never.

Limits

One machine, one hardware adapter plus WARP, no debug layer. The mutation shows the declared value is not what the readback sees; it does not identify the cause of the zero (a zeroed allocation, or a driver keeping the value behind the fast-clear path — either way the old fixture's green stays uncontrolled). The fixture exercises two sequences on one 4x4 R8G8B8A8_UNORM target with one texel copied: no blending, depth, MSAA, mip, UAV, and no cross-resource aliasing of that allocation. The sample metadata (frame=7, count=3, key) is filled by the test, so the GPU supplies the RGBA bytes only. The hardware entry returns 77 when no non-software adapter is found, so "passes" always means a GPU was present.

AI-assisted; runs executed on the machine above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7207208795 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2868#issuecomment-7207208795). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-27T01:20:24Z. --- **Independent Windows/AMD result on `bd84fbff` — measurements only, not a code change.** ### Environment Windows 11, build 26200.9974. MSVC toolset `14.44.35207` (BuildTools 2022). `ctest -N` reports `Total Tests: 2442`. D3D12 debug layer not installed (`d3d12SDKLayers.dll` absent from `System32` and from the Windows Kits `bin` tree, no `Tools.Graphics.DirectX` capability package), so this run carries no validation output. Adapters: WARP `Microsoft Basic Render Driver` (`1414:008c`) and `AMD Radeon RX 9070 XT` (`1002:7550`, driver `32.0.32029.2010`). The fixture compiles its HLSL through `D3DCompile`, not DXC. ### Commands ``` cmake --preset dev "-DINTAKE_PYTHON=C:/Users/walde/Downloads/x2w-pr641/out/pe-env/Scripts/python.exe" cmake --build --preset dev --target startup_pixel_history ctest --preset dev --no-tests=error -R "^startup_pixel_history_(warp|hardware)$" -V ``` ### Observed Head, three consecutive runs, both entries pass on both adapters. The fixture's own lines are the same in all six runs (three on the base, three on the head); only ctest's per-test durations vary between runs: ``` adapter=Microsoft Basic Render Driver vendor=0x1414 device=0x8c draw 1: draw=1 frame=7 x=1 y=1 key=1111111111111111 count=3 format=28 raw=00000000 rgba=0,0,0,0 draw 2: draw=2 frame=7 x=1 y=1 key=2222222222222222 count=3 format=28 raw=ff00ff00 rgba=0,255,0,255 draw 3: draw=3 frame=7 x=1 y=1 key=3333333333333333 count=3 format=28 raw=ff00ff00 rgba=0,255,0,255 control without draw 2: draw=3 frame=7 x=1 y=1 key=3333333333333333 count=3 format=28 raw=00000000 rgba=0,0,0,0 checks: first_black=1 second_green=1 third_green=1 second_key=1 no_second=1 control_black=1 PASS: the history names draw 2; without it the texel stays black adapter=AMD Radeon RX 9070 XT vendor=0x1002 device=0x7550 the same six lines, then 100% tests passed out of 2 ``` The base commit `b505c32b` passes the same two entries, three runs out of three, with the same fixture lines. So on this machine the PR repairs no observable failure: it removes a dependency. ### Controls (mine, not in the PR) - Base, both `D3D12_CLEAR_VALUE` initialisers (`tests/startup_pixel_history.cpp:101` and `:125`) set to opaque magenta `{1,0,1,1}`: still `raw=00000000` at draw 1 and in the control, PASS on both adapters. On these adapters the optimised clear value does not show up in the readback, so the black the old fixture watched was not produced by the field it declared. - Head, `ClearRenderTargetView(target.rtv, black, ...)` (`:120`) changed to magenta: both entries fail on both adapters, `draw 1: ... raw=ffff00ff` and `control without draw 2: ... raw=ffff00ff`, `first_black=0 ... control_black=0`. Magenta is the colour of no draw, so that word cannot come from one. Each mutation is traced in the logs (sha256 before and after, the edited line, `git status --porcelain --untracked-files=no` showing ` M tests/startup_pixel_history.cpp`), and the file was restored to `0a4203ac…` afterwards. ### What this leaves Nothing reads the target between the clear and draw 1, so the added clear is only observed after a draw — and with `black` a no-op clear is indistinguishable from memory that already reads zero, which is what this allocation does on both adapters. The control sequence is the only place where the clear is observable, and only because draw 2 would otherwise leave green there. Clearing to a colour no draw uses and asserting the texel straight after `clear_target` would turn the dependency into a guard; the copy and decode path is already there in `record_draw`. ### CI `startup_pixel_history` is absent from the `pr` configure preset's target list, so on a `pull_request` this file is not even compiled, and no job names the entry. After merge, the dev sweep runs `ctest --preset dev -E '_hardware$'` (`windows.yml:494`): `_warp` runs, `_hardware` never. ### Limits One machine, one hardware adapter plus WARP, no debug layer. The mutation shows the declared value is not what the readback sees; it does not identify the cause of the zero (a zeroed allocation, or a driver keeping the value behind the fast-clear path — either way the old fixture's green stays uncontrolled). The fixture exercises two sequences on one 4x4 `R8G8B8A8_UNORM` target with one texel copied: no blending, depth, MSAA, mip, UAV, and no cross-resource aliasing of that allocation. The sample metadata (`frame=7`, `count=3`, `key`) is filled by the test, so the GPU supplies the RGBA bytes only. The hardware entry returns 77 when no non-software adapter is found, so "passes" always means a GPU was present. _AI-assisted; runs executed on the machine above._
R0Y00 commented 2026-11-27 03:00:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T03:00:55Z.

Review: APPROVED


Reviewed bd84fbff208b31e6af8e13c57c94a54f20533692. Both explicit clears are submitted and fence-complete before the next sequence, with the target back in render-target state. I independently built the exact-head fixture and its headers with MSVC (cl /EHsc /std:c++17, separately /Od /Zi and /O2) and ran pixel_history.exe warp and pixel_history.exe hardware for both builds. All four runs passed on Windows 11 build 26200.9974, Microsoft Basic Render Driver 10.0.26100.9818 and RTX 4060 Laptop driver 32.0.16.1656. The first and control samples were 00000000, and draws 2 and 3 were ff00ff00. The fixture does not enable the D3D12 debug layer. The independent AMD report also demonstrates that a magenta explicit clear changes the readback, and documents the remaining limits. The required Windows check passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6082908513 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2868#pullrequestreview-6082908513). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T03:00:55Z. **Review:** APPROVED --- Reviewed `bd84fbff208b31e6af8e13c57c94a54f20533692`. Both explicit clears are submitted and fence-complete before the next sequence, with the target back in render-target state. I independently built the exact-head fixture and its headers with MSVC (`cl /EHsc /std:c++17`, separately `/Od /Zi` and `/O2`) and ran `pixel_history.exe warp` and `pixel_history.exe hardware` for both builds. All four runs passed on Windows 11 build 26200.9974, Microsoft Basic Render Driver 10.0.26100.9818 and RTX 4060 Laptop driver 32.0.16.1656. The first and control samples were `00000000`, and draws 2 and 3 were `ff00ff00`. The fixture does not enable the D3D12 debug layer. The independent AMD report also demonstrates that a magenta explicit clear changes the readback, and documents the remaining limits. The required Windows check passed.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2860
No description provided.