tooling: report the first scene-colour write from draw dumps #3177

Manually merged
github merged 2 commits from github-bot/gh-3175 into gh-pr/3175/base 2026-11-27 21:49:57 +00:00 AGit
Owner

@⁠lambirou on GitHub · 2026-11-27 20:24 UTC · original
lambirou:codex/scene-color-trace → main · +1222 −1 · 5 files · 2 commits · merged 2026-11-27 21:44 UTC

Changes

Adds tools/startup/scene_color_report.py, an offline reader for the existing pixel_history.txt and full-frame BMP diagnostics. For a selected frame and pixel it names the first retained colour change as well as the last writer, and classifies the history as no draw, UI only, target write, unchanged, truncated or non-RGBA8.

The report is bounded and never echoes input paths, raw log lines or arbitrary text. It does not change the runtime, the shaders or the dump format.

Validation

python -B tests/startup_scene_color_report_check.py
# Ran 14 tests in 1.399s
# OK
python -m py_compile tools/startup/scene_color_report.py tests/startup_scene_color_report_check.py
git diff --check

The synthetic check covers first change and last writer, a write restoring the baseline, no change, empty history, malformed lines, a non-RGBA8 target, BGRA order, the 48-sample cap, frame and pixel selection, a supplied baseline, BMP match and mismatch, a header/record mismatch and a missing history file.

Limits

This is a reader for diagnostics that already exist; it does not run the title and does not prove that a draw is a scene draw. No local dump was available under out/ for this change, so the checked results are synthetic. The next step is to run the title with X2W_DRAW_DUMP_FRAME and X2W_DRAW_DUMP_PIXEL on a fixed profile and input sequence.

Refs #870.

**@⁠lambirou** on GitHub · 2026-11-27 20:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3175) `lambirou:codex/scene-color-trace` → `main` · +1222 −1 · 5 files · 2 commits · merged 2026-11-27 21:44 UTC ## Changes Adds `tools/startup/scene_color_report.py`, an offline reader for the existing `pixel_history.txt` and full-frame BMP diagnostics. For a selected frame and pixel it names the first retained colour change as well as the last writer, and classifies the history as no draw, UI only, target write, unchanged, truncated or non-RGBA8. The report is bounded and never echoes input paths, raw log lines or arbitrary text. It does not change the runtime, the shaders or the dump format. ## Validation ```powershell python -B tests/startup_scene_color_report_check.py # Ran 14 tests in 1.399s # OK python -m py_compile tools/startup/scene_color_report.py tests/startup_scene_color_report_check.py git diff --check ``` The synthetic check covers first change and last writer, a write restoring the baseline, no change, empty history, malformed lines, a non-RGBA8 target, BGRA order, the 48-sample cap, frame and pixel selection, a supplied baseline, BMP match and mismatch, a header/record mismatch and a missing history file. ## Limits This is a reader for diagnostics that already exist; it does not run the title and does not prove that a draw is a scene draw. No local dump was available under `out/` for this change, so the checked results are synthetic. The next step is to run the title with `X2W_DRAW_DUMP_FRAME` and `X2W_DRAW_DUMP_PIXEL` on a fixed profile and input sequence. Refs #870.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 20:28:46 +00:00
github-bot changed target branch from main to gh-pr/3175/base 2026-11-27 21:49:56 +00:00
github manually merged commit aff14cbedd into gh-pr/3175/base 2026-11-27 21:49:57 +00:00
Author
Owner

@⁠pigalot on GitHub · 2026-11-27 21:43 UTC · original · approved these changes

Independently reviewed aff14cbe integrated over main afe70bd7 (tree b3b54873). The merge is clean.

What I traced. I compared the tool's parser and decoders with the runtime code it reads:

  • History format. HEADER_RE and SAMPLE_RE match what pixel_history_write (src/startup_stubs/pixel_history.h) prints: draw=%llu frame=%ld x=%u y=%u key=%016llx count=%u format=%d raw=%08x, plus an optional rgba=.
  • Channel order. decode_rgba uses the same byte order as pixel_history_decode for DXGI 28/29 (RGBA) and 87/91 (BGRA).
  • Cap. RUNTIME_SAMPLE_LIMIT = 48 is DrawReadbacks::limit. That limit counts copies taken plus copies in flight, for the whole process (draw_dump_tracking.h). A history of exactly 48 samples is therefore reported as history_truncated even if nothing was dropped. That is the conservative reading.
  • BMPs. The file name pattern matches draw_%02d_%016llx_%u.bmp. x2w_draw_bmp::write writes 32-bit, bottom-up, B,G,R,255 rows, which is what _bmp_pixel reads back.

