startup: record a bounded per-draw texel history (Part of #1268) #2820

Merged
lambirou merged 3 commits from upstream-pr/2828 into main 2026-11-26 13:18:06 +00:00
lambirou commented 2026-11-26 12:18:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-26T12:18:17Z.


X2W_DRAW_DUMP_FRAME copies the whole target after each translated draw, up to 48 times, so a black
frame shows that a pixel is black but not which draw last wrote it. This adds a bounded per-texel
history for the same frame.

X2W_DRAW_DUMP_PIXEL=<x>,<y> (with X2W_DRAW_DUMP_FRAME) makes each recorded copy cover one
texel of render target 0. The present writes pixel_history.txt in X2W_DRAW_DUMP_DIR, one line per
translated draw:

draw=2 frame=1500 x=1 y=1 key=2222222222222222 count=3 format=28 raw=ff00ff00 rgba=0,255,0,255

draw is the copy ordinal, frame is the frame that recorded it, key is the translated manifest key, and rgba is decoded
for R8G8B8A8/B8G8R8A8 UNORM or sRGB. The 48-copy bound is unchanged. Other formats keep the full
dump behaviour.

startup_pixel_history is a source-built 4x4 target with three draws. The first and third are
scissored to the top-left texel; only the second covers the watched texel (1, 1). The report must
name draw 2 with its key and green value, and the control that omits draw 2 must leave the texel
black at draw 3.

startup_pixel_history_warp      Passed
startup_pixel_history_hardware  Passed  (AMD Radeon RX 9060 XT, 0x7590)

d3d12_xs_shim builds in the dev preset; docs_links_check.py (27 files, 541 links) and
bidi_controls_check.py (2,036 files) pass, as does git diff --check.

This is part of #1268. The format is limited to the 8-bit four-channel targets the full dump already
supports; the runtime copy is exercised by the same CopyTextureRegion path as the full dump.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5509883156 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2828). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-26T12:18:17Z. --- `X2W_DRAW_DUMP_FRAME` copies the whole target after each translated draw, up to 48 times, so a black frame shows that a pixel is black but not which draw last wrote it. This adds a bounded per-texel history for the same frame. `X2W_DRAW_DUMP_PIXEL=<x>,<y>` (with `X2W_DRAW_DUMP_FRAME`) makes each recorded copy cover one texel of render target 0. The present writes `pixel_history.txt` in `X2W_DRAW_DUMP_DIR`, one line per translated draw: ``` draw=2 frame=1500 x=1 y=1 key=2222222222222222 count=3 format=28 raw=ff00ff00 rgba=0,255,0,255 ``` `draw` is the copy ordinal, `frame` is the frame that recorded it, `key` is the translated manifest key, and `rgba` is decoded for R8G8B8A8/B8G8R8A8 UNORM or sRGB. The 48-copy bound is unchanged. Other formats keep the full dump behaviour. `startup_pixel_history` is a source-built 4x4 target with three draws. The first and third are scissored to the top-left texel; only the second covers the watched texel (1, 1). The report must name draw 2 with its key and green value, and the control that omits draw 2 must leave the texel black at draw 3. ``` startup_pixel_history_warp Passed startup_pixel_history_hardware Passed (AMD Radeon RX 9060 XT, 0x7590) ``` `d3d12_xs_shim` builds in the dev preset; `docs_links_check.py` (27 files, 541 links) and `bidi_controls_check.py` (2,036 files) pass, as does `git diff --check`. This is part of #1268. The format is limited to the 8-bit four-channel targets the full dump already supports; the runtime copy is exercised by the same `CopyTextureRegion` path as the full dump.
tedin7 commented 2026-11-26 13:17:51 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head 62e332b8 against main (comment review, no approval).

Checked:

  • The 48-copy limit still holds. draw_dump_after returns when draw_dumps().full(), and record refuses at entries_ + consumed_ >= 48. The static sample list in draw_dump_flush can only grow by completed copies, so it is capped at 48 too.
  • Off by default. draw_dump_after returns first unless X2W_DRAW_DUMP_FRAME is set. X2W_DRAW_DUMP_PIXEL is only read for that frame and must parse exactly as <x>,<y>. Without the pixel variable the old full-target dump path is unchanged.
  • The pixel is bounds-checked against the target size, and only the four 8-bit formats the full dump already supports are accepted.
  • The 1x1 copy uses a 256-byte aligned pitch and a one-texel box, which is valid for CopyTextureRegion.

Finding (not a blocker, worth a follow-up): tests/startup_pixel_history.cpp includes only pixel_history.h and does its own copy in the test. It never runs draw_dump_after/draw_dump_flush in d3d12_draw.inl. So a break in the runtime part (ignoring the box, the env parsing, skipping the 48 limit) would not turn the test red. The negative control only omits draw 2 from the list, so it guards the report format and decode, not the runtime hook. A small check that drives the real translated draw path with the env set would close this.

