runtime: composite the presented planes in the output window #2639
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2647"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-26T00:26:24Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T00:31:47Z.
Review: COMMENTED
Comment review of head
cb137898(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.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.PlaneStep{i, false}):startup_present_planes: FAIL, "plane 1 is drawn over plane 0, blended".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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T00:44:06Z.
Review: CHANGES_REQUESTED
Windows Release at
cb137898reproduced the WARP composite and the expected overlay pixel differences. Two things remain for this slice. ThePASS_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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T01:45:36Z.
Review: APPROVED
Windows Release builds the production shim and passes all four presenter CTests at
ac59fc3e. 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.Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-26T01:05:31Z.
Thanks for reproducing it at
cb137898. Both points are addressed infddd5f70(a new commit on top; nothing rebased).1. The negative control now passes only on success
startup_present_composite_overlay_removed_control_warp, to follow the other_control_warptests. It runs the same baseline, stacked and skipped cases asstartup_present_composite_warp. Then it removes the overlays and composites the black plane 0 alone.control ok: baseline matched, <n> fences completed, removing the overlay changed 6 of 8 cells as expectedand exits 0 only when all of these hold:Gpu::runnow fails on a close or signal error, a wait that does not reach the value, or a completed value ofUINT64_MAX), andGetDeviceRemovedReasonreports no removal;PASS_REGULAR_EXPRESSION "control ok: baseline matched",FAIL_REGULAR_EXPRESSION "FAIL: ",SKIP_RETURN_CODE 77(no WARP). Every failure path printsFAIL:, including queue, compositor, target and plane setup.2. Multi-plane presentation is now experimental and opt-in
main. Plane 0 is the only plane drawn, through the same opaque full-window draw with a linear, clamped sampler. No swap chain is created when plane 0 cannot be drawn.X2W_PRESENT_COMPOSITE=1. It stays opt-in until there is a matched comparison on the same executable with this change alone.X2W_PRESENT_PLANE=<n>still shows planenalone, with or without the switch.X2W_D3D12_DUMP_SURFACEand thex2w-render presentedreadback all read plane 0's first resource again. Thex2w-render presentedline is back to itsmainformat (I dropped the mean-alpha field).x2w-render raw plane <i> (not composited): surface ..., sample <k>, mean level ..., mean alpha .... It does not touch the window copy, the note or the dump.x2w-present frame <n> plane <i>/<count>shape lines (first presents and every 300th) are still logged in both modes. They only log.docs/startup-runtime.md#presented-planesand the switch table describe the default, the opt-in and the raw plane line. The fixture still tests the compositor directly, without the switch.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
fddd5f70.14/14 passed, 0 failed, 0 skipped. Among them:
startup_present_composite_warp: passed (baseline, stacked and skipped on WARP).startup_present_composite_overlay_removed_control_warp: passed,control ok: baseline matched, 8 fences completed, removing the overlay changed 6 of 8 cells as expected.startup_present_planesandstartup_present_planes_control: passed. These are unchanged; that control is pure CPU and has no setup or device path.Mutation checks (each applied locally, the target rebuilt,
ctest --preset release --no-tests=error -R '^startup_present_composite_'run, then reverted):startup_present_composite_warpBlendEnable = FALSE(plane_compositor.h)FAIL: stacked cell row 0 column 0: got 255,255,0,0 want 0,0,0,255and othersFAIL:regex matchedcompositor.createresult forced toE_FAILFAIL: compositor setup 0x80004005FAIL:regex matched. The oldPASS_REGULAR_EXPRESSION "FAIL: "would have passed it.UINT64_MAX(device removal)FAIL: fence 1 not completed (completed 18446744073709551615, ...)FAIL:regex matchedAfter reverting, both tests pass again on the rebuilt tree.
This change was AI-assisted.