startup: exercise the pixel-history hook through the translated draw path #2843

Merged
stan495 merged 1 commit from upstream-pr/2851 into main 2026-11-26 13:59:07 +00:00
stan495 commented 2026-11-26 13:50:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-26T13:50:38Z.


Fixes #2843
Refs #2828

Exercises the runtime X2W_DRAW_DUMP_PIXEL / X2W_DRAW_DUMP_FRAME hooks (draw_dump_after and draw_dump_flush in src/startup_stubs/d3d12_draw.inl) end-to-end through the real translated draw path and queue_present.

Summary of changes

  • tests/startup_stream_draw.cpp: Add draw_pixel_history (X2W_TEST_PIXEL_HISTORY=1), which creates a guest-wrapped 8x4 DXGI_FORMAT_R8G8B8A8_UNORM render target and readback buffer (device slot 27), clears to opaque blue (0, 0, 255, 255), calls queue_present (queue slot 32) to advance frame_number to 1, records and submits a translated green (0, 255, 0, 255) triangle scissored to {2, 1, 6, 3}, calls queue_present again to flush draw_dump_flush(), and reads back the target bytes via guest CopyTextureRegion (list slot 16).
  • tests/startup_pixel_history_draw_check.py: Runs startup_stream_consumer + gfx2hlsl.py with X2W_D3D12_RENDER=1, X2W_DRAW_DUMP_FRAME=1, and X2W_DRAW_DUMP_DIR:
    1. Covered pixel X2W_DRAW_DUMP_PIXEL=3,2: checks target readback has blue (0, 0, 255, 255) at (0, 0) and green (0, 255, 0, 255) at (3, 2), and pixel_history.txt reports x2w-pixel-history 1 samples=1 with draw=1 frame=1 x=3 y=2, key=eb5897b13a530568 (non-zero, matching gfx2hlsl.pipeline_key), and rgba=0,255,0,255.
    2. Origin control X2W_DRAW_DUMP_PIXEL=0,0: verifies (0, 0) reports rgba=0,0,255,255 (distinct from (3, 2)).
    3. Off-target control X2W_DRAW_DUMP_PIXEL=8,4: verifies no sample is written (pixel_history.txt absent or empty).
    4. Full-dump control (no X2W_DRAW_DUMP_PIXEL): verifies no pixel_history.txt is written and draw_01_eb5897b13a530568_3.bmp is emitted.
  • tests/cmake/startup_pixel_history_draw.cmake: Registers startup_pixel_history_draw_warp and startup_pixel_history_draw_hardware.

Verification

  • Commit under test: 0c0065b0 (based on upstream/main 7538470e)
  • OS: Microsoft Windows NT 10.0.26200.0
  • Build: MSVC 19.44.35228.0 + Ninja (Release) + Windows SDK FXC 10.0.26100.0

CTest (startup_pixel_history*)

$env:XBOX2WINDOWS_ADAPTER = "7900"
ctest --test-dir out\wt-2843\out\build\release --no-tests=error -R "^startup_pixel_history" -V

Observed (4/4 Passed):

  • startup_pixel_history_warp (WARP Microsoft Basic Render Driver): Passed
  • startup_pixel_history_hardware (AMD Radeon RX 7900 XTX, vendor=0x1002 device=0x744c): Passed
  • startup_pixel_history_draw_warp (WARP Microsoft Basic Render Driver, driver=10.0.26100.9818):
    • warp covered (3,2): draw=1 frame=1 x=3 y=2 key=eb5897b13a530568 count=3 format=28 raw=ff00ff00 rgba=0,255,0,255
    • warp origin control (0,0): draw=1 frame=1 x=0 y=0 key=eb5897b13a530568 count=3 format=28 raw=ffff0000 rgba=0,0,255,255
    • warp off-target control (8,4): no sample
    • warp full-dump control: draw_01_eb5897b13a530568_3.bmp written, no pixel_history.txt
  • startup_pixel_history_draw_hardware (AMD Radeon RX 7900 XTX, driver=32.0.32029.2010):
    • hardware covered (3,2): draw=1 frame=1 x=3 y=2 key=eb5897b13a530568 count=3 format=28 raw=ff00ff00 rgba=0,255,0,255
    • hardware origin control (0,0): draw=1 frame=1 x=0 y=0 key=eb5897b13a530568 count=3 format=28 raw=ffff0000 rgba=0,0,255,255
    • hardware off-target control (8,4): no sample
    • hardware full-dump control: draw_01_eb5897b13a530568_3.bmp written, no pixel_history.txt

