gpu: add a composite provenance fixture for retained clear colours #1642

Manually merged
github merged 1 commit from gh-pr/1642/head into gh-pr/1642/base 2026-11-26 23:22:51 +00:00
Owner

@⁠MasterDomino on GitHub · 2026-11-24 15:37 UTC · original
MasterDomino:gpu/composite-provenance → main · +372 −0 · 6 files · 1 commits · merged 2026-11-24 15:58 UTC

Refs #1628

A source-built two-pass D3D12 fixture for composite provenance: it shows whether a colour left in a composite's destination came from the composite or was already there. It is synthetic; nothing from the title is involved.

Fixture (tests/startup_composite_provenance.cpp, .hlsl, mode --startup-composite-provenance)

One command list, then one fence wait (ComputeCommands::submit_and_wait, as startup_cb_blend uses):

  1. Pass 1 (composite source): a 64×64 R32G32B32A32_FLOAT render target is cleared to blue. It then gets a green centre block [16,48)² and a red corner block [0,8)², each drawn by a full-screen triangle under its own scissor.
  2. Readback: the source is copied out, then moved to PIXEL_SHADER_RESOURCE.
  3. Destination: cleared to magenta, then copied out. This is the destination immediately before the composite draw.
  4. Composite: a full-screen triangle Loads the exact source texel at floor(position) × scale + offset, so no filtering or rounding is involved. The viewport, scissor, write mask and UV come from the case; blending is off.
  5. Readback: the destination immediately after the composite draw is copied out.

A CPU model built from the source and before-composite readbacks predicts every after-composite pixel. A pixel inside the viewport and scissor takes the source texel in its written channels; every other pixel keeps the before value. The comparison is bit-exact.

case viewport scissor blend write mask UV centre after
drawn centre 0,0 64×64 (0,0)–(64,64) off 0xf texel × (1,1) + (0,0) green (source centre)
clipped centre 0,0 64×64 (0,0)–(64,16) off 0xf texel × (1,1) + (0,0) magenta (retained)
UV selects corner 0,0 64×64 (0,0)–(64,64) off 0xf texel × (0,0) + (2,2) red (source corner)

The fixture also checks the inputs (source centre, corner and base, and the before centre), and that the three after-centres are pairwise distinct.

Breaking controls: each runs against the unchanged model of its case and must mismatch.

  • The corner case with its UV moved to the source centre, offset (32,32).
  • The drawn case with write mask red|alpha.

New CTests: startup_composite_provenance_{hardware,warp}, plus the DXC header rules for the VS and the two pixel shaders. docs/startup-runtime.md gains a "Composite provenance fixture" section.

Results

4147ef23 on 141617bb. Windows 11 26H2, build 26300.9974. MSVC 19.44.35207, DXC 1.8.2502.11. D3D12 debug layer enabled, debug_errors=0 debug_warnings=0.

ctest --preset dev --no-tests=error -R '^startup_composite_provenance_(hardware|warp)$' -V
AMD Radeon RX 9070 XT, driver 32.0.31044.16 WARP 10.0.26100.9818
drawn centre 0/4096 mismatches, centre (0,1,0,1) 0/4096, (0,1,0,1)
clipped centre 0/4096, centre (1,0,1,1) 0/4096, (1,0,1,1)
UV selects corner 0/4096, centre (1,0,0,1) 0/4096, (1,0,0,1)
mutant: UV moved 4096/4096 mismatch 4096/4096
mutant: write mask red|alpha 1088/4096 mismatch (centre + corner, where green/blue differ from magenta) 1088/4096

