startup: check the depth target binding of translated draws #2156

Manually merged
github merged 2 commits from gh-pr/2156/head into gh-pr/2156/base 2026-11-27 00:01:08 +00:00
Owner

@⁠rasptum on GitHub · 2026-11-25 01:49 UTC · original
rasptum:startup/translated-draw-depth-target → main · +521 −0 · 4 files · 2 commits · merged 2026-11-25 02:56 UTC

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, and pipeline_for takes the translated pipeline's DSVFormat from it. startup_stream_depth already 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.cpp draws 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.

Case Depth handle Expected
bound the depth view Green in front. Depth 0.25 in the drawn half and 1.0 elsewhere. One bind, nothing unresolved, no debug-layer message of any severity.
null holds 0 (maps to no descriptor) The colour target is bound without depth: red overwrites green and depth keeps 1.0. binding no depth is logged and x2w_d3d12_render_target_stats counts one unresolved handle.
unknown an address in no descriptor heap The whole bind is refused (not a known depth stencil view, counted once), so nothing is drawn: the clear colour stays and depth keeps 1.0.

docs/startup-runtime.md gains a short "Depth target on translated draws" section.

Negative control

startup_draw_depth_target_drop_control_{warp,hardware} (WILL_FAIL) runs the bound case's draw with the zero handle and checks it against the bound expectations. 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.

ctest --preset dev --no-tests=error -R '^(startup_draw_depth_target_.*|startup_stream_depth_.*|startup_stream_(request|draw)_.*|startup_slot57_blend_draw_.*)$' -V
ctest --preset release --no-tests=error -R '^(startup_draw_depth_target_.*|startup_stream_depth_.*|startup_stream_(request|draw)_.*|startup_slot57_blend_draw_.*)$' -V
  • Result: 11 of 11 passed, 0 failed, 0 skipped, in both presets. Both new tests and both controls passed on WARP and on hardware. The existing stream draw, stream depth and slot 57 blend draw tests pass unchanged.
  • Repeat runs: startup_draw_depth_target_warp passed 10 of 10 repeated runs in release.
  • Python checks: tests/docs_links_check.py and tests/bidi_controls_check.py pass.

AI-assisted (Claude Code).
🤖 Generated with Claude Code

**@⁠rasptum** on GitHub · 2026-11-25 01:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2156) `rasptum:startup/translated-draw-depth-target` → `main` · +521 −0 · 4 files · 2 commits · merged 2026-11-25 02:56 UTC 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, and `pipeline_for` takes the translated pipeline's `DSVFormat` from it. `startup_stream_depth` already 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.cpp` draws 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. | Case | Depth handle | Expected | |---|---|---| | `bound` | the depth view | Green in front. Depth 0.25 in the drawn half and 1.0 elsewhere. One bind, nothing unresolved, no debug-layer message of any severity. | | `null` | holds 0 (maps to no descriptor) | The colour target is bound without depth: red overwrites green and depth keeps 1.0. `binding no depth` is logged and `x2w_d3d12_render_target_stats` counts one unresolved handle. | | `unknown` | an address in no descriptor heap | The whole bind is refused (`not a known depth stencil view`, counted once), so nothing is drawn: the clear colour stays and depth keeps 1.0. | `docs/startup-runtime.md` gains a short "Depth target on translated draws" section. ### Negative control `startup_draw_depth_target_drop_control_{warp,hardware}` (`WILL_FAIL`) runs the `bound` case's draw with the zero handle and checks it against the `bound` expectations. 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. ``` ctest --preset dev --no-tests=error -R '^(startup_draw_depth_target_.*|startup_stream_depth_.*|startup_stream_(request|draw)_.*|startup_slot57_blend_draw_.*)$' -V ctest --preset release --no-tests=error -R '^(startup_draw_depth_target_.*|startup_stream_depth_.*|startup_stream_(request|draw)_.*|startup_slot57_blend_draw_.*)$' -V ``` - **Result:** 11 of 11 passed, 0 failed, 0 skipped, in both presets. Both new tests and both controls passed on WARP and on hardware. The existing stream draw, stream depth and slot 57 blend draw tests pass unchanged. - **Repeat runs:** `startup_draw_depth_target_warp` passed 10 of 10 repeated runs in `release`. - **Python checks:** `tests/docs_links_check.py` and `tests/bidi_controls_check.py` pass. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
List slot 50 (OMSetRenderTargets) already forwards a bound depth-stencil
view to the desktop list together with the colour targets, and the
translated pipeline takes its DSVFormat from it. Nothing checked the
depth values it produces, the debug layer after the fence, or the two
unresolved-handle paths. This adds that coverage; no stand-in code
changes, because the fixture found the binding correct.

tests/startup_draw_depth_target.cpp draws a near (z 0.25) green and a
far (z 0.75) red triangle with a depth-tested stream pipeline (LESS,
writes on), one case per process, and reads back the colour target and
the D32 depth values after the fence:
- bound: green in front, depth 0.25 where drawn and 1.0 elsewhere, one
  bind, nothing unresolved, no debug-layer message (X2W_D3D12_DEBUG=1;
  the script says so if the layer is not installed);
