From c881a5c703ca9cfa01aa32f55cf3cfcabe091f69 Mon Sep 17 00:00:00 2001 From: rasptum <348594691+rasptum@users.noreply.github.com> Date: Tue, 24 Nov 2026 22:05:52 -0500 Subject: [PATCH] tests: report the depth-target debug-layer check as its own test Follow-up to #2156's review nits. - The bound case's debug-message check was skipped with a printed note when the D3D12 debug layer is not installed. It is now its own test, startup_draw_depth_target_debug_{warp,hardware}: it requires the bound picture and no debug-layer message after the fence, and exits 77 (a capability skip CTest reports) when the layer is missing, instead of passing with a note. The check mode keeps every pixel, depth and counter check. - run_case says why the unknown case is exempt from the "-> drawn;" check: the stand-in refuses the whole OMSetRenderTargets there, so no draw may be issued; nothing drawn is checked through the read-back and the refusal line. - The CMakeLists comment no longer says the drop control "must fail only its picture": it passes only when it reads back the unbound picture. Refs #1999 Co-Authored-By: Claude Opus 5.5 --- CMakeLists.txt | 8 ++++-- docs/startup-runtime.md | 5 ++-- tests/startup_draw_depth_target_check.py | 34 +++++++++++++++--------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 17aa9d3505..ed95c18068 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2668,15 +2668,19 @@ if(EXISTS "${INTAKE_PYTHON}") "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_stream_depth_check.py" "$" "${backend}") set_tests_properties(startup_stream_depth_${backend} PROPERTIES TIMEOUT 90 SKIP_RETURN_CODE 77) - # The drop control draws the bound case with an unresolved depth handle and must fail only its picture. + # The drop control draws the bound case with the depth binding dropped (a zero handle) and passes only when + # it reads back that unbound picture; the debug test reports a skip (77) without a debug layer. add_test(NAME startup_draw_depth_target_${backend} COMMAND "${CMAKE_COMMAND}" -E env "X2W_FXC=${STARTUP_FXC}" "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_draw_depth_target_check.py" "$" "${backend}" check) add_test(NAME startup_draw_depth_target_drop_control_${backend} COMMAND "${CMAKE_COMMAND}" -E env "X2W_FXC=${STARTUP_FXC}" "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_draw_depth_target_check.py" "$" "${backend}" drop) + add_test(NAME startup_draw_depth_target_debug_${backend} COMMAND "${CMAKE_COMMAND}" -E env "X2W_FXC=${STARTUP_FXC}" + "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_draw_depth_target_check.py" + "$" "${backend}" debug) set_tests_properties(startup_draw_depth_target_${backend} startup_draw_depth_target_drop_control_${backend} - PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77) + startup_draw_depth_target_debug_${backend} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77) foreach(compiler IN ITEMS fxc dxc) add_test(NAME startup_mrt_${compiler}_${backend} COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_mrt_check.py" diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index 52a640efbc..f372fde5d9 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -72,8 +72,9 @@ counts it in `x2w_d3d12_render_target_stats`. A depth handle in no descriptor he depth-stencil view, refuses the whole bind (also logged and counted), so nothing is drawn onto targets the title did not ask for. `ctest --preset release --no-tests=error -R "^startup_draw_depth_target_" -V` draws a near and a far triangle with a depth-tested stream pipeline and reads back the colour and the D32 depth -values after the fence. With the view bound, the near triangle wins, depth is 0.25 where drawn, and the -debug layer reports no message. With a zero handle, the far triangle overwrites and depth keeps its clear +values after the fence. With the view bound, the near triangle wins and depth is 0.25 where drawn. The +`_debug` test also requires no debug-layer message after the fence, and reports a skip (77) when the +debug layer is not installed. With a zero handle, the far triangle overwrites and depth keeps its clear value. With an unknown handle, nothing is drawn. Each unresolved handle is counted once. The `_drop_control` draws the bound case with a zero handle and passes only when the intended colour and depth mismatch appears. diff --git a/tests/startup_draw_depth_target_check.py b/tests/startup_draw_depth_target_check.py index 72f455119b..a93a93e9bf 100644 --- a/tests/startup_draw_depth_target_check.py +++ b/tests/startup_draw_depth_target_check.py @@ -1,15 +1,15 @@ """Depth target binding for translated draws (#1999 item D). -usage: startup_draw_depth_target_check.py [check|drop] -Exit codes: 0 pass, 1 unexpected result, 2 broken run, 77 no hardware. +usage: startup_draw_depth_target_check.py [check|drop|debug] +Exit codes: 0 pass, 1 unexpected result, 2 broken run, 77 no hardware adapter (and, for "debug" only, +no D3D12 debug layer). tests/startup_draw_depth_target.cpp draws a near green triangle (z 0.25), then a far red one (z 0.75), with a depth-tested stream pipeline (LESS, writes on), and reads back the colour target and the D32 depth target. "check" (the default) runs three cases, each in its own process: bound the depth handle resolves: green in front, depth 0.25 in the drawn half and 1.0 elsewhere, - one bind and nothing unresolved, and no debug-layer message of any severity after the fence - (when the debug layer is installed; otherwise the script says the message check did not run) + one bind and nothing unresolved null the depth handle holds 0, which maps to no descriptor: the stand-in logs it and counts it once and binds the colour target without depth, so red overwrites green and the depth target keeps 1.0 unknown the depth handle is in no descriptor heap: the stand-in logs it, counts it once and refuses the @@ -18,6 +18,10 @@ "drop" is the negative control: the bound case's draw with the null handle, checked against the bound case's expectations. The control passes only when the expected mismatch appears (red in front, depth untouched, and one colour target bind). A broken run or an unexpected picture fails CTest. + +"debug" runs the bound case with the D3D12 debug layer (X2W_D3D12_DEBUG=1) and requires the bound picture +and no debug-layer message of any severity after the fence. Without an installed debug layer the message +check cannot run, so this mode exits 77 (a capability skip that CTest reports as such) instead of passing. """ import os from pathlib import Path @@ -76,6 +80,9 @@ def prepare(directory, program, backend): def run_case(directory, args, env, case): out = directory / case run = subprocess.run(args + [case, str(out)], env=env, capture_output=True, text=True) + # Every case but "unknown" must draw. In "unknown" the stand-in refuses the whole OMSetRenderTargets, + # so no target is bound and no draw may be issued; its "nothing drawn" is checked through the read-back + # (the clear colour and depth 1.0) and the refusal line, not through a "-> drawn;" line. print(f"[{case}] " + run.stdout.strip().replace("\n", f"\n[{case}] ")) debug = [line for line in run.stderr.splitlines() if "x2w-d3d12-debug " in line] for line in run.stderr.splitlines(): @@ -106,7 +113,7 @@ def describe(result): def main(): program, backend = sys.argv[1], sys.argv[2] mode = sys.argv[3] if len(sys.argv) > 3 else "check" - if mode not in ("check", "drop"): + if mode not in ("check", "drop", "debug"): print(__doc__) return 64 try: @@ -126,18 +133,21 @@ def main(): print(f"control drop: {describe(result)} -> " + ("failed for the stated reason" if stated else "did NOT fail for the stated reason")) return 0 if stated else 1 + if mode == "debug": + bound = run_case(directory, args, env, "bound") + if not bound["debug_layer"]: + print("the D3D12 debug layer is not installed: the debug-message check cannot run (skip)") + return 77 + picture = (bound["colour"], bound["depth"]) == BOUND + print(f"debug: debug layer enabled, {len(bound['debug'])} debug-layer message(s) after the fence; " + f"bound picture {'matches' if picture else 'DIFFERS'}") + return 0 if picture and not bound["debug"] else 1 failed = [] bound = run_case(directory, args, env, "bound") if (bound["colour"], bound["depth"]) != BOUND: failed.append(f"bound: {describe(bound)}") if bound["binds"] != 1 or bound["unresolved"] or bound["logged"]: failed.append(f"bound: binds +{bound['binds']}, unresolved +{bound['unresolved']}, logged {bound['logged']}") - if bound["debug"]: - failed.append(f"bound: {len(bound['debug'])} debug-layer message(s)") - debug_note = ("no debug-layer message" if bound["debug_layer"] - else "debug layer NOT available, so the message check did not run") - if not bound["debug_layer"]: - print("note: the D3D12 debug layer is not installed; the debug-message check did not run") null = run_case(directory, args, env, "null") if (null["colour"], null["depth"]) != UNBOUND: failed.append(f"null: {describe(null)}") @@ -156,7 +166,7 @@ def main(): print("FAIL", line) if failed: return 1 - print(f"{backend}: bound depth target occluded red with depth 0.25 and {debug_note}; a zero depth " + print(f"{backend}: bound depth target occluded red with depth 0.25; a zero depth " "handle bound the colour target without depth; an unknown one refused the bind; each logged and counted once") return 0