What I ran.

python -B tests/startup_scene_color_report_check.py      # Ran 14 tests ... OK
python -B tests/run_checks_fragments_check.py            # run_checks_fragments_check ok
python -B tests/docs_links_check.py                      # Checked 109 Markdown files and 602 links.
ctest --test-dir out/build/dev --no-tests=error -V -R '^startup_pixel_history_warp$'   # Passed
  • End to end on real runtime output. I took the three history lines that startup_pixel_history_warp prints from pixel_history_write on a dev build of the trial merge and wrote them under the runtime header. Then I ran python -B tools/startup/scene_color_report.py <dir> --pixel 1,1. It reports target_write, with first change and last writer both draw=2, key=2222222222222222, raw=0xff00ff00, 0,255,0,255. That matches the fixture's expectation: only draw 2 covers texel (1, 1).
  • Before. The check and the tool are new and are absent on main.

Mutants (each applied alone to tools/startup/scene_color_report.py, check rerun, file restored from its raw bytes, git diff --quiet clean afterwards):

Mutant Result
BGRA flag ignored in decode_rgba killed (test_bgra_format_uses_the_documented_channel_order)
runtime cap 48 → 49 killed (test_history_cap_marks_truncated_and_bounds_rows)
final != baseline → == killed (2 tests)
BMP rows read top-down killed (test_bmp_cross_check_and_mismatch_control)
header/record count mismatch ignored killed (test_header_mismatch_is_bounded)
--baseline-raw ignored killed (test_supplied_baseline_can_name_the_first_draw)
last writer pinned to first change killed (2 tests)
BMP R and B swapped in _bmp_pixel survives
--frame filter dropped survives
earlier-frame baseline (find_baseline) disabled survives

Non-blocking notes.

  • Survivors.
    • The BMP fixture colour is green (0, 255, 0), so a red/blue swap reads the same. A colour with R ≠ B would pin it.
    • In test_frame_and_pixel_selection, --pixel 0,0 alone already picks frame 1, so --frame is never what decides. Two frames at the same pixel would pin it.
    • No case has a sample from an earlier frame at the selected pixel, so the find_baseline path is unexercised.
  • Whitespace. git diff --check origin/main review/3175 reports docs/experiments/startup-scene-color-report.md:113: new blank line at EOF. The PR body lists git diff --check as run.
  • Wording. The classification labels are French (aucun draw, draw UI seulement, …) in both the report output and the doc table, while the rest of the repository is English. The tag ui_only says more than the tool can know: it means "no retained sample changed this pixel". Your doc already says so, but a neutral tag such as no_change would carry that into the report itself.

Verdict: approve on aff14cbe.

Environment: Microsoft Basic Render Driver (WARP) for startup_pixel_history_warp, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, debug layer off.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on aff14cbe.

This reply was AI-assisted.