Debug-layer and static checks

$env:X2W_D3D12_DEBUG = "1"; $env:X2W_TEST_DEBUG_LAYER = "1"; $env:XBOX2WINDOWS_ADAPTER = "7900"
.\out\pe-env\Scripts\python.exe -B out\wt-2843\tests\startup_pixel_history_draw_check.py out\wt-2843\out\build\release\startup_stream_consumer.exe warp
.\out\pe-env\Scripts\python.exe -B out\wt-2843\tests\startup_pixel_history_draw_check.py out\wt-2843\out\build\release\startup_stream_consumer.exe hardware
.\out\pe-env\Scripts\python.exe -B out\wt-2843\tests\bidi_controls_check.py
.\out\pe-env\Scripts\python.exe -B out\wt-2843\tests\docs_links_check.py

Observed: x2w-d3d12 debug layer: 0x00000000 enabled cleanly across all runs on both WARP and AMD Radeon RX 7900 XTX; bidi_controls_check.py (Checked 2038 tracked source, script and build/CI files: no bidirectional controls.) and docs_links_check.py (Checked 27 Markdown files and 542 links.) exited 0.

Origin-box mutant check

Temporarily mutated src/startup_stubs/d3d12_draw.inl (const D3D12_BOX box{0, 0, 0, 1, 1, 1}; instead of {pixel.x, pixel.y, 0, pixel.x + 1, pixel.y + 1, 1}), rebuilt d3d12_xs_shim, and ran startup_pixel_history_draw_check.py ... warp. Observed failure (exit 1):
AssertionError: draw=1 frame=1 x=3 y=2 key=eb5897b13a530568 count=3 format=28 raw=ffff0000 rgba=0,0,255,255
Reverted src/startup_stubs/d3d12_draw.inl cleanly and rebuilt d3d12_xs_shim before re-running ctest (4/4 Passed).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6628086661 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2851). Originally posted by [stan495](https://github.com/stan495) on 2026-11-26T13:50:38Z. --- Fixes #2843 Refs #2828 Exercises the runtime `X2W_DRAW_DUMP_PIXEL` / `X2W_DRAW_DUMP_FRAME` hooks (`draw_dump_after` and `draw_dump_flush` in `src/startup_stubs/d3d12_draw.inl`) end-to-end through the real translated draw path and `queue_present`. ### Summary of changes - `tests/startup_stream_draw.cpp`: Add `draw_pixel_history` (`X2W_TEST_PIXEL_HISTORY=1`), which creates a guest-wrapped `8x4` `DXGI_FORMAT_R8G8B8A8_UNORM` render target and readback buffer (`device` slot `27`), clears to opaque blue `(0, 0, 255, 255)`, calls `queue_present` (queue slot `32`) to advance `frame_number` to `1`, records and submits a translated green `(0, 255, 0, 255)` triangle scissored to `{2, 1, 6, 3}`, calls `queue_present` again to flush `draw_dump_flush()`, and reads back the target bytes via guest `CopyTextureRegion` (`list` slot `16`). - `tests/startup_pixel_history_draw_check.py`: Runs `startup_stream_consumer` + `gfx2hlsl.py` with `X2W_D3D12_RENDER=1`, `X2W_DRAW_DUMP_FRAME=1`, and `X2W_DRAW_DUMP_DIR`: 1. Covered pixel `X2W_DRAW_DUMP_PIXEL=3,2`: checks target readback has blue `(0, 0, 255, 255)` at `(0, 0)` and green `(0, 255, 0, 255)` at `(3, 2)`, and `pixel_history.txt` reports `x2w-pixel-history 1 samples=1` with `draw=1 frame=1 x=3 y=2`, `key=eb5897b13a530568` (non-zero, matching `gfx2hlsl.pipeline_key`), and `rgba=0,255,0,255`. 2. Origin control `X2W_DRAW_DUMP_PIXEL=0,0`: verifies `(0, 0)` reports `rgba=0,0,255,255` (distinct from `(3, 2)`). 3. Off-target control `X2W_DRAW_DUMP_PIXEL=8,4`: verifies no sample is written (`pixel_history.txt` absent or empty). 4. Full-dump control (no `X2W_DRAW_DUMP_PIXEL`): verifies no `pixel_history.txt` is written and `draw_01_eb5897b13a530568_3.bmp` is emitted. - `tests/cmake/startup_pixel_history_draw.cmake`: Registers `startup_pixel_history_draw_warp` and `startup_pixel_history_draw_hardware`. ### Verification - Commit under test: `0c0065b0` (based on `upstream/main` `7538470e`) - OS: `Microsoft Windows NT 10.0.26200.0` - Build: `MSVC 19.44.35228.0` + Ninja (`Release`) + Windows SDK FXC `10.0.26100.0` #### CTest (`startup_pixel_history*`) ```powershell $env:XBOX2WINDOWS_ADAPTER = "7900" ctest --test-dir out\wt-2843\out\build\release --no-tests=error -R "^startup_pixel_history" -V ``` Observed (`4/4 Passed`): - `startup_pixel_history_warp` (WARP `Microsoft Basic Render Driver`): Passed - `startup_pixel_history_hardware` (`AMD Radeon RX 7900 XTX`, `vendor=0x1002 device=0x744c`): Passed - `startup_pixel_history_draw_warp` (WARP `Microsoft Basic Render Driver`, `driver=10.0.26100.9818`): - `warp covered (3,2): draw=1 frame=1 x=3 y=2 key=eb5897b13a530568 count=3 format=28 raw=ff00ff00 rgba=0,255,0,255` - `warp origin control (0,0): draw=1 frame=1 x=0 y=0 key=eb5897b13a530568 count=3 format=28 raw=ffff0000 rgba=0,0,255,255` - `warp off-target control (8,4): no sample` - `warp full-dump control: draw_01_eb5897b13a530568_3.bmp written, no pixel_history.txt` - `startup_pixel_history_draw_hardware` (`AMD Radeon RX 7900 XTX`, `driver=32.0.32029.2010`): - `hardware covered (3,2): draw=1 frame=1 x=3 y=2 key=eb5897b13a530568 count=3 format=28 raw=ff00ff00 rgba=0,255,0,255` - `hardware origin control (0,0): draw=1 frame=1 x=0 y=0 key=eb5897b13a530568 count=3 format=28 raw=ffff0000 rgba=0,0,255,255` - `hardware off-target control (8,4): no sample` - `hardware full-dump control: draw_01_eb5897b13a530568_3.bmp written, no pixel_history.txt` #### Debug-layer and static checks ```powershell $env:X2W_D3D12_DEBUG = "1"; $env:X2W_TEST_DEBUG_LAYER = "1"; $env:XBOX2WINDOWS_ADAPTER = "7900" .\out\pe-env\Scripts\python.exe -B out\wt-2843\tests\startup_pixel_history_draw_check.py out\wt-2843\out\build\release\startup_stream_consumer.exe warp .\out\pe-env\Scripts\python.exe -B out\wt-2843\tests\startup_pixel_history_draw_check.py out\wt-2843\out\build\release\startup_stream_consumer.exe hardware .\out\pe-env\Scripts\python.exe -B out\wt-2843\tests\bidi_controls_check.py .\out\pe-env\Scripts\python.exe -B out\wt-2843\tests\docs_links_check.py ``` Observed: `x2w-d3d12 debug layer: 0x00000000 enabled` cleanly across all runs on both WARP and `AMD Radeon RX 7900 XTX`; `bidi_controls_check.py` (`Checked 2038 tracked source, script and build/CI files: no bidirectional controls.`) and `docs_links_check.py` (`Checked 27 Markdown files and 542 links.`) exited `0`. #### Origin-box mutant check Temporarily mutated `src/startup_stubs/d3d12_draw.inl` (`const D3D12_BOX box{0, 0, 0, 1, 1, 1};` instead of `{pixel.x, pixel.y, 0, pixel.x + 1, pixel.y + 1, 1}`), rebuilt `d3d12_xs_shim`, and ran `startup_pixel_history_draw_check.py ... warp`. Observed failure (`exit 1`): `AssertionError: draw=1 frame=1 x=3 y=2 key=eb5897b13a530568 count=3 format=28 raw=ffff0000 rgba=0,0,255,255` Reverted `src/startup_stubs/d3d12_draw.inl` cleanly and rebuilt `d3d12_xs_shim` before re-running `ctest` (`4/4 Passed`).
upstream-sync closed this pull request 2026-11-26 14:00:34 +00:00
tedin7 commented 2026-11-26 14:00:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:58:46Z.

Review: COMMENTED


Win2025 WARP receipt for head 0c0065b0 (3 commits behind main, PR files untouched by them).

Review: the tests only; the hook code in src/startup_stubs/d3d12_draw.inl (draw_dump_after, draw_dump_flush) is unchanged. The new startup_pixel_history_draw_{warp,hardware} tests are registered next to the sibling startup_pixel_history_* tests from #2828. Covered texel, origin control, off-target control and full-dump control are all asserted on the real translated draw path.

Mutations of the code under test (Win2025 dev, startup_pixel_history_draw_warp), both made the new test FAIL:

  1. draw_dump_after returns early when a pixel is watched: AssertionError: missing ...\dump_covered\pixel_history.txt
  2. the copy box always reads texel (0,0): AssertionError: draw=1 frame=1 x=3 y=2 ... rgba=0,0,255,255

Unmutated head:

  • dev: ctest --preset dev -R '^startup_pixel_history' 4/4 passed (the two #2828 tests and the two new tests).
  • dev + release: ctest -R '^startup_pixel_history_draw' 2/2 passed in each (startup_pixel_history_draw_warp, startup_pixel_history_draw_hardware; the "hardware" test runs on WARP here).
  • Linux: git diff --check, tests/docs_links_check.py, tests/bidi_controls_check.py clean.

Real-GPU run not available (RunPod stopped). Test-only change, no startup claim.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6075380228 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2851#pullrequestreview-6075380228). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T13:58:46Z. **Review:** COMMENTED --- Win2025 WARP receipt for head 0c0065b0 (3 commits behind main, PR files untouched by them). Review: the tests only; the hook code in `src/startup_stubs/d3d12_draw.inl` (`draw_dump_after`, `draw_dump_flush`) is unchanged. The new `startup_pixel_history_draw_{warp,hardware}` tests are registered next to the sibling `startup_pixel_history_*` tests from #2828. Covered texel, origin control, off-target control and full-dump control are all asserted on the real translated draw path. Mutations of the code under test (Win2025 dev, `startup_pixel_history_draw_warp`), both made the new test FAIL: 1. `draw_dump_after` returns early when a pixel is watched: `AssertionError: missing ...\dump_covered\pixel_history.txt` 2. the copy box always reads texel (0,0): `AssertionError: draw=1 frame=1 x=3 y=2 ... rgba=0,0,255,255` Unmutated head: - dev: `ctest --preset dev -R '^startup_pixel_history' ` 4/4 passed (the two #2828 tests and the two new tests). - dev + release: `ctest -R '^startup_pixel_history_draw'` 2/2 passed in each (`startup_pixel_history_draw_warp`, `startup_pixel_history_draw_hardware`; the "hardware" test runs on WARP here). - Linux: `git diff --check`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py` clean. Real-GPU run not available (RunPod stopped). Test-only change, no startup claim. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 14:00:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:58:52Z.


Win2025 WARP receipt for head 0c0065b0.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 0c0065b0a825d86e4018562be2e6b3203df1b4bf:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target startup_stream_consumer -- -j 2): 5.86s (configure 0.00s)
    • Test (ctest --preset dev -R '^startup_pixel_history_draw' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (1.57s: startup_pixel_history_draw_hardware 1.30s, startup_pixel_history_draw_warp 1.32s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target startup_stream_consumer -- -j 2): 7.37s (configure 0.00s)
    • Test (ctest --preset release -R '^startup_pixel_history_draw' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (1.35s: startup_pixel_history_draw_hardware 1.10s, startup_pixel_history_draw_warp 1.13s)
  • sccache: 10/19 hits; wall 24.7s
    tested: 0c0065b0 via fetch (pull/2851/head, no patch)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7194105044 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2851#issuecomment-7194105044). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T13:58:52Z. --- Win2025 WARP receipt for head 0c0065b0. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `0c0065b0a825d86e4018562be2e6b3203df1b4bf`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target startup_stream_consumer -- -j 2`): `5.86s` (configure `0.00s`) - Test (`ctest --preset dev -R '^startup_pixel_history_draw' --parallel 2 --no-tests=error --output-on-failure`): **2/2 passed** (`1.57s`: `startup_pixel_history_draw_hardware` `1.30s`, `startup_pixel_history_draw_warp` `1.32s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target startup_stream_consumer -- -j 2`): `7.37s` (configure `0.00s`) - Test (`ctest --preset release -R '^startup_pixel_history_draw' --parallel 2 --no-tests=error --output-on-failure`): **2/2 passed** (`1.35s`: `startup_pixel_history_draw_hardware` `1.10s`, `startup_pixel_history_draw_warp` `1.13s`) - `sccache`: 10/19 hits; wall `24.7s` tested: 0c0065b0 via fetch (pull/2851/head, no patch) AI-assisted; commands listed were executed locally.
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!2843
No description provided.