startup: check the depth target binding of translated draws #2148
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2156"
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 rasptum on 2026-11-25T01:49:31Z.
Refs #1999 (item D).
Problem
List slot 50 (
OMSetRenderTargets) forwards a bound depth-stencil view to the desktop list in the same call as the colour targets, andpipeline_fortakes the translated pipeline'sDSVFormatfrom it.startup_stream_depthalready checks the resulting colours for several bindings. No fixture read back the depth values a translated draw writes, checked the debug layer after the fence, or covered the two paths for a depth handle the stand-in cannot resolve.Change
Coverage only. The fixture found the binding correct, so no stand-in code changes.
tests/startup_draw_depth_target.cppdraws a near green triangle (z 0.25) and then a far red one (z 0.75) with a depth-tested stream pipeline (LESS, writes on). Each case runs in its own process, so its debug-layer messages belong to it. It reads back the colour target and the D32 depth values after the fence, then executes an empty list so the stand-in drains the stored debug messages.boundnullbinding no depthis logged andx2w_d3d12_render_target_statscounts one unresolved handle.unknownnot a known depth stencil view, counted once), so nothing is drawn: the clear colour stays and depth keeps 1.0.docs/startup-runtime.mdgains a short "Depth target on translated draws" section.Negative control
startup_draw_depth_target_drop_control_{warp,hardware}(WILL_FAIL) runs theboundcase's draw with the zero handle and checks it against theboundexpectations. It exits 1 only when exactly the picture differs (red in front, depth target untouched) while the draw still happened. Otherwise it exits 0, and a broken run exits 2, so it cannot pass by crashing.Observed on both backends: red in front and depth 1.0 everywhere, "failed for the stated reason".
Not covered
A depth-only mesh pass (no colour target, no pixel stage) is not covered. Mesh pipelines reach the stand-in only as native desktop-bytecode streams (
build_stream_pipeline), which must have a pixel stage and no depth format, so such a pipeline is refused when it is created. Supporting it is a separate change, and needs a hardware fixture or a capability skip, as the issue notes for WARP.The depth clear and the read-only DSV restore are left to #1806.
Verification
Windows 10 19045, MSVC 19.44. WARP: Microsoft Basic Render Driver, vendor 1414, device 008c, driver 10.0.19041.5794. Hardware: NVIDIA GeForce RTX 3060, vendor 10de, device 2503, driver 32.0.15.9636. The debug layer was enabled (
X2W_D3D12_DEBUG=1) in every run.startup_draw_depth_target_warppassed 10 of 10 repeated runs inrelease.tests/docs_links_check.pyandtests/bidi_controls_check.pypass.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T02:03:59Z.
Review: CHANGES_REQUESTED
The source-built readback covers the depth write, occlusion and the two unresolved-handle paths. Please fix the drop control's exit mapping before merge. I reproduced CTest treating Python exit 2 as a passing
WILL_FAILtest, which means translation, fixture launch, or readback errors can make the control green.After the fix, please rerun
ctest --preset release --no-tests=error -R '^startup_draw_depth_target_' -Vand include the output for an intentionally broken invocation of the control. The PR's Windows smoke preset omits this target and its tests, and the PR's/O2workflow job is skipped.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:10:02Z.
Review: COMMENTED
Review of head
2eb71c0ae6d43d9cd638d930e5720a21ea721466(test and docs only: CMakeLists.txt, docs/startup-runtime.md, tests/startup_draw_depth_target.cpp, tests/startup_draw_depth_target_check.py).Commands run locally on the PR head:
git diff --stat origin/main...HEAD: 4 files, +523, no production code touched.python3 tests/docs_links_check.py: self-test passed, 18 Markdown files, 398 links OK.python3 tests/bidi_controls_check.py: 1437 files, no bidirectional controls.git diff --check origin/main...HEAD: clean.python3 -m py_compile tests/startup_draw_depth_target_check.py: OK.gh pr checks 2156: Windows build and test, Linux Python checks and gfx1013 fixtures all pass. The /O2 job is skipped.Findings: P1=0, P2=0.
Read-through notes:
checkmode asserts colour, depth, bind count, unresolved count and the log line for all three cases (bound,null,unknown). The expected values match the table in the PR body.dropcontrol only returns 1 when the picture alone differs (UNBOUNDresult, one bind), and a broken run returns 2. A crash therefore does not count as the control failing for its stated reason. Good design.ctest -R "^startup_draw_depth_target_"command is consistent with the test names in CMake. The pattern also matches the_drop_controltests, which is fine because they are WILL_FAIL.Nits (non-blocking):
bounddebug-layer check is skipped with only a printed note when the layer is missing. That is honest, but the CI log is the only place that shows it. Consider also failing on the Windows CI runner when the layer is expected to be present.run_casetreats a missing-> drawn;as broken for every case exceptunknown. A short comment on whyunknownis exempt would help the next reader.Not done: I did not mutate the stand-in logic or run the D3D12 fixtures here. They need Windows and a D3D12 device, and this Linux worktree has neither. I also did not request a separate Win2025 run, because the change adds no gfx2hlsl or shader code and the Windows CI job passed on this head. The WARP and hardware results are therefore taken from CI, not reproduced by me.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T02:44:57Z.
Review: APPROVED
The drop control now accepts only its expected colour/depth mismatch. Windows Release passed both variants on WARP and RTX 4060 Laptop, and the missing-executable invocation returned exit 2, which fails the new CTest setup.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:48:10Z.
Review: COMMENTED
Re-review of head
986414f6d00f7fcf88a5c9debca4161bf7c252eb(previous review was on2eb71c0ae6d43d9cd638d930e5720a21ea721466). Test and docs only: CMakeLists.txt, docs/startup-runtime.md, tests/startup_draw_depth_target.cpp, tests/startup_draw_depth_target_check.py.Commands run locally on this head:
git diff --stat origin/main...HEAD: 4 files, +521, no production code touched.git diff 2eb71c0 HEAD -- tests/startup_draw_depth_target_check.py: the only PR-owned change since the last review (the rest of the range is merges from main).python3 tests/docs_links_check.py: self-test passed, 18 Markdown files, 401 links OK.python3 tests/bidi_controls_check.py: 1455 files, no bidirectional controls.git diff --check origin/main...HEAD: clean.python3 -m py_compile tests/startup_draw_depth_target_check.py: OK.gh pr checks 2156: Windows build and test, Linux Python checks and gfx1013 fixtures pass. The /O2 job and the chart publish are skipped.Findings: P1=0, P2=0.
What changed and whether it holds:
CMakeLists.txt:2597-2604registers the control with no WILL_FAIL, which matches the new exit codes. The docs paragraph ("passes only when the intended colour and depth mismatch appears") matches the script.run_casehas no comment on whyunknownis exempt from the-> drawn;check.Nit (new, non-blocking):
CMakeLists.txt:2596: the comment still says the control "must fail only its picture". It now passes only on that mismatch. Suggest rewording to match.Not done: I did not run the D3D12 binary or mutate the stand-in. This Linux worktree has no Windows or D3D12 device, so a mutation of the exit-code logic could not be exercised here. I did not request a Win2025 run, because there is no gfx2hlsl or shader change and the Windows CI job passed on this head. The WARP and hardware results are taken from CI, not reproduced by me.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T02:43:46Z.
I removed WILL_FAIL from the drop cases. They now pass only when the actual colour, depth and bind count match the intended dropped-depth result. Windows Release passed all four WARP and RTX cases, and a deliberately missing fixture executable returned exit 2. Both the occlusion and depth documentation sections are retained.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T02:03:59Z.
Code review location:
CMakeLists.txt; line 2522WILL_FAILaccepts exit 2 just like exit 1. Remove this property and make the Pythondropmode return 0 only when readback matches the expected red/clear picture with a successful color bind. Keep wrong pictures and broken runs nonzero, and preserve return 77 for an unavailable hardware adapter. This makes a passing control demonstrate the intended depth-binding dependency.