Both pass in the dev and release presets, with no skips. startup_cb_blend_* and the new startup_packed_screen_position_* (#1634) still pass alongside.

AI-assisted.

🤖 Generated with Claude Code

**@⁠MasterDomino** on GitHub · 2026-11-24 15:37 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1642) `MasterDomino:gpu/composite-provenance` → `main` · +372 −0 · 6 files · 1 commits · merged 2026-11-24 15:58 UTC Refs #1628 A source-built two-pass D3D12 fixture for composite provenance: it shows whether a colour left in a composite's destination came from the composite or was already there. It is synthetic; nothing from the title is involved. ## Fixture (`tests/startup_composite_provenance.cpp`, `.hlsl`, mode `--startup-composite-provenance`) One command list, then one fence wait (`ComputeCommands::submit_and_wait`, as `startup_cb_blend` uses): 1. **Pass 1 (composite source):** a 64×64 `R32G32B32A32_FLOAT` render target is cleared to blue. It then gets a green centre block `[16,48)²` and a red corner block `[0,8)²`, each drawn by a full-screen triangle under its own scissor. 2. **Readback:** the source is copied out, then moved to `PIXEL_SHADER_RESOURCE`. 3. **Destination:** cleared to magenta, then copied out. This is the destination immediately before the composite draw. 4. **Composite:** a full-screen triangle `Load`s the exact source texel at `floor(position) × scale + offset`, so no filtering or rounding is involved. The viewport, scissor, write mask and UV come from the case; blending is off. 5. **Readback:** the destination immediately after the composite draw is copied out. A CPU model built from the source and before-composite readbacks predicts every after-composite pixel. A pixel inside the viewport and scissor takes the source texel in its written channels; every other pixel keeps the before value. The comparison is bit-exact. | case | viewport | scissor | blend | write mask | UV | centre after | |---|---|---|---|---|---|---| | drawn centre | 0,0 64×64 | (0,0)–(64,64) | off | 0xf | texel × (1,1) + (0,0) | green (source centre) | | clipped centre | 0,0 64×64 | (0,0)–(64,16) | off | 0xf | texel × (1,1) + (0,0) | magenta (retained) | | UV selects corner | 0,0 64×64 | (0,0)–(64,64) | off | 0xf | texel × (0,0) + (2,2) | red (source corner) | The fixture also checks the inputs (source centre, corner and base, and the before centre), and that the three after-centres are pairwise distinct. **Breaking controls:** each runs against the unchanged model of its case and must mismatch. - The corner case with its UV moved to the source centre, offset (32,32). - The drawn case with write mask red|alpha. New CTests: `startup_composite_provenance_{hardware,warp}`, plus the DXC header rules for the VS and the two pixel shaders. `docs/startup-runtime.md` gains a "Composite provenance fixture" section. ## Results `4147ef23` on `141617bb`. Windows 11 26H2, build 26300.9974. MSVC 19.44.35207, DXC 1.8.2502.11. D3D12 debug layer enabled, `debug_errors=0 debug_warnings=0`. ```powershell ctest --preset dev --no-tests=error -R '^startup_composite_provenance_(hardware|warp)$' -V ``` | | AMD Radeon RX 9070 XT, driver `32.0.31044.16` | WARP `10.0.26100.9818` | |---|---|---| | drawn centre | 0/4096 mismatches, centre (0,1,0,1) | 0/4096, (0,1,0,1) | | clipped centre | 0/4096, centre (1,0,1,1) | 0/4096, (1,0,1,1) | | UV selects corner | 0/4096, centre (1,0,0,1) | 0/4096, (1,0,0,1) | | mutant: UV moved | 4096/4096 mismatch | 4096/4096 | | mutant: write mask red\|alpha | 1088/4096 mismatch (centre + corner, where green/blue differ from magenta) | 1088/4096 | Both pass in the `dev` and `release` presets, with no skips. `startup_cb_blend_*` and the new `startup_packed_screen_position_*` (#1634) still pass alongside. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A source-built two-pass D3D12 fixture: one command list draws a composite
source with distinct base, centre and corner colours, clears the
destination to a fourth colour, and composites exact source texels.
The source, the destination immediately before the composite draw and
the destination immediately after it are read back on that list behind
one fence. A drawn centre, a centre clipped by the scissor and a UV that
selects the source corner leave three different destination centres,
and a moved UV and a red|alpha write mask must each break the model.

