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

Merged
MasterDomino merged 1 commit from upstream-pr/1642 into main 2026-11-24 15:58:03 +00:00
MasterDomino commented 2026-11-24 15:37:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T15:37:59Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6585521573 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1642). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T15:37:59Z. --- 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)
upstream-sync closed this pull request 2026-11-24 16:03:28 +00:00
tedin7 commented 2026-11-24 16:03:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:43:54Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6042501732 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1642#pullrequestreview-6042501732). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T15:43:54Z. **Review:** COMMENTED --- 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.
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!1635
No description provided.