**@⁠pigalot** on GitHub · 2026-11-27 21:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3175#pullrequestreview-6093592456) · **approved these changes** Independently reviewed `aff14cbe` integrated over `main` `afe70bd7` (tree `b3b54873`). The merge is clean. **What I traced.** I compared the tool's parser and decoders with the runtime code it reads: - **History format.** `HEADER_RE` and `SAMPLE_RE` match what `pixel_history_write` (`src/startup_stubs/pixel_history.h`) prints: `draw=%llu frame=%ld x=%u y=%u key=%016llx count=%u format=%d raw=%08x`, plus an optional ` rgba=`. - **Channel order.** `decode_rgba` uses the same byte order as `pixel_history_decode` for DXGI 28/29 (RGBA) and 87/91 (BGRA). - **Cap.** `RUNTIME_SAMPLE_LIMIT = 48` is `DrawReadbacks::limit`. That limit counts copies taken plus copies in flight, for the whole process (`draw_dump_tracking.h`). A history of exactly 48 samples is therefore reported as `history_truncated` even if nothing was dropped. That is the conservative reading. - **BMPs.** The file name pattern matches `draw_%02d_%016llx_%u.bmp`. `x2w_draw_bmp::write` writes 32-bit, bottom-up, B,G,R,255 rows, which is what `_bmp_pixel` reads back. **What I ran.** ```powershell python -B tests/startup_scene_color_report_check.py # Ran 14 tests ... OK python -B tests/run_checks_fragments_check.py # run_checks_fragments_check ok python -B tests/docs_links_check.py # Checked 109 Markdown files and 602 links. ctest --test-dir out/build/dev --no-tests=error -V -R '^startup_pixel_history_warp$' # Passed ``` - **End to end on real runtime output.** I took the three history lines that `startup_pixel_history_warp` prints from `pixel_history_write` on a `dev` build of the trial merge and wrote them under the runtime header. Then I ran `python -B tools/startup/scene_color_report.py <dir> --pixel 1,1`. It reports `target_write`, with first change and last writer both `draw=2`, `key=2222222222222222`, `raw=0xff00ff00`, `0,255,0,255`. That matches the fixture's expectation: only draw 2 covers texel (1, 1). - **Before.** The check and the tool are new and are absent on `main`. **Mutants** (each applied alone to `tools/startup/scene_color_report.py`, check rerun, file restored from its raw bytes, `git diff --quiet` clean afterwards): | Mutant | Result | |---|---| | BGRA flag ignored in `decode_rgba` | killed (`test_bgra_format_uses_the_documented_channel_order`) | | runtime cap 48 → 49 | killed (`test_history_cap_marks_truncated_and_bounds_rows`) | | final `!=` baseline → `==` | killed (2 tests) | | BMP rows read top-down | killed (`test_bmp_cross_check_and_mismatch_control`) | | header/record count mismatch ignored | killed (`test_header_mismatch_is_bounded`) | | `--baseline-raw` ignored | killed (`test_supplied_baseline_can_name_the_first_draw`) | | last writer pinned to first change | killed (2 tests) | | BMP R and B swapped in `_bmp_pixel` | survives | | `--frame` filter dropped | survives | | earlier-frame baseline (`find_baseline`) disabled | survives | **Non-blocking notes.** - **Survivors.** - The BMP fixture colour is green `(0, 255, 0)`, so a red/blue swap reads the same. A colour with R ≠ B would pin it. - In `test_frame_and_pixel_selection`, `--pixel 0,0` alone already picks frame 1, so `--frame` is never what decides. Two frames at the same pixel would pin it. - No case has a sample from an earlier frame at the selected pixel, so the `find_baseline` path is unexercised. - **Whitespace.** `git diff --check origin/main review/3175` reports `docs/experiments/startup-scene-color-report.md:113: new blank line at EOF.` The PR body lists `git diff --check` as run. - **Wording.** The classification labels are French (`aucun draw`, `draw UI seulement`, …) in both the report output and the doc table, while the rest of the repository is English. The tag `ui_only` says more than the tool can know: it means "no retained sample changed this pixel". Your doc already says so, but a neutral tag such as `no_change` would carry that into the report itself. **Verdict:** approve on `aff14cbe`. Environment: Microsoft Basic Render Driver (WARP) for `startup_pixel_history_warp`, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, debug layer off. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `aff14cbe`. This reply was AI-assisted.
Author
Owner

@⁠lambirou on GitHub · 2026-11-27 22:24 UTC · original

@⁠R0Y00 @⁠pigalot #3177 has no review yet. It is the scene-colour report tool from the 27/11 batch, head aff14cbe, with its synthetic check and CI green; could you take a look?

**@⁠lambirou** on GitHub · 2026-11-27 22:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3175#issuecomment-7229303149) @⁠R0Y00 @⁠pigalot #3177 has no review yet. It is the scene-colour report tool from the 27/11 batch, head `aff14cbe`, with its synthetic check and CI green; could you take a look?
This discussion has been locked. Commenting is limited to contributors.
No description provided.