From e5484d6c70a711c1a0335d521a8a12b3abab07f6 Mon Sep 17 00:00:00 2001 From: RavenCurseBurg <360931527+RavenCurseBurg@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:02:49 +0800 Subject: [PATCH] tests: draw all eight integer predicate groups on one device --- docs/experiments.md | 18 +++++++++--------- tests/pixel_aot_check.py | 34 +++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/docs/experiments.md b/docs/experiments.md index 3132b2d251..1a4c0eec77 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -7420,15 +7420,15 @@ sets the process exit code to 1. The remaining pairs still report a status. Run `ctest --preset dev --no-tests=error -R '^pixel_batch_pairs_(hardware|warp)$' -V` to compare two shaders with isolated draws and exercise mismatch and missing-file controls. -The 32-bit integer, 16-bit integer and SDWA predicate draws use the same -runner, one batch per compiled group, with the same references. The -signed-against-unsigned control of the first `i32` e32 group and the -inverted-unordered control of each SDWA group run inside their batch as -expected mismatches, each followed by a passing draw. The three 16-bit -`must_mismatch` controls, two of them on mutated shaders, keep one single-case -draw each. These three suites -go from 108 device creations to 23, and DXC compiles one shader fewer, because -the signed/unsigned control now reuses the group's compiled shader. +The 32-bit integer predicate fixture passes eight compiled shaders and 33 +references to one `--check-pixel-pairs` process. The signed-against-unsigned +reference in the first `i32` e32 group must mismatch, and the following draw +must pass. Each 16-bit integer or SDWA predicate group uses a single-shader +batch. Each SDWA inverted-unordered control still precedes a passing draw. +The three 16-bit `must_mismatch` controls use one single-case draw each. +The original per-shader batching cut device creations across these three +suites from 108 to 23 and saved one compile by reusing the signed shader. +Combining the eight 32-bit groups saves seven more device creations. The remaining multi-case `--check-pixel-case` loops across `draw-core`, `draw-predicate-rounding`, `draw-blend-scalar`, `draw-e64`, `draw-integer-nc`, diff --git a/tests/pixel_aot_check.py b/tests/pixel_aot_check.py index 43f65bd728..52b5d7f4bc 100644 --- a/tests/pixel_aot_check.py +++ b/tests/pixel_aot_check.py @@ -3637,9 +3637,7 @@ def predicate_group_e64(first): return with_constants(body) -def run_pixel_batch_statuses(renderer, backend, shader, paths): - command = [renderer, backend, "--check-pixel-batch", shader, *paths] - result = subprocess.run(command, capture_output=True, text=True) +def pixel_batch_statuses(result, count): if result.returncode == 77: result.check_returncode() statuses = [] @@ -3648,11 +3646,17 @@ def run_pixel_batch_statuses(renderer, backend, shader, paths): if not line.startswith(prefix): raise AssertionError(f"Unexpected batch line {line!r}\n{result.stdout}\n{result.stderr}") statuses.append(line[len(prefix):]) - if len(statuses) != len(paths) or any(status not in ("pass", "mismatch") for status in statuses): + if len(statuses) != count or any(status not in ("pass", "mismatch") for status in statuses): raise AssertionError(f"Unexpected batch statuses {statuses}\n{result.stdout}\n{result.stderr}") if result.returncode != int("mismatch" in statuses): raise AssertionError(f"Unexpected batch exit code {result.returncode}\n{result.stdout}\n{result.stderr}") - return statuses, result + return statuses + + +def run_pixel_batch_statuses(renderer, backend, shader, paths): + command = [renderer, backend, "--check-pixel-batch", shader, *paths] + result = subprocess.run(command, capture_output=True, text=True) + return pixel_batch_statuses(result, len(paths)), result def run_pixel_batch(renderer, backend, shader, cases): @@ -3976,7 +3980,6 @@ def check_predicate_draws(directory, compiler, renderer, backend): def check_int_predicate_draws(directory, compiler, renderer, backend): source = directory / "int_predicates.hlsl" - shader = directory / "int_predicates.cso" # Normal and signed-zero IEEE-754 bit patterns avoid denormal/NaN canonicalization while covering # signed/unsigned order flips (-0.0 vs +0.0, +1.0 vs -1.0) and integer-vs-float order (-2.0 vs -1.0). pairs = ( @@ -3994,9 +3997,11 @@ def relation(left_u, right_u, kind): left_v, right_v = left_u, right_u return 0 if left_v < right_v else (1 if left_v == right_v else 2) + draws = [] for kind in ("i32", "u32"): for encoding in ("e32", "e64"): for first in (0, 4): + shader = directory / f"int_predicates-{kind}-{encoding}-{first}.cso" source.write_text(translate(int_predicate_group(kind, encoding, first)), encoding="ascii") compile_shader(compiler, source, shader) cases = [] @@ -4017,11 +4022,18 @@ def relation(left_u, right_u, kind): wrong = directory / f"int_predicates-{kind}-{encoding}-{first}-unsigned-reference.case" wrong.write_bytes(constants + wrong_pixel * 64) cases.insert(-1, (wrong, "mismatch")) - try: - run_pixel_batch(renderer, backend, shader, cases) - except AssertionError as error: - error.add_note(f"Integer predicate draw on {backend}, {kind} {encoding} first={first}") - raise + draws.extend((shader, case, status) for case, status in cases) + + # Relative input names keep the Windows command line short even under a long temp path. + # Resolve an explicitly supplied executable before changing its working directory. + executable = Path(renderer).resolve() if Path(renderer).is_file() else None + paths = [name for shader, case, _ in draws for name in (shader.name, case.name)] + result = subprocess.run([renderer, backend, "--check-pixel-pairs", *paths], cwd=directory, + executable=executable, capture_output=True, text=True) + for (shader, case, expected), actual in zip(draws, pixel_batch_statuses(result, len(draws))): + if actual != expected: + raise AssertionError(f"{backend}: {shader.name} / {case.name}: expected {expected}, got {actual}\n" + f"{result.stdout}\n{result.stderr}") def check_unsigned_less_than_draws(directory, compiler, renderer, backend):