Commands run (Linux): git diff --check origin/main...HEAD, python3 tests/docs_links_check.py (27 files, 541 links), python3 tests/bidi_controls_check.py (2038 files): all pass.
Win2025 WARP, same head: dev 5/5 and release 5/5 for startup_pixel_history_warp|startup_dump_fence|startup_teardown (includes the new test). Real-GPU run not available (RunPod stopped).
Merge stays open until CI on this head is green.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6074792571 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2828#pullrequestreview-6074792571). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T13:17:51Z. **Review:** COMMENTED --- Review of head 62e332b8 against main (comment review, no approval). Checked: - The 48-copy limit still holds. `draw_dump_after` returns when `draw_dumps().full()`, and `record` refuses at `entries_ + consumed_ >= 48`. The static sample list in `draw_dump_flush` can only grow by completed copies, so it is capped at 48 too. - Off by default. `draw_dump_after` returns first unless `X2W_DRAW_DUMP_FRAME` is set. `X2W_DRAW_DUMP_PIXEL` is only read for that frame and must parse exactly as `<x>,<y>`. Without the pixel variable the old full-target dump path is unchanged. - The pixel is bounds-checked against the target size, and only the four 8-bit formats the full dump already supports are accepted. - The 1x1 copy uses a 256-byte aligned pitch and a one-texel box, which is valid for `CopyTextureRegion`. Finding (not a blocker, worth a follow-up): `tests/startup_pixel_history.cpp` includes only `pixel_history.h` and does its own copy in the test. It never runs `draw_dump_after`/`draw_dump_flush` in `d3d12_draw.inl`. So a break in the runtime part (ignoring the box, the env parsing, skipping the 48 limit) would not turn the test red. The negative control only omits draw 2 from the list, so it guards the report format and decode, not the runtime hook. A small check that drives the real translated draw path with the env set would close this. Commands run (Linux): `git diff --check origin/main...HEAD`, `python3 tests/docs_links_check.py` (27 files, 541 links), `python3 tests/bidi_controls_check.py` (2038 files): all pass. Win2025 WARP, same head: dev 5/5 and release 5/5 for `startup_pixel_history_warp|startup_dump_fence|startup_teardown` (includes the new test). Real-GPU run not available (RunPod stopped). Merge stays open until CI on this head is green. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-26 14:00:27 +00:00
tedin7 commented 2026-11-26 14:00:36 +00:00 (Migrated from github.com)

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


Win2025 WARP receipt for head 62e332b8.

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

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_dump_fence_check startup_pixel_history -- -j 2): 29.80s (configure 1.51s)
    • Test (ctest --preset dev -R 'startup_pixel_history_warp|startup_dump_fence|startup_teardown' --parallel 6 --no-tests=error --output-on-failure): 5/5 passed (0.42s: startup_pixel_history_warp 0.07s, startup_dump_fence_removed_control_warp 0.08s, startup_dump_fence_warp 0.09s, startup_teardown_unload_hardware 0.26s, startup_teardown_unload_warp 0.28s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_dump_fence_check startup_pixel_history -- -j 2): 36.58s (configure 1.56s)
    • Test (ctest --preset release -R 'startup_pixel_history_warp|startup_dump_fence|startup_teardown' --parallel 6 --no-tests=error --output-on-failure): 5/5 passed (0.45s: startup_dump_fence_warp 0.07s, startup_dump_fence_removed_control_warp 0.06s, startup_pixel_history_warp 0.07s, startup_teardown_unload_warp 0.27s, startup_teardown_unload_hardware 0.29s)
  • sccache: 10/28 hits; wall 76.6s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7193147564 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2828#issuecomment-7193147564). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T13:17:55Z. --- Win2025 WARP receipt for head 62e332b8. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `62e332b862aec1b71290aa1087664c907b757d46`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_dump_fence_check startup_pixel_history -- -j 2`): `29.80s` (configure `1.51s`) - Test (`ctest --preset dev -R 'startup_pixel_history_warp|startup_dump_fence|startup_teardown' --parallel 6 --no-tests=error --output-on-failure`): **5/5 passed** (`0.42s`: `startup_pixel_history_warp` `0.07s`, `startup_dump_fence_removed_control_warp` `0.08s`, `startup_dump_fence_warp` `0.09s`, `startup_teardown_unload_hardware` `0.26s`, `startup_teardown_unload_warp` `0.28s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_dump_fence_check startup_pixel_history -- -j 2`): `36.58s` (configure `1.56s`) - Test (`ctest --preset release -R 'startup_pixel_history_warp|startup_dump_fence|startup_teardown' --parallel 6 --no-tests=error --output-on-failure`): **5/5 passed** (`0.45s`: `startup_dump_fence_warp` `0.07s`, `startup_dump_fence_removed_control_warp` `0.06s`, `startup_pixel_history_warp` `0.07s`, `startup_teardown_unload_warp` `0.27s`, `startup_teardown_unload_hardware` `0.29s`) - `sccache`: 10/28 hits; wall `76.6s` AI-assisted; commands listed were executed locally.
lambirou commented 2026-11-26 14:00:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-26T13:20:26Z.


Thanks for the review. The runtime-hook gap is tracked in #2843: a fixture that presents a guest target, draws through the translated path with X2W_DRAW_DUMP_FRAME=1 and X2W_DRAW_DUMP_PIXEL set, then presents again to flush pixel_history.txt. This landed PR stays as the report/decode slice.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7193209120 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2828#issuecomment-7193209120). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-26T13:20:26Z. --- Thanks for the review. The runtime-hook gap is tracked in #2843: a fixture that presents a guest target, draws through the translated path with X2W_DRAW_DUMP_FRAME=1 and X2W_DRAW_DUMP_PIXEL set, then presents again to flush pixel_history.txt. This landed PR stays as the report/decode slice.
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!2820
No description provided.