- null: a zero depth handle maps to no descriptor; the colour target is
  bound without depth (logged, counted once by
  x2w_d3d12_render_target_stats): red overwrites, depth keeps 1.0;
- unknown: a handle in no descriptor heap refuses the whole bind
  (logged, counted once): nothing is drawn.
Negative control startup_draw_depth_target_drop_control (WILL_FAIL):
the bound case's draw with the zero handle, checked against the bound
expectations; it exits 1 only when exactly the picture differs, and a
broken run exits 2.

A depth-only mesh pass is not covered: mesh pipelines reach the stand-in
only as native desktop-bytecode streams, which must have a pixel stage
and no depth format, so such a pipeline is refused at creation. Noted in
docs/startup-runtime.md.

Refs #1999

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:01:06 +00:00
github manually merged commit 986414f6d0 into gh-pr/2156/base 2026-11-27 00:01:08 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-25 02:03 UTC · original

WILL_FAIL accepts exit 2 just like exit 1. Remove this property and make the Python drop mode 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.

**@⁠R0Y00** on GitHub · 2026-11-25 02:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2156#discussion_r4689260031) `WILL_FAIL` accepts exit 2 just like exit 1. Remove this property and make the Python `drop` mode 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.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-25 02:43 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-25 02:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2156#issuecomment-7151105980) 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.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-25 02:03 UTC · original · requested changes

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_FAIL test, 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_' -V and 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 /O2 workflow job is skipped.

**@⁠R0Y00** on GitHub · 2026-11-25 02:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2156#pullrequestreview-6050534980) · **requested changes** 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_FAIL` test, 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_' -V` and 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 `/O2` workflow job is skipped.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 02:10 UTC · original · reviewed

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.
  • Mergeable, not a draft, title neutral, no clean-room concern seen.

Findings: P1=0, P2=0.

Read-through notes:

  • The check mode 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.
  • The drop control only returns 1 when the picture alone differs (UNBOUND result, one bind), and a broken run returns 2. A crash therefore does not count as the control failing for its stated reason. Good design.
  • Docs: the new section matches the checks. The ctest -R "^startup_draw_depth_target_" command is consistent with the test names in CMake. The pattern also matches the _drop_control tests, which is fine because they are WILL_FAIL.

Nits (non-blocking):

  1. The bound debug-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.
  2. run_case treats a missing -> drawn; as broken for every case except unknown. A short comment on why unknown is 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.

**@⁠tedin7** on GitHub · 2026-11-25 02:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2156#pullrequestreview-6050607418) · **reviewed** 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. - Mergeable, not a draft, title neutral, no clean-room concern seen. Findings: P1=0, P2=0. Read-through notes: - The `check` mode 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. - The `drop` control only returns 1 when the picture alone differs (`UNBOUND` result, one bind), and a broken run returns 2. A crash therefore does not count as the control failing for its stated reason. Good design. - Docs: the new section matches the checks. The `ctest -R "^startup_draw_depth_target_"` command is consistent with the test names in CMake. The pattern also matches the `_drop_control` tests, which is fine because they are WILL_FAIL. Nits (non-blocking): 1. The `bound` debug-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. 2. `run_case` treats a missing `-> drawn;` as broken for every case except `unknown`. A short comment on why `unknown` is 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.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-25 02:44 UTC · original · approved these changes

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.

**@⁠R0Y00** on GitHub · 2026-11-25 02:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2156#pullrequestreview-6051044752) · **approved these changes** 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.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 02:48 UTC · original · reviewed

Re-review of head 986414f6d00f7fcf88a5c9debca4161bf7c252eb (previous review was on 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 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.
  • Mergeable, not a draft, title neutral, no clean-room concern seen.

Findings: P1=0, P2=0.

What changed and whether it holds:

  • The drop control now returns 0 when the expected mismatch appears (red in front, depth 1.0, one colour bind) and 1 otherwise. A broken run still returns 2. The control no longer depends on a failing-test inversion, so a crash or a wrong picture fails CTest. This is stricter than before and I find no flaw in it.
  • CMakeLists.txt:2597-2604 registers 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.
  • The two nits from the last review were not applied. They stay non-blocking: (1) the missing debug layer is only a printed note; (2) run_case has no comment on why unknown is 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.

**@⁠tedin7** on GitHub · 2026-11-25 02:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2156#pullrequestreview-6051081746) · **reviewed** Re-review of head `986414f6d00f7fcf88a5c9debca4161bf7c252eb` (previous review was on `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 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. - Mergeable, not a draft, title neutral, no clean-room concern seen. Findings: P1=0, P2=0. What changed and whether it holds: - The drop control now returns 0 when the expected mismatch appears (red in front, depth 1.0, one colour bind) and 1 otherwise. A broken run still returns 2. The control no longer depends on a failing-test inversion, so a crash or a wrong picture fails CTest. This is stricter than before and I find no flaw in it. - `CMakeLists.txt:2597-2604` registers 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. - The two nits from the last review were not applied. They stay non-blocking: (1) the missing debug layer is only a printed note; (2) `run_case` has no comment on why `unknown` is 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.