Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2748,15 +2748,19 @@ if(EXISTS "${INTAKE_PYTHON}")
"${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_slot57_depth_check.py"
"$<TARGET_FILE:startup_slot57_depth>" "${backend}")
set_tests_properties(startup_slot57_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"
"$<TARGET_FILE:startup_draw_depth_target>" "${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"
"$<TARGET_FILE:startup_draw_depth_target>" "${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"
"$<TARGET_FILE:startup_draw_depth_target>" "${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"
Expand Down
5 changes: 3 additions & 2 deletions docs/startup-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
34 changes: 22 additions & 12 deletions tests/startup_draw_depth_target_check.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""Depth target binding for translated draws (#1999 item D).

usage: startup_draw_depth_target_check.py <startup_draw_depth_target> <warp|hardware> [check|drop]
Exit codes: 0 pass, 1 unexpected result, 2 broken run, 77 no hardware.
usage: startup_draw_depth_target_check.py <startup_draw_depth_target> <warp|hardware> [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
Expand All @@ -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
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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:
Expand All @@ -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)}")
Expand All @@ -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

Expand Down
Loading