startup: map the optimized clear value of console-only formats to the desktop format #3194
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3194"
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 tedin7 on 2026-11-27T21:22:20Z.
Part of #870
What this unblocks: depth/stencil and 10-bit float targets made with a console-only format keep their optimized clear value on desktop D3D12, so the title's clears match it.
The shim already maps the console-only DXGI values 116-120 (two 10-bit float formats, D16_UNORM_S8_UINT and its two typed views) to the nearest desktop formats when it creates a resource. The optimized clear value passed with that resource kept the console format, so desktop D3D12 got a clear format that no longer matched the created resource (ID3D12Device::CreateCommittedResource / CreatePlacedResource / CreateReservedResource,
pOptimizedClearValue), and later clears were reported as mismatching.This change:
src/startup_stubs/clear_value_format.h(desktop_format,desktop_clear_value), used by the device shim and byxg_xs.cppinstead of two copies;Tests:
startup_clear_depth_stencil_warp: new case D creates a 1x1 console-format-118 depth target with a matching clear value through slot 76 and clears it; the run fails on a debug-layerCLEARDEPTHSTENCILVIEW_MISMATCHINGCLEARVALUEmessage or a dropped clear in the log.startup_packed_target+ newstartup_packed_target_raw-clear_control(WILL_FAIL): CPU check ofdesktop_clear_valuefor console formats 116, 117 and 118 and for the packed stand-in; the control forwards format 118 unchanged and must fail.Verification:
x86_64-w64-mingw32-g++ -std=c++20 -fsyntax-only -x c++ -Isrc -Isrc/startup_stubs src/startup_stubs/clear_value_format.h-> OKcmake -S . -B /tmp/cfg -G Ninja -DDXC_EXECUTABLE=/bin/true-> configure OKf35405a5,x2w_pipe.py win2025 3194 --targets startup_clear_depth_stencil,startup_packed_target_check --regex '^startup_(clear_depth_stencil|packed_target)' --force:startup_clear_depth_stencil_warp,_hardware,startup_packed_target, its 8 WILL_FAIL controls includingraw-clear_control,startup_packed_target_draw_warp,_hardware)a8f19ac9did not build: MSVC rejected aconstexprlocal used inside a capture-less lambda intests/startup_packed_target_check.cpp;f35405a5inlines theoffsetof.Draft until an independent peer review and the Win2025 WARP gate pass.
Thanks to @Makto94 for the testing that found this.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T23:53:04Z.
Review of
f35405a5(two commits):Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T10:49:12Z.
Real-GPU verification (NVIDIA RTX 3070 Ti, driver 32.0.16.2101, Windows 11):
Tested at
f35405a(current head). dev preset, ctest run one test at a time:These complement the existing WARP runs.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-28T10:49:25Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
f35405aℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T22:07:56Z.
Merged current
maininto this branch (merge commit, no force push, no conflicts); head is now637a102b2. No change to the PR's own files.Verification (Windows Server 2025, D3D12 WARP, head
637a102b2):x2w_pipe.py win2025 3194 --regex '^startup_(packed_target|clear)'-> 15/15 passed.@MasterDomino ready for review and merge when you have time. KelboLive's review of
f35405a5has no open asks.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-29T08:05:22Z.
Review: APPROVED
Independently reviewed
637a102bintegrated overmain212d4b5f(treeca374ec7). The trial merge is clean andgit diff --checkis clean. The branch's merge ofmain(637a102b, by the author) has no conflict resolution in it.What I traced
desktop_formatin the newclear_value_format.his the same 116-120 table thatd3d12_xs_device.cppandxg_xs.cppeach carried; the device shim keeps its logging wrapper around it.desktop_clear_valueagainst the oldpacked_clear_value: for the packed stand-in case the condition is the same (packed_target_mappingonly returns a mapping whoserequestedequals the mapped description format). The new part is that the clear format goes through the 116-120 table first, and a copy is made whenever the format changes.create_slot: slot 27CreateCommittedResource(props, flags, desc, state, clear, …)and slot 29CreatePlacedResource(heap, offset, desc, state, clear, …)take it as argument 4, slot 30CreateReservedResource(desc, state, clear, …)as argument 2. That matches the vtable order and theenable_create<device_kind, 30, 3, 0>registration.Results
Built
startup_clear_depth_stencil,startup_packed_target_checkand the shim indevandrelease, then ranctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^startup_(clear_depth_stencil_warp|packed_target)' -E '_hardware$':11 of 11 passed in Debug and in Release
/O2, no skips (startup_clear_depth_stencil_warp,startup_packed_target, its 8WILL_FAILcontrols includingraw-clear_control,startup_packed_target_draw_warp).startup_clear_depth_stencil_hardwareandstartup_packed_target_draw_hardwarepassed in both presets with the debug layer on, no skips. The slot 76 log line showsfmt=118with the clear kept (no(dropped)).Negative control: with
main'sd3d12_xs_device.cppand this PR's tests,startup_clear_depth_stencil_warpfails on the(dropped)log marker.Mutants (Debug,
ctest -R '^startup_(packed_target|clear)' -E '_hardware$', 12 tests):startup_clear_depth_stencil_warpfails on the(dropped)marker.startup_clear_depth_stencil_warpandstartup_packed_targetfail.startup_packed_targetfails.format == mapping->requestedcondition:startup_packed_targetfails.copy = *clear: both fail.N == 27 || N == 29 || N == 30condition.device_place_resource_x) forwards the title's clear value unchanged.created_format == mapping->replacement: at every call site the created format is either the replacement or the requested format, so the result is the same.desktop_formataroundtitle_desc_format: no packed format is in 116-120.Notes (not blocking)
main. A follow-up case that creates a format-118 target through slot 30 (and one of 27 or 29) would close it.R24_UNORM_X8_TYPELESSorX24_TYPELESS_G8_UINT, which desktop D3D12 does not accept as a clear format. Slot 76 then retries without the clear value; the other slots do not. That was already so onmain(the raw value was refused the same way), so it is not a regression.Wider runs
devbuild, thenctest --test-dir out/build/dev --no-tests=error -j 6 -E '(_hardware$|^startup_audio_)': two failures,startup_compute_dispatch_output_warpandstartup_compute_half_buffer_uav_controls. Both fail the same way alone at-j 1, and both still fail withmain'sd3d12_xs_device.cppandxg_xs.cppswapped in, so they do not come from this PR.xg_xs.cppusersstartup_ui_texture_bands_warpandstartup_nv12_draw_warppass in Release.main212d4b5fwas judged no worse than the baseline run ofmain.Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; NVIDIA GeForce RTX 5090, driver 32.0.16.1088, D3D12 debug layer on for the hardware runs; WARP for the
_warptests.CI:
Build and test on Windowspassed on637a102b; its test subset does not include the tests this PR changes.Approving
637a102b.This reply was AI-assisted.