Repository navigation
runtime: composite the presented planes in the output window - #2647
Conversation
A console present (CommandQueue slot 32) can carry several planes. The output window showed plane 0 alone; on a two-plane present plane 0 was black and plane 1 held the picture. The window now composites the planes bottom to top: the lowest drawn plane opaque (its alpha ignored), each later plane blended by its own alpha (src-alpha / inv-src-alpha) in plane order. Unreadable or empty records, surfaces the presenter cannot draw and repeats of a surface are left out. X2W_PRESENT_PLANE=<n> shows one plane alone for diagnosis, and the first presents log each plane. The draw (shaders, opaque and blend pipelines, per-plane draws) moves into plane_compositor.h, shared by the window presenter and a new WARP readback fixture. New fixtures with negative controls: startup_present_planes (record layout and order) and startup_present_composite_warp (single-plane baseline, stacked transparent, partly transparent and opaque overlays, skipped repeats; the control composites only the black first plane).
tedin7
left a comment
There was a problem hiding this comment.
Comment review of head cb13789 (code and fixture tests only).
What I checked:
present_planes.h:composite_stepskeeps plane order, drops unreadable planes and repeats of a surface already drawn, and makes the lowest drawn plane the opaque base. Matches the contract in the PR body and indocs/startup-runtime.md.plane_compositor.h: the opaque pipeline writesfloat4(rgb, 1). The blend pipeline usesSRC_ALPHA / INV_SRC_ALPHAfor colour andONE / INV_SRC_ALPHAfor alpha, so straight alpha over an opaque base keeps target alpha at 255. Window presenter and the WARP fixture share this class, so the fixture exercises the window's draw code.d3d12_xs_device.cpp:presented_planes()bounds the loop bywindow_planes, falls back to the first known surface when none can be drawn, andX2W_PRESENT_PLANEstill selects one plane.- The new WARP fixture compares GPU readback with CPU-computed expected colours for the baseline, stacked and skipped cases, not string checks.
- No other open or merged PR covers this slice (search "composite planes present": only #2591, the series issue-PR this one is slice 1 of).
Commands run (Linux, in a worktree of this head):
git diff --check origin/main...HEAD: clean.python3 tests/docs_links_check.py: passed (19 files, 508 links).python3 tests/bidi_controls_check.py: passed.g++ -std=c++17 tests/startup_present_planes_check.cpp(pure logic, builds on Linux):ok.- Mutation 1: first drawn plane no longer marked opaque/blended correctly (
PlaneStep{i, false}):startup_present_planes: FAIL, "plane 1 is drawn over plane 0, blended". - Mutation 2: repeat-surface check removed: FAIL, "a surface presented twice is drawn once".
- The D3D12 WARP fixture (
startup_present_composite_warp) needs Windows; I did not run it here.
Findings: no bugs found in the code. The branch is 20 commits behind main.
Why this is not merged by me: the PR describes a measured black window on a real two-plane present (blocker seen while running the console executable), and its fix is meant to advance that run. We have no access to the executable, so the fixture results above are the only thing verified. Whether the window now shows the picture, and the hardware report of a top plane with alpha about 5/255, must be confirmed by whoever merges, on the executable. The merge stays with MasterDomino or @R0Y00.
AI-assisted; commands listed were executed locally.
R0Y00
left a comment
There was a problem hiding this comment.
Windows Release at cb137898 reproduced the WARP composite and the expected overlay pixel differences. Two things remain for this slice. The PASS_REGULAR_EXPRESSION "FAIL: " accepts queue or compositor setup failure and device removal as a successful negative control. Make the control succeed only after the baseline matches, a fence completes, and removing the overlay produces the expected pixel differences. Also keep the new multi-plane presentation behind an explicit experimental option until there is a matched executable comparison of this standalone candidate. The #2591 run combined four changes. Preserve the existing baseline capture and label the highest-plane sample as a raw plane so it cannot be mistaken for final composited pixels.
The output window shows plane 0 alone again by default; the multi-plane composite runs only with the experimental X2W_PRESENT_COMPOSITE=1. The baseline capture is restored: the frame capture, the presented signature, the surface dump and the x2w-render presented readback read plane 0's first resource as before. Under the switch the highest plane above plane 0 is sampled separately and logged as "x2w-render raw plane <i> (not composited)". The WARP control is renamed startup_present_composite_overlay_removed_control_warp. It runs the baseline, stacked and skipped cases, then removes the overlays, and passes only on "control ok:", printed when the baseline matched, every fence completed without device removal and the overlay-free picture differs from the stacked expectation in exactly the six overlay cells. Any FAIL line, including setup failure, a fence that does not complete or device removal, now fails it.
|
Thanks for reproducing it at 1. The negative control now passes only on success
2. Multi-plane presentation is now experimental and opt-in
Results Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088, Windows 10.0.26200, Release preset, debug layer off (the composite fixture does not enable it). Commit . .\tools\dev.ps1
cmake --preset release
cmake --build --preset release
ctest --preset release --no-tests=error -R 'present' -V14/14 passed, 0 failed, 0 skipped. Among them:
python -B tests/docs_links_check.py # Checked 19 Markdown files and 509 links (exit 0)
python -B tests/bidi_controls_check.py # no bidirectional controls (exit 0)
git diff --check origin/main...HEAD # cleanMutation checks (each applied locally, the target rebuilt,
After reverting, both tests pass again on the rebuilt tree. This change was AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
Windows Release builds the production shim and passes all four presenter CTests at ac59fc3. The default setup uses one descriptor and only the opaque pipeline. The same fixture then configures the opt-in compositor and checks stacked and skipped planes. The overlay-removed control completed all eight fences and found exactly six changed cells out of eight. This addresses the two review findings. A matched real-executable comparison remains separate.
Change
Slice 1 of 4 from #2591, the compositor. It runs under any profile.
A console present (CommandQueue slot 32) can carry several plane records
(
present_planes.h: 0x48 bytes each, +0x08 resource count, +0x10 resource array). The output windowshowed plane 0 alone. On a two-plane present I measured, plane 0 (1920x1080) stayed black and plane 1
(3840x2160) held the picture with alpha 255, so the window was black.
The window now composites the planes. The draw (shaders, root signature, opaque and blend pipelines,
per-plane SRVs and draws) moves out of
d3d12_present.inlintosrc/startup_stubs/plane_compositor.h.The window presenter and the new WARP fixture use the same
PlaneCompositor, so the fixture runs thesame draw code as the window, not a copy of it.
Supported alpha and order contract (also in
docs/startup-runtime.md#presented-planes):composite_steps). At mostfour planes are read.
ignored.
rgb = src.rgb * a + dst.rgb * (1 - a)(SRC_ALPHA/INV_SRC_ALPHA; alphaONE/INV_SRC_ALPHA). Alpha 0 keeps what is below, alpha 255 replaces it, and the target alpha stays 255.drawn (
present_view_format.h), and a repeat of a surface already drawn. If plane 0 is left out,the next drawn plane becomes the opaque base.
whole window.
X2W_PRESENT_PLANE=<n>(diagnostic) shows planenalone. The first presents log each plane's shape.The
x2w-render presentedreadback now reports the topmost drawn plane and adds a mean alpha. Thisanswers the review report of a top plane with alpha about 5/255 on hardware: that plane now
contributes about 5/255 of its colour over the plane below it. It no longer replaces it.
Refs #2591. Independent of the other three slices (slot 76, view dimensions, console profile).
Verification
Build: this branch, one commit
cb137898onmainat02368737. From the worktree in PowerShell:. .\tools\dev.ps1,cmake --preset release,cmake --build --preset release(Python envout/pe-envfromrequirements-dev.txt).Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088, Windows 10.0.26200.9974. The new fixtures
use in-box WARP, with the debug layer off.
ctest --preset release --no-tests=error -R '^startup_present_(planes|composite_warp)(_control)?$' -V:4/4 passed.
startup_present_planesandstartup_present_composite_warpprintok. Both controlsprint
FAIL:lines, as their regex requires.ctest --preset release -j 8 --no-tests=error -R '^startup_' -E '_hardware$|^startup_audio_': 642tests, 635 passed, 6 skipped (capability, exit 77), 1 failed. The failure was
startup_inflate,which timed out at 60 s under
-j 8. Rerun alone withctest --preset release --no-tests=error -R '^startup_inflate$'it passed in 9.1 s. This changedoes not touch it. (Run before a final amend that only moved an
#include/ CMake block to avoid a merge conflict with the sibling slices; the slice's own tests were rerun after it and pass.)python -B tests/docs_links_check.py: pass (19 Markdown files, 508 links).python -B tests/bidi_controls_check.py: pass (no bidirectional controls).git diff --check origin/main...HEAD: clean.Evidence
startup_present_composite_warpbuilds 64x32 RGBA8 planes from source (cells of 16x16 texels). Itpasses them through synthetic 0x48-byte plane records, then
present_plane_resource, thencomposite_steps, thenPlaneCompositor::recordinto a render target cleared to(64,128,191,0). It reads every texel back. Observed on WARP:
Opaque cells are exact. Blended cells are within 1 level of the expected value.
128,0,127depends onplane order: plane 1 under plane 2.
--controlcomposites only the black first plane. The baselinestill passes, and every overlay cell plus both step counts print
FAIL:. The test exits 77 when noWARP adapter is available.
startup_present_planes(from #2591, unchanged) checks the record layout and the composite order onsynthetic records. Its control reads 0x40-byte records and composites plane 0 alone.
All inputs are written in source (MIT). Why plane 0 stays black on the console path is still unknown,
and the record's rectangles are not decoded. A start-up run with a local console executable (not
included) showed a picture with this change. That run is recorded in #2591, not repeated here.
Checklist
This change was AI-assisted.