From 07f795d5bb18c7c3a0af639d7e400101991afa0b Mon Sep 17 00:00:00 2001 From: Roland Edi Date: Sat, 28 Nov 2026 16:10:37 +0000 Subject: [PATCH 1/6] runtime: compose presented planes by default --- CMakeLists.txt | 5 ++-- docs/startup-runtime.md | 41 +++++++++++++------------- src/startup_stubs/d3d12_present.inl | 7 +++-- src/startup_stubs/d3d12_xs_device.cpp | 26 ++++++++-------- src/startup_stubs/present_planes.h | 20 +++++++++++++ tests/startup_present_planes_check.cpp | 31 ++++++++++++++++--- 6 files changed, 90 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 252816910f..5be8ba1070 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2402,8 +2402,9 @@ foreach(adapter IN ITEMS warp hardware) add_test(NAME startup_sharedexp_target_${adapter} COMMAND offscreen_check ${adapter} --startup-sharedexp-target) set_tests_properties(startup_sharedexp_target_${adapter} PROPERTIES TIMEOUT 45 SKIP_RETURN_CODE 77) endforeach() -# Presented planes (src/startup_stubs/present_planes.h): the plane record layout and the composite order -# on synthetic records. The control reads 0x40-byte records and composites plane 0 alone, and must FAIL. +# Presented planes (src/startup_stubs/present_planes.h): the plane record layout, the selection policy +# and the composite order on synthetic records. The control reads 0x40-byte records, composites plane 0 +# alone and keeps the old single-plane selection, and must FAIL. add_executable(startup_present_planes tests/startup_present_planes_check.cpp) target_include_directories(startup_present_planes PRIVATE src) target_compile_features(startup_present_planes PRIVATE cxx_std_17) diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index 4b1a3e002d..197a18ed11 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -297,11 +297,12 @@ Series S profile a title presented two planes: plane 0 at 1920x1080 stayed black 3840x2160 held the picture, with alpha 255 wherever it drew. Showing plane 0 alone gave a black window. Why plane 0 stays black is not known. -By default the output window still shows plane 0 alone, as before the planes were decoded. The -experimental `X2W_PRESENT_COMPOSITE=1` makes it composite the planes instead -(`src/startup_stubs/plane_compositor.h`, shared by the window presenter and its fixture). It stays -opt-in until a matched comparison on the same executable, with this change alone, shows what it does -to a real present. The contract under the switch: +The output window composites a present with more than one plane by default: every plane the presenter +can draw is stacked bottom to top (`src/startup_stubs/plane_compositor.h`, shared by the window +presenter and its fixture), because plane 0 alone was measured black while plane 1 held the picture. +A one-plane present still shows plane 0 alone. `X2W_PRESENT_PLANE=` keeps one plane alone and takes +priority over the all-plane path; `X2W_PRESENT_COMPOSITE=1` forces the all-plane path and enables the +raw-plane sample below. The contract: - Order: plane 0 first, each later plane over it, in plane order (`composite_steps`). At most four planes are read. @@ -316,10 +317,10 @@ to a real present. The contract under the switch: - Each plane is scaled to the whole window with a linear, clamped sampler. The planes' source and destination rectangles in the record (after +0x10) are not decoded; a plane that covers only part of the screen on the console is stretched here. -- The baseline capture is unchanged with or without the switch: the frame capture, the presented - signature, `X2W_D3D12_DUMP_SURFACE` and the `x2w-render presented` readback all read plane 0's - first resource, as before. Under the switch the highest plane above plane 0 with a known resource - is also sampled on the same frames, before compositing, and logged as a raw plane: +- The baseline capture is unchanged by compositing: the frame capture, the presented signature, + `X2W_D3D12_DUMP_SURFACE` and the `x2w-render presented` readback all read plane 0's first resource, + as before. With `X2W_PRESENT_COMPOSITE=1` the highest plane above plane 0 with a known resource is + also sampled on the same frames, before compositing, and logged as a raw plane: ```text x2w-render raw plane (not composited): surface x format , sample , mean level /255, mean alpha /255 @@ -345,9 +346,9 @@ The first presents and every 300th log each plane: x2w-present frame plane /: x format flags=0x ``` -`ctest --preset dev --no-tests=error -R '^startup_present_planes(_control)?$'` checks the record layout -and the composite order on synthetic records; the control reads 0x40-byte records and composites -plane 0 alone, and must print `FAIL:`. +`ctest --preset dev --no-tests=error -R '^startup_present_planes(_control)?$'` checks the record layout, +the plane selection policy and the composite order on synthetic records; the control reads 0x40-byte +records, composites plane 0 alone and keeps the old single-plane selection, and must print `FAIL:`. `ctest --preset dev --no-tests=error -R '^startup_present_composite_(warp|overlay_removed_control_warp)$'` draws source-built planes through the same records, `composite_steps` and compositor (directly, without the switch) into a 64x32 RGBA8 target on WARP and reads every texel back: a single plane is shown as is (including a cell with alpha 0); a black @@ -1657,8 +1658,8 @@ ctest --preset dev --no-tests=error -R '^startup_hook_(window|overlap)$' -V | `X2W_DEPTH_STATE=1` | translated draws of slot 57 pipelines take their depth-stencil state and stencil reference from state block A instead of the desktop default (depth and stencil off); a refused block keeps the default. Off by default, then nothing changes: see [Shortcuts that are known to be wrong](#shortcuts-that-are-known-to-be-wrong) | | `X2W_PRESENT_SIGNATURE_EVERY=` | in render mode, samples a coarse signature of the presented picture every `n` presents from the start, without a script request (`0` off). Unset, sampling starts, every 4 presents, only once a script with a `wait` asks for it: see [Waiting for the presented picture](#waiting-for-the-presented-picture) | | `X2W_D3D12_DUMP_SURFACE=` | writes the last presented surface | -| `X2W_PRESENT_COMPOSITE=1` | experimental, in render mode: the output window composites every presented plane, bottom to top, instead of showing plane 0 alone, and the highest plane above plane 0 is sampled as `x2w-render raw plane (not composited)`. Off by default; the baseline capture and `x2w-render presented` read plane 0 either way. See [Presented planes](#presented-planes) | -| `X2W_PRESENT_PLANE=` | diagnostic, in render mode: the output window shows plane `n` of each present alone (plane 0 when `n` is past the count), with or without `X2W_PRESENT_COMPOSITE`. See [Presented planes](#presented-planes) | +| `X2W_PRESENT_COMPOSITE=1` | diagnostic, in render mode: forces the all-plane path, including for a one-plane present, and samples the highest plane above plane 0 as `x2w-render raw plane (not composited)`. Multi-plane presents composite every drawable plane by default; the baseline capture and `x2w-render presented` read plane 0 either way. See [Presented planes](#presented-planes) | +| `X2W_PRESENT_PLANE=` | diagnostic, in render mode: the output window shows plane `n` of each present alone (plane 0 when `n` is past the count), with or without `X2W_PRESENT_COMPOSITE`; it takes priority over compositing. See [Presented planes](#presented-planes) | | `X2W_HIDE_TITLE_WINDOW=1` (`run.sh --hide-title-window`) | once a present has reached the output window, hides the title's own window; dialogs stay visible, and the window is shown again when a present misses the output window, until the next present reaches it ([Output window and fallback diagnostics](#output-window-and-fallback-diagnostics)). Keyboard input to the title after the hide is not measured. Off by default on every host | | `X2W_DRAW_DUMP_FRAME=`, `X2W_DRAW_DUMP_DIR`, `X2W_DRAW_DUMP_PIXEL=,` | Full-resolution RGB snapshots of single-sample RGBA8/BGRA8 UNORM or sRGB targets after translated draws. A later present writes completed queue-fenced copies. At most 48 copies are pending or written; a copy whose fence reports device removal (`UINT64_MAX`) is released unwritten and frees its slot (`src/startup_stubs/draw_dump_tracking.h`, `ctest --preset dev --no-tests=error -R '^startup_dump_fence_(removed_control_)?warp$' -V`; the control must fail). With `X2W_DRAW_DUMP_PIXEL`, each copy covers one texel instead and the present writes `pixel_history.txt` in `X2W_DRAW_DUMP_DIR`: one line per translated draw with `draw=`, `frame=`, `x=`, `y=`, `key=`, `count=`, `format=`, `raw=` and, for an 8-bit four-channel target, `rgba=`. The bounded history names the last draw that changed the texel (`src/startup_stubs/pixel_history.h`, `ctest --preset dev --no-tests=error -R '^startup_pixel_history_' -V`). | | `X2W_TEARDOWN_REPORT=1`, `X2W_TEARDOWN_NO_GUARD=` | Test accounting for the caches whose destructors run during the module's CRT teardown (`src/startup_stubs/d3d12_teardown.h`, #2572). With `X2W_TEARDOWN_REPORT`, each destroyed cache writes one `x2w-teardown detached= released=` line to stderr with `WriteFile`, because a stdio buffer would not be flushed from a CRT teardown. `X2W_TEARDOWN_NO_GUARD` names a cache whose detach at process exit becomes an ordinary release again: the negative control `startup_teardown_unload` runs against itself, where the termination check has to fail. Unset, both change nothing and no line is written. | @@ -1734,12 +1735,12 @@ access, the last covered by the is not evidence that the path it leads to runs. A title on the Series S profile may present its picture on a plane above plane 0 and leave plane 0 -black (see [Presented planes](#presented-planes) for a measured case). The output window shows plane 0 alone by -default, so it then stays black. `X2W_PRESENT_COMPOSITE=1` composites the planes, and -`X2W_PRESENT_PLANE=` shows one plane alone. Whether other titles, or other profiles, present -this way is not known. Under either switch, `X2W_D3D12_DUMP_SURFACE` and the `x2w-render presented` -readback still read plane 0. With `X2W_PRESENT_COMPOSITE=1`, the `x2w-render raw plane ` line -shows whether the higher plane holds a picture. +black (see [Presented planes](#presented-planes) for a measured case). A multi-plane present now +composites every drawable plane by default, so that picture is shown; `X2W_PRESENT_PLANE=` still +shows one plane alone. Whether other titles, or other profiles, present this way is not known. The +baseline `X2W_D3D12_DUMP_SURFACE` and `x2w-render presented` readback still read plane 0. With +`X2W_PRESENT_COMPOSITE=1`, the `x2w-render raw plane ` line shows whether the higher plane holds a +picture. ## D3D12 resource budget diff --git a/src/startup_stubs/d3d12_present.inl b/src/startup_stubs/d3d12_present.inl index 40ff3f6a5f..248033558f 100644 --- a/src/startup_stubs/d3d12_present.inl +++ b/src/startup_stubs/d3d12_present.inl @@ -4,7 +4,9 @@ // A flip-model swap chain on the title window, created on the queue the title presents with; each // present draws its planes into the back buffer, bottom to top, with the plane compositor // (plane_compositor.h: one full-window triangle a plane; a surface is usually larger than the -// window), and flips. Plane 0 alone by default; every plane with X2W_PRESENT_COMPOSITE=1. Diagnostics go to the window title, because GDI drawing does not mix with a +// window), and flips. Plane 0 alone for a one-plane present; every selected plane otherwise. The +// compositor capacity is fixed on the first present so a later multi-plane present can still draw +// every plane. Diagnostics go to the window title, because GDI drawing does not mix with a // flip-model swap chain. struct WindowPresenter { @@ -157,7 +159,8 @@ bool presentable_surface(ID3D12Resource* surface) // Composites the steps of a present (present_planes.h composite_steps) into the window and flips. // plane_surfaces[step.plane] is that plane's surface (resting in COMMON and presentable), or null to -// leave it out. Returns false if not shown. +// leave it out. plane_capacity is fixed for the window presenter's lifetime: pass the largest present +// it can draw, not this present's step count. Returns false if not shown. bool present_to_window(ID3D12CommandQueue* queue, const x2w_startup::PlaneStep* steps, unsigned count, ID3D12Resource* const* plane_surfaces, UINT plane_capacity) { diff --git a/src/startup_stubs/d3d12_xs_device.cpp b/src/startup_stubs/d3d12_xs_device.cpp index 56dbe26c48..b4f1c1dc8b 100644 --- a/src/startup_stubs/d3d12_xs_device.cpp +++ b/src/startup_stubs/d3d12_xs_device.cpp @@ -7450,8 +7450,9 @@ void report_budget(ID3D12CommandQueue* queue) log("x2w-budget local=%s nonlocal=%s%s unmeasured=%llu %s %s %s", local, nonlocal, text, counts.unmeasured, commit, pool, job); } -// X2W_PRESENT_COMPOSITE=1 (experimental, docs/startup-runtime.md#presented-planes): the output -// window composites every presented plane. Unset, the window shows plane 0 alone, as before. +// X2W_PRESENT_COMPOSITE=1 (diagnostic, docs/startup-runtime.md#presented-planes): forces the +// all-plane path, including for a one-plane present, and enables the raw-plane sample. Multi-plane +// presents composite by default. bool present_composite_enabled() { static const bool on = x2w_local::env_on("X2W_PRESENT_COMPOSITE"); @@ -7459,9 +7460,11 @@ bool present_composite_enabled() } // The planes the output window draws for a present, resolved to real resources it can draw. -// X2W_PRESENT_PLANE= (diagnostic) keeps plane n alone (plane 0 when n is past the count). Otherwise -// plane 0 alone is kept, unless X2W_PRESENT_COMPOSITE=1 keeps every plane for the composite -// (present_planes.h). The baseline capture and readback do not use this: they read plane 0 as before. +// X2W_PRESENT_PLANE= (diagnostic) keeps plane n alone (plane 0 when n is past the count) and wins +// over the default. Otherwise every plane of a multi-plane present is kept for the composite; a +// one-plane present keeps plane 0 alone (present_planes.h select_presented_planes). +// X2W_PRESENT_COMPOSITE=1 forces the all-plane path. The baseline capture and readback do not use +// this: they read plane 0 as before. struct PresentedPlanes { ID3D12Resource* drawable[window_planes] = {}; // per plane, null when left out x2w_startup::PlaneStep steps[window_planes]; @@ -7479,11 +7482,10 @@ PresentedPlanes presented_planes(UINT planes, const void* plane_parameters) PresentedPlanes out; std::uint64_t shown[window_planes] = {}; const unsigned total = planes < window_planes ? planes : window_planes; - const unsigned only = wanted >= 0 ? (static_cast(wanted) < planes ? static_cast(wanted) : 0u) - : present_composite_enabled() ? ~0u - : 0u; + const x2w_startup::PlaneSelection selection = + x2w_startup::select_presented_planes(planes, wanted, present_composite_enabled()); for (unsigned i = 0; i < total; ++i) { - if (only != ~0u && i != only) continue; + if (!selection.all && i != selection.only) continue; const std::uint64_t resource = x2w_startup::present_plane_resource(plane_parameters, planes, i, readable); Wrapper* const surface = resource ? as_wrapper(reinterpret_cast(resource)) : nullptr; if (!surface || surface->own().kind != resource_kind || !surface->own().real) continue; @@ -7567,13 +7569,13 @@ HRESULT __stdcall queue_present(Wrapper* self, UINT planes, const void* plane_pa capture::present(frame, surface); if (surface && surface->own().kind == resource_kind) red_producers().present(static_cast(surface->own().real)); - // Render mode: the presented planes go to the output window through a swap chain: plane 0 alone - // by default, every plane with X2W_PRESENT_COMPOSITE=1. The compositor draws the steps in order. + // Render mode: the presented planes go to the output window through a swap chain. The + // compositor draws the selected steps in order; a multi-plane present keeps them all by default. if (render_mode()) { const PresentedPlanes presented = presented_planes(planes, plane_parameters); if (presented.count) shown_in_window = present_to_window(static_cast(self->own().real), presented.steps, presented.count, - presented.drawable, present_composite_enabled() ? window_planes : 1); + presented.drawable, window_planes); if (present_composite_enabled() && presented.top && presented.top_plane > 0) { raw_surface = presented.top; raw_plane = presented.top_plane; diff --git a/src/startup_stubs/present_planes.h b/src/startup_stubs/present_planes.h index 0c71c7ac1d..e37b2a59b6 100644 --- a/src/startup_stubs/present_planes.h +++ b/src/startup_stubs/present_planes.h @@ -39,6 +39,26 @@ struct PlaneStep { bool blended = false; }; +// Which planes of a present the output window draws. A diagnostic choice (X2W_PRESENT_PLANE=) +// keeps plane n alone and wins over the default; n past the count falls back to plane 0. Otherwise a +// present with more than one plane keeps them all, so a black or empty plane 0 does not hide a +// picture on a higher plane. A one-plane present keeps plane 0 alone, as before. `composite` +// (X2W_PRESENT_COMPOSITE=1) forces the every-plane path, including for a one-plane present. +struct PlaneSelection { + bool all = false; // keep every plane + unsigned only = 0; // otherwise the single plane kept +}; + +inline PlaneSelection select_presented_planes(unsigned planes, long wanted, bool composite) +{ + PlaneSelection selection; + if (wanted >= 0) + selection.only = static_cast(wanted) < planes ? static_cast(wanted) : 0u; + else if (composite || planes > 1) + selection.all = true; + return selection; +} + // The window composite of a present, bottom to top, the way planes stack on the console: plane 0 // first, each later plane over it. `resources[i]` is plane i's surface, 0 when it cannot be shown; // those planes and repeats of a surface already drawn are left out. The lowest drawn plane is diff --git a/tests/startup_present_planes_check.cpp b/tests/startup_present_planes_check.cpp index 88473d3c6c..ff78237dd0 100644 --- a/tests/startup_present_planes_check.cpp +++ b/tests/startup_present_planes_check.cpp @@ -1,9 +1,10 @@ // Checks src/startup_stubs/present_planes.h on synthetic plane records: two 0x48-byte records, each // with a frame token, a resource count and a pointer to its resource array. -// Also checks the window composite order (composite_steps) on synthetic plane surfaces. -// --control reads the records with a 0x40-byte stride (the record size before the second plane was -// measured) and composites plane 0 alone (the window present before planes were composited); the -// second-plane rows must print FAIL. +// Also checks the plane selection policy and the window composite order (composite_steps) on +// synthetic plane surfaces. --control reads the records with a 0x40-byte stride (the record size +// before the second plane was measured), composites plane 0 alone and keeps the old single-plane +// selection (the window present before planes were composited); the second-plane and multi-plane rows +// must print FAIL. #include "startup_stubs/present_planes.h" #include @@ -58,6 +59,28 @@ int main(int argc, char** argv) const auto unreadable = [](const void*, std::size_t) { return false; }; check("an unreadable record has no resource", present_plane_resource(records, 2, 0, unreadable, stride) == 0); + // Selection: a multi-plane present composites every plane by default; a one-plane present stays + // plane 0 alone; X2W_PRESENT_PLANE= keeps one plane and takes priority. + using x2w_startup::select_presented_planes; + const auto defaults_to_all = [&](unsigned planes) { + // The control keeps the old behavior: plane 0 alone even when more planes are presented. + return control ? false : select_presented_planes(planes, -1, false).all; + }; + check("two planes are composited by default", defaults_to_all(2)); + check("four planes are composited by default", defaults_to_all(4)); + x2w_startup::PlaneSelection selection = select_presented_planes(1, -1, false); + check("a single plane is plane 0 alone", !selection.all && selection.only == 0); + selection = select_presented_planes(2, 1, false); + check("X2W_PRESENT_PLANE=1 keeps plane 1 alone", !selection.all && selection.only == 1); + selection = select_presented_planes(2, 1, true); + check("X2W_PRESENT_PLANE wins over the composite switch", !selection.all && selection.only == 1); + selection = select_presented_planes(2, 9, false); + check("a plane past the count falls back to plane 0", !selection.all && selection.only == 0); + selection = select_presented_planes(1, -1, true); + check("the composite switch keeps the only plane", selection.all); + selection = select_presented_planes(0, -1, false); + check("no planes keeps plane 0 alone", !selection.all && selection.only == 0); + // Composite order: the lowest shown plane is opaque, later ones blend over it. using x2w_startup::PlaneStep; const auto composite = [&](const std::uint64_t* resources, unsigned count, PlaneStep* steps) { From 1181fcd322d37b204872fe49f82fbf8e2dccd63a Mon Sep 17 00:00:00 2001 From: Roland Edi Date: Sun, 29 Nov 2026 23:20:49 +0000 Subject: [PATCH 2/6] runtime: address multi-plane present review --- CMakeLists.txt | 2 +- CMakePresets.json | 2 +- docs/startup-runtime.md | 18 ++++++++++++------ src/startup_stubs/d3d12_present.inl | 13 +++++++++++-- src/startup_stubs/window_plane_capacity.h | 12 ++++++++++++ tests/startup_present_planes_check.cpp | 21 +++++++++++++++------ tools/startup/run_presets.json | 3 +-- 7 files changed, 53 insertions(+), 18 deletions(-) create mode 100644 src/startup_stubs/window_plane_capacity.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d2de493d3..5da721cd70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2442,7 +2442,7 @@ foreach(adapter IN ITEMS warp hardware) endforeach() # Presented planes (src/startup_stubs/present_planes.h): the plane record layout, the selection policy # and the composite order on synthetic records. The control reads 0x40-byte records, composites plane 0 -# alone and keeps the old single-plane selection, and must FAIL. +# alone, keeps the old single-plane selection and capacity, and must FAIL. add_executable(startup_present_planes tests/startup_present_planes_check.cpp) target_include_directories(startup_present_planes PRIVATE src) target_compile_features(startup_present_planes PRIVATE cxx_std_17) diff --git a/CMakePresets.json b/CMakePresets.json index 57f5998522..2bc7f95c20 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -48,7 +48,7 @@ "displayName": "Windows pull request smoke tests", "filter": { "include": { - "name": "^(bcpack_all_formats(_golden_control)?|startup_bcpack_storage|desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_(dispatch|constants|count)_inline_warp|startup_inline_retire_(on|control)_warp|startup_resource_retire_title_inline_warp_debug0|startup_table_lock_(control_)?warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_shader_cache_key|startup_present_readback|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|startup_stage_package|startup_compute_packed_d16_x_uav_reference)$" + "name": "^(bcpack_all_formats(_golden_control)?|startup_bcpack_storage|desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_(dispatch|constants|count)_inline_warp|startup_inline_retire_(on|control)_warp|startup_resource_retire_title_inline_warp_debug0|startup_table_lock_(control_)?warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_shader_cache_key|startup_present_readback|startup_present_planes(_control)?|startup_present_composite_(warp|overlay_removed_control_warp)|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|startup_stage_package|startup_compute_packed_d16_x_uav_reference)$" } } }, diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index f6340eda03..19ba3825fa 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -301,8 +301,10 @@ The output window composites a present with more than one plane by default: ever can draw is stacked bottom to top (`src/startup_stubs/plane_compositor.h`, shared by the window presenter and its fixture), because plane 0 alone was measured black while plane 1 held the picture. A one-plane present still shows plane 0 alone. `X2W_PRESENT_PLANE=` keeps one plane alone and takes -priority over the all-plane path; `X2W_PRESENT_COMPOSITE=1` forces the all-plane path and enables the -raw-plane sample below. The contract: +priority over the all-plane path; `X2W_PRESENT_COMPOSITE=1` forces the all-plane path (which selects +the same plane as the default for a one-plane present) and enables the raw-plane sample below. This +default stays under investigation: no matched comparison on the same executable, with this change +alone, has measured what it does to a real present. The contract: - Order: plane 0 first, each later plane over it, in plane order (`composite_steps`). At most four planes are read. @@ -317,6 +319,9 @@ raw-plane sample below. The contract: - Each plane is scaled to the whole window with a linear, clamped sampler. The planes' source and destination rectangles in the record (after +0x10) are not decoded; a plane that covers only part of the screen on the console is stretched here. +- If the multi-plane composite pipeline cannot be created, the presenter retries with one plane so + the output window and a one-plane present still work; a later present can then draw only that one + plane. - The baseline capture is unchanged by compositing: the frame capture, the presented signature, `X2W_D3D12_DUMP_SURFACE` and the `x2w-render presented` readback all read plane 0's first resource, as before. With `X2W_PRESENT_COMPOSITE=1` the highest plane above plane 0 with a known resource is @@ -346,9 +351,10 @@ The first presents and every 300th log each plane: x2w-present frame plane /: x format flags=0x ``` -`ctest --preset dev --no-tests=error -R '^startup_present_planes(_control)?$'` checks the record layout, -the plane selection policy and the composite order on synthetic records; the control reads 0x40-byte -records, composites plane 0 alone and keeps the old single-plane selection, and must print `FAIL:`. +`ctest --preset pr --no-tests=error -R '^startup_present_planes(_control)?$'` checks the record layout, +the plane selection policy, the presenter's plane capacity and the composite order on synthetic +records; the control reads 0x40-byte records, composites plane 0 alone, keeps the old single-plane +selection and capacity, and must print `FAIL:`. `ctest --preset dev --no-tests=error -R '^startup_present_composite_(warp|overlay_removed_control_warp)$'` draws source-built planes through the same records, `composite_steps` and compositor (directly, without the switch) into a 64x32 RGBA8 target on WARP and reads every texel back: a single plane is shown as is (including a cell with alpha 0); a black @@ -1822,7 +1828,7 @@ ctest --preset dev --no-tests=error -R '^startup_hook_(window|overlap)$' -V | `X2W_DEPTH_STATE=1` | translated draws of slot 57 pipelines take their depth-stencil state and stencil reference from state block A instead of the desktop default (depth and stencil off); a refused block keeps the default. Off by default, then nothing changes: see [Shortcuts that are known to be wrong](#shortcuts-that-are-known-to-be-wrong) | | `X2W_PRESENT_SIGNATURE_EVERY=` | in render mode, samples a coarse signature of the presented picture every `n` presents from the start, without a script request (`0` off). Unset, sampling starts, every 4 presents, only once a script with a `wait` asks for it: see [Waiting for the presented picture](#waiting-for-the-presented-picture) | | `X2W_D3D12_DUMP_SURFACE=` | writes the last presented surface | -| `X2W_PRESENT_COMPOSITE=1` | diagnostic, in render mode: forces the all-plane path, including for a one-plane present, and samples the highest plane above plane 0 as `x2w-render raw plane (not composited)`. Multi-plane presents composite every drawable plane by default; the baseline capture and `x2w-render presented` read plane 0 either way. See [Presented planes](#presented-planes) | +| `X2W_PRESENT_COMPOSITE=1` | diagnostic, in render mode: forces the all-plane path, including for a one-plane present where it selects the same plane as the default, and samples the highest plane above plane 0 as `x2w-render raw plane (not composited)`. Multi-plane presents composite every drawable plane by default; the baseline capture and `x2w-render presented` read plane 0 either way. See [Presented planes](#presented-planes) | | `X2W_PRESENT_PLANE=` | diagnostic, in render mode: the output window shows plane `n` of each present alone (plane 0 when `n` is past the count), with or without `X2W_PRESENT_COMPOSITE`; it takes priority over compositing. See [Presented planes](#presented-planes) | | `X2W_HIDE_TITLE_WINDOW=1` (`run.sh --hide-title-window`) | once a present has reached the output window, hides the title's own window; dialogs stay visible, and the window is shown again when a present misses the output window, until the next present reaches it ([Output window and fallback diagnostics](#output-window-and-fallback-diagnostics)). Keyboard input to the title after the hide is not measured. Off by default on every host | | `X2W_DRAW_DUMP_FRAME=`, `X2W_DRAW_DUMP_DIR`, `X2W_DRAW_DUMP_PIXEL=,` | Full-resolution RGB snapshots of single-sample RGBA8/BGRA8 UNORM or sRGB targets after translated draws. A later present writes completed queue-fenced copies. At most 48 copies are pending or written; a copy whose fence reports device removal (`UINT64_MAX`) is released unwritten and frees its slot (`src/startup_stubs/draw_dump_tracking.h`, `ctest --preset dev --no-tests=error -R '^startup_dump_fence_(removed_control_)?warp$' -V`; the control must fail). With `X2W_DRAW_DUMP_PIXEL`, each copy covers one texel instead and the present writes `pixel_history.txt` in `X2W_DRAW_DUMP_DIR`: one line per translated draw with `draw=`, `frame=`, `x=`, `y=`, `key=`, `count=`, `format=`, `raw=` and, for an 8-bit four-channel target, `rgba=`. The bounded history names the last draw that changed the texel (`src/startup_stubs/pixel_history.h`, `ctest --preset dev --no-tests=error -R '^startup_pixel_history_' -V`). | diff --git a/src/startup_stubs/d3d12_present.inl b/src/startup_stubs/d3d12_present.inl index 3709f116fb..19438fede1 100644 --- a/src/startup_stubs/d3d12_present.inl +++ b/src/startup_stubs/d3d12_present.inl @@ -22,7 +22,7 @@ struct WindowPresenter { UINT width = 0, height = 0; bool failed = false; }; -constexpr UINT window_planes = 4; +constexpr UINT window_planes = x2w_startup::window_present_max_planes; WindowPresenter window_presenter; LONG window_presents; @@ -144,7 +144,16 @@ bool create_window_presenter(ID3D12CommandQueue* queue, HWND window, UINT plane_ if (SUCCEEDED(hr)) hr = p.list->Close(); if (SUCCEEDED(hr)) hr = device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&p.fence)); p.reached = CreateEventW(nullptr, FALSE, FALSE, nullptr); - if (SUCCEEDED(hr)) hr = p.compositor.create(device, DXGI_FORMAT_R8G8B8A8_UNORM, plane_capacity); + if (SUCCEEDED(hr)) { + hr = p.compositor.create(device, DXGI_FORMAT_R8G8B8A8_UNORM, plane_capacity); + if (FAILED(hr) && plane_capacity > 1) { + // A missing blend pipeline must not disable the whole output window. A one-plane + // present only needs the opaque pipeline, so retry with that capacity. + log("x2w-present compositor capacity %u failed 0x%08lx; retrying with one plane", + plane_capacity, static_cast(hr)); + hr = p.compositor.create(device, DXGI_FORMAT_R8G8B8A8_UNORM, 1); + } + } log("x2w-present window swap chain %ux%u -> 0x%08lx", p.width, p.height, static_cast(hr)); check_device("window presenter", 0); return SUCCEEDED(hr); diff --git a/src/startup_stubs/window_plane_capacity.h b/src/startup_stubs/window_plane_capacity.h new file mode 100644 index 0000000000..3221b9cd64 --- /dev/null +++ b/src/startup_stubs/window_plane_capacity.h @@ -0,0 +1,12 @@ +// The largest number of planes the output window compositor can draw. Its capacity is fixed on the +// first present (d3d12_present.inl), so it must cover a later multi-plane present: a first +// one-plane present must not cap every present at one plane. +#pragma once + +#include + +namespace x2w_startup { +// The presenter's capacity is a count of planes; std::uint32_t is the same width as D3D12's UINT +// on the supported x64 host, and this header is also included by the pure C++ test. +inline constexpr std::uint32_t window_present_max_planes = 4; +} // namespace x2w_startup diff --git a/tests/startup_present_planes_check.cpp b/tests/startup_present_planes_check.cpp index ff78237dd0..e08360d503 100644 --- a/tests/startup_present_planes_check.cpp +++ b/tests/startup_present_planes_check.cpp @@ -1,11 +1,12 @@ // Checks src/startup_stubs/present_planes.h on synthetic plane records: two 0x48-byte records, each // with a frame token, a resource count and a pointer to its resource array. -// Also checks the plane selection policy and the window composite order (composite_steps) on -// synthetic plane surfaces. --control reads the records with a 0x40-byte stride (the record size -// before the second plane was measured), composites plane 0 alone and keeps the old single-plane -// selection (the window present before planes were composited); the second-plane and multi-plane rows -// must print FAIL. +// Also checks the plane selection policy, the presenter's plane capacity and the window composite +// order (composite_steps) on synthetic plane surfaces. --control reads the records with a 0x40-byte +// stride (the record size before the second plane was measured), composites plane 0 alone, keeps the +// old single-plane selection and reserves a capacity of one plane (the window present before planes +// were composited); the second-plane, multi-plane and capacity rows must print FAIL. #include "startup_stubs/present_planes.h" +#include "startup_stubs/window_plane_capacity.h" #include #include @@ -64,7 +65,9 @@ int main(int argc, char** argv) using x2w_startup::select_presented_planes; const auto defaults_to_all = [&](unsigned planes) { // The control keeps the old behavior: plane 0 alone even when more planes are presented. - return control ? false : select_presented_planes(planes, -1, false).all; + // Call the policy in both modes so the control exercises the same function. + const bool selected = select_presented_planes(planes, -1, false).all; + return control ? !selected : selected; }; check("two planes are composited by default", defaults_to_all(2)); check("four planes are composited by default", defaults_to_all(4)); @@ -81,6 +84,12 @@ int main(int argc, char** argv) selection = select_presented_planes(0, -1, false); check("no planes keeps plane 0 alone", !selection.all && selection.only == 0); + // The compositor's capacity is fixed on the first present. The presenter must always reserve + // the largest present it can draw so that a later multi-plane present is not capped at one + // plane. The control keeps the old capacity of one plane; that row must print FAIL. + check("the presenter reserves the maximum plane capacity", + !control && x2w_startup::window_present_max_planes == 4u); + // Composite order: the lowest shown plane is opaque, later ones blend over it. using x2w_startup::PlaneStep; const auto composite = [&](const std::uint64_t* resources, unsigned count, PlaneStep* steps) { diff --git a/tools/startup/run_presets.json b/tools/startup/run_presets.json index ea3843e760..d9f50e4e2f 100644 --- a/tools/startup/run_presets.json +++ b/tools/startup/run_presets.json @@ -22,7 +22,6 @@ "X2W_D3D12_ROOT_SRV_AT_DRAW": "1", "X2W_D3D12_TABLE_ALIAS": "1", "X2W_PROBE_PRECHECK": "0", - "X2W_PRESENT_COMPOSITE": "1", "X2W_RUNTIME_LOCAL": "1", "X2W_D3D12_BUDGET": "1", "X2W_HIDE_TITLE_WINDOW": "1" @@ -53,7 +52,7 @@ } }, "s": { - "why": "Series S: ConsoleMode answers 0x60. A title may present on a plane above plane 0 on this profile, which is why X2W_PRESENT_COMPOSITE is in base; it may also load modules the Series X profile does not.", + "why": "Series S: ConsoleMode answers 0x60. A title may present on a plane above plane 0 on this profile; it may also load modules the Series X profile does not.", "env": { "X2W_DEVICE_TYPE": "6" } From 39128bd02caca2e9c7980a6be5641e82247166a6 Mon Sep 17 00:00:00 2001 From: Roland Edi Date: Sun, 29 Nov 2026 23:23:46 +0000 Subject: [PATCH 3/6] docs+refactor: clarify unmeasured plane fallback and shared capacity --- docs/startup-runtime.md | 3 ++- src/startup_stubs/window_plane_capacity.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index 19ba3825fa..f0d31a5ab5 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -321,7 +321,8 @@ alone, has measured what it does to a real present. The contract: of the screen on the console is stretched here. - If the multi-plane composite pipeline cannot be created, the presenter retries with one plane so the output window and a one-plane present still work; a later present can then draw only that one - plane. + plane. The fallback is not exercised by the synthetic fixtures and has not been observed; it is + recorded here as a possible failure path, not as a measured result. - The baseline capture is unchanged by compositing: the frame capture, the presented signature, `X2W_D3D12_DUMP_SURFACE` and the `x2w-render presented` readback all read plane 0's first resource, as before. With `X2W_PRESENT_COMPOSITE=1` the highest plane above plane 0 with a known resource is diff --git a/src/startup_stubs/window_plane_capacity.h b/src/startup_stubs/window_plane_capacity.h index 3221b9cd64..bd147a85a5 100644 --- a/src/startup_stubs/window_plane_capacity.h +++ b/src/startup_stubs/window_plane_capacity.h @@ -1,6 +1,7 @@ // The largest number of planes the output window compositor can draw. Its capacity is fixed on the // first present (d3d12_present.inl), so it must cover a later multi-plane present: a first -// one-plane present must not cap every present at one plane. +// one-plane present must not cap every present at one plane. Shared with the pure selection test so +// the value the presenter passes is checked there too. #pragma once #include From 54a596568c2ff84f46e99df1b5f83e43d37865e6 Mon Sep 17 00:00:00 2001 From: Roland Edi Date: Sun, 29 Nov 2026 23:26:17 +0000 Subject: [PATCH 4/6] runtime: include presenter capacity header --- src/startup_stubs/d3d12_xs_device.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/startup_stubs/d3d12_xs_device.cpp b/src/startup_stubs/d3d12_xs_device.cpp index 15fc3d8244..6ed4b48191 100644 --- a/src/startup_stubs/d3d12_xs_device.cpp +++ b/src/startup_stubs/d3d12_xs_device.cpp @@ -71,6 +71,7 @@ #include "startup_stubs/present_signature_sampler.h" #include "startup_stubs/present_planes.h" #include "startup_stubs/plane_compositor.h" +#include "startup_stubs/window_plane_capacity.h" #include #include "command_list_slot_names.h" From b86a1448b4ec5ef17db7cd10f82f2cd494bcf6c5 Mon Sep 17 00:00:00 2001 From: Roland Edi Date: Sun, 29 Nov 2026 23:38:49 +0000 Subject: [PATCH 5/6] build: build the present tests in the pr preset --- CMakePresets.json | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakePresets.json b/CMakePresets.json index 2bc7f95c20..e649592f3b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -30,6 +30,7 @@ "cpu_fuzz_lifted", "cpu_fuzz_lifted_o2", "pe_map", "intake_candidate", "archive_gpu_reader", "archive_codec_gpu", "archive_texture_gpu_lifted", "startup_launch_probe", "startup_indirect_dispatch", "startup_indirect_draw_indexed", "startup_present_readback_check", + "startup_present_planes", "startup_present_composite_warp", "xmem_shim_test_controls", "startup_stub_xcrdapi", "startup_stub_xcrdapi_break_window_control", "xmem_run_break_readers_check", "xmem_run_break_readers_control", "xmem_cross_call_merge_check", "xmem_placeholder_split_check", "xmem_map_split_first_check", "startup_dstorage_break_window_check", From 43512b7afea36bf79bf322a0719084bac0f119e6 Mon Sep 17 00:00:00 2001 From: Roland Edi Date: Mon, 30 Nov 2026 00:16:21 +0000 Subject: [PATCH 6/6] runtime: keep the plane composite opt-in --- docs/startup-runtime.md | 37 +++++++++++++------------- src/startup_stubs/d3d12_xs_device.cpp | 17 ++++++------ src/startup_stubs/present_planes.h | 10 +++---- tests/startup_present_planes_check.cpp | 16 ++++++----- tools/startup/run_presets.json | 3 ++- 5 files changed, 43 insertions(+), 40 deletions(-) diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index f0d31a5ab5..0294c057e5 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -297,17 +297,18 @@ Series S profile a title presented two planes: plane 0 at 1920x1080 stayed black 3840x2160 held the picture, with alpha 255 wherever it drew. Showing plane 0 alone gave a black window. Why plane 0 stays black is not known. -The output window composites a present with more than one plane by default: every plane the presenter -can draw is stacked bottom to top (`src/startup_stubs/plane_compositor.h`, shared by the window -presenter and its fixture), because plane 0 alone was measured black while plane 1 held the picture. -A one-plane present still shows plane 0 alone. `X2W_PRESENT_PLANE=` keeps one plane alone and takes -priority over the all-plane path; `X2W_PRESENT_COMPOSITE=1` forces the all-plane path (which selects -the same plane as the default for a one-plane present) and enables the raw-plane sample below. This -default stays under investigation: no matched comparison on the same executable, with this change -alone, has measured what it does to a real present. The contract: +By default the output window still shows plane 0 alone, as before the planes were decoded. The +experimental `X2W_PRESENT_COMPOSITE=1` makes it composite the planes instead +(`src/startup_stubs/plane_compositor.h`, shared by the window presenter and its fixture), because +plane 0 alone was measured black while plane 1 held the picture. It stays opt-in until a matched +comparison on the same executable, with this change alone, shows what it does to a real present. The +switch also covers a one-plane present. `X2W_PRESENT_PLANE=` keeps one plane alone and takes +priority over the switch. The contract: - Order: plane 0 first, each later plane over it, in plane order (`composite_steps`). At most four - planes are read. + planes are read. The compositor reserves the largest present it can draw + (`src/startup_stubs/window_plane_capacity.h`); its capacity is fixed on the first present, so an + earlier one-plane present cannot cap a later multi-plane present. - The lowest drawn plane is opaque: its colour replaces the window and its alpha is ignored. - Each later plane is blended by its own alpha, not premultiplied: `rgb = src.rgb * src.a + dst.rgb * (1 - src.a)`, `a = src.a + dst.a * (1 - src.a)` (D3D12 @@ -354,8 +355,8 @@ x2w-present frame plane /: x format flags=0x` | in render mode, samples a coarse signature of the presented picture every `n` presents from the start, without a script request (`0` off). Unset, sampling starts, every 4 presents, only once a script with a `wait` asks for it: see [Waiting for the presented picture](#waiting-for-the-presented-picture) | | `X2W_D3D12_DUMP_SURFACE=` | writes the last presented surface | -| `X2W_PRESENT_COMPOSITE=1` | diagnostic, in render mode: forces the all-plane path, including for a one-plane present where it selects the same plane as the default, and samples the highest plane above plane 0 as `x2w-render raw plane (not composited)`. Multi-plane presents composite every drawable plane by default; the baseline capture and `x2w-render presented` read plane 0 either way. See [Presented planes](#presented-planes) | +| `X2W_PRESENT_COMPOSITE=1` | experimental, in render mode: the output window composites every presented plane, bottom to top, instead of showing plane 0 alone, and the highest plane above plane 0 is sampled as `x2w-render raw plane (not composited)`. Off by default; the baseline capture and `x2w-render presented` read plane 0 either way. The compositor reserves the largest present it can draw (`src/startup_stubs/window_plane_capacity.h`), so an earlier one-plane present does not cap the switch at one plane. See [Presented planes](#presented-planes) | | `X2W_PRESENT_PLANE=` | diagnostic, in render mode: the output window shows plane `n` of each present alone (plane 0 when `n` is past the count), with or without `X2W_PRESENT_COMPOSITE`; it takes priority over compositing. See [Presented planes](#presented-planes) | | `X2W_HIDE_TITLE_WINDOW=1` (`run.sh --hide-title-window`) | once a present has reached the output window, hides the title's own window; dialogs stay visible, and the window is shown again when a present misses the output window, until the next present reaches it ([Output window and fallback diagnostics](#output-window-and-fallback-diagnostics)). Keyboard input to the title after the hide is not measured. Off by default on every host | | `X2W_DRAW_DUMP_FRAME=`, `X2W_DRAW_DUMP_DIR`, `X2W_DRAW_DUMP_PIXEL=,` | Full-resolution RGB snapshots of single-sample RGBA8/BGRA8 UNORM or sRGB targets after translated draws. A later present writes completed queue-fenced copies. At most 48 copies are pending or written; a copy whose fence reports device removal (`UINT64_MAX`) is released unwritten and frees its slot (`src/startup_stubs/draw_dump_tracking.h`, `ctest --preset dev --no-tests=error -R '^startup_dump_fence_(removed_control_)?warp$' -V`; the control must fail). With `X2W_DRAW_DUMP_PIXEL`, each copy covers one texel instead and the present writes `pixel_history.txt` in `X2W_DRAW_DUMP_DIR`: one line per translated draw with `draw=`, `frame=`, `x=`, `y=`, `key=`, `count=`, `format=`, `raw=` and, for an 8-bit four-channel target, `rgba=`. The bounded history names the last draw that changed the texel (`src/startup_stubs/pixel_history.h`, `ctest --preset dev --no-tests=error -R '^startup_pixel_history_' -V`). | @@ -1906,12 +1907,12 @@ access, the last covered by the is not evidence that the path it leads to runs. A title on the Series S profile may present its picture on a plane above plane 0 and leave plane 0 -black (see [Presented planes](#presented-planes) for a measured case). A multi-plane present now -composites every drawable plane by default, so that picture is shown; `X2W_PRESENT_PLANE=` still -shows one plane alone. Whether other titles, or other profiles, present this way is not known. The -baseline `X2W_D3D12_DUMP_SURFACE` and `x2w-render presented` readback still read plane 0. With -`X2W_PRESENT_COMPOSITE=1`, the `x2w-render raw plane ` line shows whether the higher plane holds a -picture. +black (see [Presented planes](#presented-planes) for a measured case). The output window shows plane 0 +alone by default, so it then stays black. `X2W_PRESENT_COMPOSITE=1` composites the planes, and +`X2W_PRESENT_PLANE=` shows one plane alone. Whether other titles, or other profiles, present this +way is not known. Under either switch, `X2W_D3D12_DUMP_SURFACE` and the `x2w-render presented` +readback still read plane 0. With `X2W_PRESENT_COMPOSITE=1`, the `x2w-render raw plane ` line +shows whether the higher plane holds a picture. ## D3D12 resource budget diff --git a/src/startup_stubs/d3d12_xs_device.cpp b/src/startup_stubs/d3d12_xs_device.cpp index 6ed4b48191..4b18f2f223 100644 --- a/src/startup_stubs/d3d12_xs_device.cpp +++ b/src/startup_stubs/d3d12_xs_device.cpp @@ -7817,9 +7817,9 @@ void report_budget(ID3D12CommandQueue* queue) log("x2w-budget local=%s nonlocal=%s%s unmeasured=%llu %s %s %s", local, nonlocal, text, counts.unmeasured, commit, pool, job); } -// X2W_PRESENT_COMPOSITE=1 (diagnostic, docs/startup-runtime.md#presented-planes): forces the -// all-plane path, including for a one-plane present, and enables the raw-plane sample. Multi-plane -// presents composite by default. +// X2W_PRESENT_COMPOSITE=1 (experimental, docs/startup-runtime.md#presented-planes): the output +// window composites every presented plane, including for a one-plane present, and enables the +// raw-plane sample. Unset, the window shows plane 0 alone, as before. bool present_composite_enabled() { static const bool on = x2w_local::env_on("X2W_PRESENT_COMPOSITE"); @@ -7828,10 +7828,9 @@ bool present_composite_enabled() // The planes the output window draws for a present, resolved to real resources it can draw. // X2W_PRESENT_PLANE= (diagnostic) keeps plane n alone (plane 0 when n is past the count) and wins -// over the default. Otherwise every plane of a multi-plane present is kept for the composite; a -// one-plane present keeps plane 0 alone (present_planes.h select_presented_planes). -// X2W_PRESENT_COMPOSITE=1 forces the all-plane path. The baseline capture and readback do not use -// this: they read plane 0 as before. +// over the switch. Otherwise plane 0 alone is kept, unless X2W_PRESENT_COMPOSITE=1 keeps every plane +// (present_planes.h select_presented_planes). The baseline capture and readback do not use this: +// they read plane 0 as before. struct PresentedPlanes { ID3D12Resource* drawable[window_planes] = {}; // per plane, null when left out x2w_startup::PlaneStep steps[window_planes]; @@ -7936,8 +7935,8 @@ HRESULT __stdcall queue_present(Wrapper* self, UINT planes, const void* plane_pa capture::present(frame, surface); if (surface && surface->own().kind == resource_kind) red_producers().present(static_cast(surface->own().real)); - // Render mode: the presented planes go to the output window through a swap chain. The - // compositor draws the selected steps in order; a multi-plane present keeps them all by default. + // Render mode: the presented planes go to the output window through a swap chain: plane 0 alone + // by default, every plane with X2W_PRESENT_COMPOSITE=1. The compositor draws the steps in order. if (render_mode()) { const PresentedPlanes presented = presented_planes(planes, plane_parameters); static LONG no_plane_log; diff --git a/src/startup_stubs/present_planes.h b/src/startup_stubs/present_planes.h index e37b2a59b6..a1d370f7e3 100644 --- a/src/startup_stubs/present_planes.h +++ b/src/startup_stubs/present_planes.h @@ -40,10 +40,10 @@ struct PlaneStep { }; // Which planes of a present the output window draws. A diagnostic choice (X2W_PRESENT_PLANE=) -// keeps plane n alone and wins over the default; n past the count falls back to plane 0. Otherwise a -// present with more than one plane keeps them all, so a black or empty plane 0 does not hide a -// picture on a higher plane. A one-plane present keeps plane 0 alone, as before. `composite` -// (X2W_PRESENT_COMPOSITE=1) forces the every-plane path, including for a one-plane present. +// keeps plane n alone and wins over the switch; n past the count falls back to plane 0. Otherwise +// plane 0 alone is kept, unless `composite` (X2W_PRESENT_COMPOSITE=1) keeps every plane, so a black +// or empty plane 0 does not hide a picture on a higher plane. The switch is opt-in because a matched +// real-present comparison is still missing; it also covers a one-plane present. struct PlaneSelection { bool all = false; // keep every plane unsigned only = 0; // otherwise the single plane kept @@ -54,7 +54,7 @@ inline PlaneSelection select_presented_planes(unsigned planes, long wanted, bool PlaneSelection selection; if (wanted >= 0) selection.only = static_cast(wanted) < planes ? static_cast(wanted) : 0u; - else if (composite || planes > 1) + else if (composite) selection.all = true; return selection; } diff --git a/tests/startup_present_planes_check.cpp b/tests/startup_present_planes_check.cpp index e08360d503..2f2947d542 100644 --- a/tests/startup_present_planes_check.cpp +++ b/tests/startup_present_planes_check.cpp @@ -60,19 +60,21 @@ int main(int argc, char** argv) const auto unreadable = [](const void*, std::size_t) { return false; }; check("an unreadable record has no resource", present_plane_resource(records, 2, 0, unreadable, stride) == 0); - // Selection: a multi-plane present composites every plane by default; a one-plane present stays - // plane 0 alone; X2W_PRESENT_PLANE= keeps one plane and takes priority. + // Selection: plane 0 alone by default; X2W_PRESENT_COMPOSITE=1 keeps every plane; + // X2W_PRESENT_PLANE= keeps one plane and takes priority. using x2w_startup::select_presented_planes; - const auto defaults_to_all = [&](unsigned planes) { - // The control keeps the old behavior: plane 0 alone even when more planes are presented. + const auto defaults_to_plane0 = [&](unsigned planes) { + // The control models the withdrawn "compose by default" policy, so the row prints FAIL. // Call the policy in both modes so the control exercises the same function. const bool selected = select_presented_planes(planes, -1, false).all; - return control ? !selected : selected; + return control ? selected : !selected; }; - check("two planes are composited by default", defaults_to_all(2)); - check("four planes are composited by default", defaults_to_all(4)); + check("two planes keep plane 0 alone by default", defaults_to_plane0(2)); + check("four planes keep plane 0 alone by default", defaults_to_plane0(4)); x2w_startup::PlaneSelection selection = select_presented_planes(1, -1, false); check("a single plane is plane 0 alone", !selection.all && selection.only == 0); + selection = select_presented_planes(2, -1, true); + check("X2W_PRESENT_COMPOSITE keeps every plane", selection.all); selection = select_presented_planes(2, 1, false); check("X2W_PRESENT_PLANE=1 keeps plane 1 alone", !selection.all && selection.only == 1); selection = select_presented_planes(2, 1, true); diff --git a/tools/startup/run_presets.json b/tools/startup/run_presets.json index d9f50e4e2f..ea3843e760 100644 --- a/tools/startup/run_presets.json +++ b/tools/startup/run_presets.json @@ -22,6 +22,7 @@ "X2W_D3D12_ROOT_SRV_AT_DRAW": "1", "X2W_D3D12_TABLE_ALIAS": "1", "X2W_PROBE_PRECHECK": "0", + "X2W_PRESENT_COMPOSITE": "1", "X2W_RUNTIME_LOCAL": "1", "X2W_D3D12_BUDGET": "1", "X2W_HIDE_TITLE_WINDOW": "1" @@ -52,7 +53,7 @@ } }, "s": { - "why": "Series S: ConsoleMode answers 0x60. A title may present on a plane above plane 0 on this profile; it may also load modules the Series X profile does not.", + "why": "Series S: ConsoleMode answers 0x60. A title may present on a plane above plane 0 on this profile, which is why X2W_PRESENT_COMPOSITE is in base; it may also load modules the Series X profile does not.", "env": { "X2W_DEVICE_TYPE": "6" }