Refs #1628

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:22:50 +00:00
github manually merged commit 4147ef2352 into gh-pr/1642/base 2026-11-26 23:22:51 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 15:43 UTC · original · reviewed

Reviewed 4147ef2352bac44708c2529e643cbcb4d6ae5f15:

  • Implementation & semantics: tests/startup_composite_provenance.cpp and tests/startup_composite_provenance.hlsl cleanly implement the two-pass D3D12 provenance fixture on a single command list (ComputeCommands::submit_and_wait), using source.Load(int3(int2(position.xy) * scale + offset, 0)) for exact texel addressing without filtering. Root signature layout (b0 8×32-bit constants matching float4 fill + int2 scale + int2 offset, plus t0 SRV descriptor table), resource state transitions (RENDER_TARGET -> COPY_SOURCE -> PIXEL_SHADER_RESOURCE for source, RENDER_TARGET -> COPY_SOURCE -> RENDER_TARGET -> COPY_SOURCE for destination), bit-exact std::memcmp verification against the CPU model, pairwise-distinct centre checks, and the two breaking controls (uv moved to the source centre, write mask red|alpha) are all sound.
  • Linux repo hygiene (executed locally):
    • python3 tests/docs_links_check.py — passed (Checked 16 Markdown files and 348 links.)
    • python3 tests/bidi_controls_check.py — passed (Checked 1268 tracked source, script and build/CI files: no bidirectional controls.)
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) (executed locally):
    • Debug (cmake --build --preset dev --target offscreen_check -- -j 6 + ctest --preset dev -R '^startup_composite_provenance_' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (startup_composite_provenance_warp, startup_composite_provenance_hardware).
    • Release /O2 (cmake --build --preset release --target offscreen_check -- -j 6 + ctest --preset release -R '^startup_composite_provenance_' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (startup_composite_provenance_hardware, startup_composite_provenance_warp).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 15:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1642#pullrequestreview-6042501732) · **reviewed** Reviewed `4147ef2352bac44708c2529e643cbcb4d6ae5f15`: - **Implementation & semantics**: `tests/startup_composite_provenance.cpp` and `tests/startup_composite_provenance.hlsl` cleanly implement the two-pass D3D12 provenance fixture on a single command list (`ComputeCommands::submit_and_wait`), using `source.Load(int3(int2(position.xy) * scale + offset, 0))` for exact texel addressing without filtering. Root signature layout (`b0` 8×32-bit constants matching `float4 fill + int2 scale + int2 offset`, plus `t0` SRV descriptor table), resource state transitions (`RENDER_TARGET -> COPY_SOURCE -> PIXEL_SHADER_RESOURCE` for `source`, `RENDER_TARGET -> COPY_SOURCE -> RENDER_TARGET -> COPY_SOURCE` for `destination`), bit-exact `std::memcmp` verification against the CPU model, pairwise-distinct centre checks, and the two breaking controls (`uv moved to the source centre`, `write mask red|alpha`) are all sound. - **Linux repo hygiene** (executed locally): - `python3 tests/docs_links_check.py` — passed (`Checked 16 Markdown files and 348 links.`) - `python3 tests/bidi_controls_check.py` — passed (`Checked 1268 tracked source, script and build/CI files: no bidirectional controls.`) - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)** (executed locally): - Debug (`cmake --build --preset dev --target offscreen_check -- -j 6` + `ctest --preset dev -R '^startup_composite_provenance_' --parallel 4 --no-tests=error --output-on-failure`): **2/2 passed** (`startup_composite_provenance_warp`, `startup_composite_provenance_hardware`). - Release `/O2` (`cmake --build --preset release --target offscreen_check -- -j 6` + `ctest --preset release -R '^startup_composite_provenance_' --parallel 4 --no-tests=error --output-on-failure`): **2/2 passed** (`startup_composite_provenance_hardware`, `startup_composite_provenance_warp`). AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.