tests: serve GPU draw cases from one offscreen_check device #2758

Merged
tedin7 merged 12 commits from upstream-pr/2766 into main 2026-11-27 18:41:47 +00:00
tedin7 commented 2026-11-26 06:50:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T06:50:32Z.


Part of #448

What this unblocks: the GPU draw checks create the D3D12 device once per test instead of once per case, which is where #448 measured most of the time (about 0.25 s of start-up per launch against about 0.03 s per case on a real card with the debug layer on).
Source: Microsoft D3D12 documentation, D3D12CreateDevice and ID3D12Device lifetime; earlier code of this repo (tests/offscreen_check draw cases and their CTest entries in CMakeLists.txt).

What changed

  • offscreen_check <warp|hardware> --serve (tests/offscreen_check.cpp): runs any other operation, case after case, on the one device it already created. One case per stdin line, the operation and its operands separated by tabs, exactly the arguments that follow the adapter name in a one-shot call. Each case goes through the same argument validation, capability gate, debug-layer check and exit-code mapping as a one-shot call (0, 1, 77, 2), and its stdout and stderr text is what the one-shot call prints. Both streams end the case with a marker line so the client can split the text per case; the debug messages are cleared between cases; a removed device ends the loop after answering.
  • tests/gpu_case_runner.py: run(renderer, adapter, args) has the signature and result of subprocess.run([renderer, adapter, *args], capture_output=True, text=True), but starts one --serve process per renderer and adapter and sends the case to it. The adapter banner is repeated in front of every case, so a check that looks for debug_layer=enabled and debug_errors=0 debug_warnings=0 sees it in each case, as in a one-shot call. Only a server that cannot start (an older offscreen_check without --serve, no adapter, X2W_FLAT_SERVER=0) falls back to the one-shot call. Once a case has been sent, a renderer that dies, does not answer within one deadline or answers with the wrong case number gives a FAILED verdict for that case and is never run again, so a crash cannot turn into a pass; both reply indices are validated and the renderer is ended as a whole process group.
  • Adopted by startup_flat_param_check.draw (imported by 50 checks, among them startup_gfx2hlsl_f16_alu_draw), startup_gfx2hlsl_f32_sdwa, startup_gfx2hlsl_f32_nan and startup_image_sample_b. Their cases, references and controls are unchanged. startup_flat_param_check.compile_hlsl now routes DXC compiles through the opt-in X2W_DXC_CACHE cache that pixel_aot_check and compute_store_check already use.
  • tests/gpu_case_runner_check.py (new, gpu_case_runner): a fake offscreen_check that speaks the protocol checks per-case text and exit codes, the banner with every case, skip (77), a renderer without --serve, a crash after the handshake (failed verdict, case not run again), a silent renderer (one deadline), a wrong reply index, a launcher child that keeps the pipes open, a second-case debug warning, and X2W_FLAT_SERVER=0.

Builds on the batching work in #2635, #2654, #2615 and #2690 and the compiler reuse in #2711 (credit to RavenCurseBurg), and on the DXC cache of #448. Those make one test launch fewer processes by batching its references; this adds the same saving for every check that still starts a process per case, without changing any test's cases.

Why it is safe

Every case of the four adopted checks was run twice on Windows Server 2025 WARP, once through the served device and once through the old one-shot call, and compared (exit code, stdout, stderr; the banner is part of each served case and was compared too):

check cases identical wrong-value controls (both paths must fail)
startup_gfx2hlsl_f16_alu_draw 220 220 32 of 32 failed on both, same message
startup_gfx2hlsl_f32_nan 194 194 28 of 28
startup_gfx2hlsl_f32_sdwa 288 288 42 of 42
startup_image_sample_b 72 72 11 of 11

Each control changes one bit of the expected words (or the first byte of the reference file) of every seventh case and runs it through both paths.

Time (Windows Server 2025 WARP, idle host, one run each, DXC cache off)

check one-shot served
startup_gfx2hlsl_f32_nan 8.2 s 2.1 s
startup_gfx2hlsl_f32_sdwa 12.0 s 2.7 s
startup_image_sample_b 4.1 s 1.7 s
startup_gfx2hlsl_f16_alu_draw 26.7 s 20.7 s

f16_alu_draw still spends most of its time compiling one vertex shader per case with DXC and FXC one after the other; that is the next step (compiling in parallel), not part of this change. The saving on a real card is larger, because the debug layer makes each launch more expensive.

What stays the same

Only --startup-flat-param, --startup-pixel-words and --startup-image-2d-array-mips cases changed path; every other operation and every check that is not listed above is untouched. offscreen_check --self-test still validates the operation table, and --serve itself is listed there like any other operation.

Verification

  • python3 -B tests/gpu_case_runner_check.py: all tests OK (Linux).
  • python3 -B tests/startup_flat_param_check.py: controls OK (Linux).
  • Windows Server 2025 (aws-1), dev build of offscreen_check with this change and ctest -R 'gpu_case_runner|startup_gfx2hlsl_f16_alu_draw|startup_gfx2hlsl_f32_sdwa|startup_gfx2hlsl_f32_nan|startup_image_sample_b_(warp|hardware)|startup_flat_param': 15/15 passed.
  • Old versus new per case and the wrong-value controls: the table above, run with the same binary on WARP.
  • RunPod (RTX 3090, Wine + vkd3d-proton, hardware adapter), same old-versus-new comparison on the same binary:
check cases identical wrong-value controls one-shot served
startup_gfx2hlsl_f16_alu_draw 220 220 32 of 32 failed on both 441.7 s 8.1 s
startup_gfx2hlsl_f32_nan 194 194 28 of 28 322.8 s 7.2 s
startup_gfx2hlsl_f32_sdwa 288 288 42 of 42 476.4 s 8.3 s
startup_image_sample_b 72 72 11 of 11 138.5 s 5.4 s

(times are the summed offscreen_check calls only, not compiles.) ctest of the same 15 tests: 15/15 passed.

  • Win2025 WARP (proxmox pool), dev and release on the final head, 17/17 each: cmake --build --preset <dev|release> --target offscreen_check then ctest --preset <dev|release> --no-tests=error -R "gpu_case_runner|startup_gfx2hlsl_f16_alu_draw|startup_gfx2hlsl_f32_sdwa|startup_gfx2hlsl_f32_nan|startup_image_sample_b|startup_flat_param|draw_skip" -V (gpu_case_runner, startup_flat_param_{controls,warp,hardware}, startup_image_sample_b_{controls,warp,hardware}, startup_gfx2hlsl_f32_nan{,_warp,_hardware}, startup_gfx2hlsl_f32_sdwa{,_warp,hardware}, startup_gfx2hlsl_f16_alu_draw{controls,warp,hardware}, startup_gfx2hlsl_draw_skip).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5505410521 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T06:50:32Z. --- Part of #448 What this unblocks: the GPU draw checks create the D3D12 device once per test instead of once per case, which is where #448 measured most of the time (about 0.25 s of start-up per launch against about 0.03 s per case on a real card with the debug layer on). Source: Microsoft D3D12 documentation, `D3D12CreateDevice` and `ID3D12Device` lifetime; earlier code of this repo (tests/offscreen_check draw cases and their CTest entries in CMakeLists.txt). ## What changed - `offscreen_check <warp|hardware> --serve` (tests/offscreen_check.cpp): runs any other operation, case after case, on the one device it already created. One case per stdin line, the operation and its operands separated by tabs, exactly the arguments that follow the adapter name in a one-shot call. Each case goes through the same argument validation, capability gate, debug-layer check and exit-code mapping as a one-shot call (0, 1, 77, 2), and its stdout and stderr text is what the one-shot call prints. Both streams end the case with a marker line so the client can split the text per case; the debug messages are cleared between cases; a removed device ends the loop after answering. - `tests/gpu_case_runner.py`: `run(renderer, adapter, args)` has the signature and result of `subprocess.run([renderer, adapter, *args], capture_output=True, text=True)`, but starts one `--serve` process per renderer and adapter and sends the case to it. The adapter banner is repeated in front of every case, so a check that looks for `debug_layer=enabled` and `debug_errors=0 debug_warnings=0` sees it in each case, as in a one-shot call. Only a server that cannot start (an older `offscreen_check` without `--serve`, no adapter, `X2W_FLAT_SERVER=0`) falls back to the one-shot call. Once a case has been sent, a renderer that dies, does not answer within one deadline or answers with the wrong case number gives a FAILED verdict for that case and is never run again, so a crash cannot turn into a pass; both reply indices are validated and the renderer is ended as a whole process group. - Adopted by `startup_flat_param_check.draw` (imported by 50 checks, among them `startup_gfx2hlsl_f16_alu_draw`), `startup_gfx2hlsl_f32_sdwa`, `startup_gfx2hlsl_f32_nan` and `startup_image_sample_b`. Their cases, references and controls are unchanged. `startup_flat_param_check.compile_hlsl` now routes DXC compiles through the opt-in `X2W_DXC_CACHE` cache that `pixel_aot_check` and `compute_store_check` already use. - `tests/gpu_case_runner_check.py` (new, `gpu_case_runner`): a fake `offscreen_check` that speaks the protocol checks per-case text and exit codes, the banner with every case, skip (77), a renderer without `--serve`, a crash after the handshake (failed verdict, case not run again), a silent renderer (one deadline), a wrong reply index, a launcher child that keeps the pipes open, a second-case debug warning, and `X2W_FLAT_SERVER=0`. Builds on the batching work in #2635, #2654, #2615 and #2690 and the compiler reuse in #2711 (credit to RavenCurseBurg), and on the DXC cache of #448. Those make one test launch fewer processes by batching its references; this adds the same saving for every check that still starts a process per case, without changing any test's cases. ## Why it is safe Every case of the four adopted checks was run twice on Windows Server 2025 WARP, once through the served device and once through the old one-shot call, and compared (exit code, stdout, stderr; the banner is part of each served case and was compared too): | check | cases | identical | wrong-value controls (both paths must fail) | |---|---|---|---| | startup_gfx2hlsl_f16_alu_draw | 220 | 220 | 32 of 32 failed on both, same message | | startup_gfx2hlsl_f32_nan | 194 | 194 | 28 of 28 | | startup_gfx2hlsl_f32_sdwa | 288 | 288 | 42 of 42 | | startup_image_sample_b | 72 | 72 | 11 of 11 | Each control changes one bit of the expected words (or the first byte of the reference file) of every seventh case and runs it through both paths. ## Time (Windows Server 2025 WARP, idle host, one run each, DXC cache off) | check | one-shot | served | |---|---|---| | startup_gfx2hlsl_f32_nan | 8.2 s | 2.1 s | | startup_gfx2hlsl_f32_sdwa | 12.0 s | 2.7 s | | startup_image_sample_b | 4.1 s | 1.7 s | | startup_gfx2hlsl_f16_alu_draw | 26.7 s | 20.7 s | `f16_alu_draw` still spends most of its time compiling one vertex shader per case with DXC and FXC one after the other; that is the next step (compiling in parallel), not part of this change. The saving on a real card is larger, because the debug layer makes each launch more expensive. ## What stays the same Only `--startup-flat-param`, `--startup-pixel-words` and `--startup-image-2d-array-mips` cases changed path; every other operation and every check that is not listed above is untouched. `offscreen_check --self-test` still validates the operation table, and `--serve` itself is listed there like any other operation. ## Verification - `python3 -B tests/gpu_case_runner_check.py`: all tests OK (Linux). - `python3 -B tests/startup_flat_param_check.py`: controls OK (Linux). - Windows Server 2025 (aws-1), dev build of `offscreen_check` with this change and `ctest -R 'gpu_case_runner|startup_gfx2hlsl_f16_alu_draw|startup_gfx2hlsl_f32_sdwa|startup_gfx2hlsl_f32_nan|startup_image_sample_b_(warp|hardware)|startup_flat_param'`: 15/15 passed. - Old versus new per case and the wrong-value controls: the table above, run with the same binary on WARP. - RunPod (RTX 3090, Wine + vkd3d-proton, hardware adapter), same old-versus-new comparison on the same binary: | check | cases | identical | wrong-value controls | one-shot | served | |---|---|---|---|---|---| | startup_gfx2hlsl_f16_alu_draw | 220 | 220 | 32 of 32 failed on both | 441.7 s | 8.1 s | | startup_gfx2hlsl_f32_nan | 194 | 194 | 28 of 28 | 322.8 s | 7.2 s | | startup_gfx2hlsl_f32_sdwa | 288 | 288 | 42 of 42 | 476.4 s | 8.3 s | | startup_image_sample_b | 72 | 72 | 11 of 11 | 138.5 s | 5.4 s | (times are the summed `offscreen_check` calls only, not compiles.) `ctest` of the same 15 tests: 15/15 passed. - Win2025 WARP (proxmox pool), dev and release on the final head, 17/17 each: `cmake --build --preset <dev|release> --target offscreen_check` then `ctest --preset <dev|release> --no-tests=error -R "gpu_case_runner|startup_gfx2hlsl_f16_alu_draw|startup_gfx2hlsl_f32_sdwa|startup_gfx2hlsl_f32_nan|startup_image_sample_b|startup_flat_param|draw_skip" -V` (gpu_case_runner, startup_flat_param_{controls,warp,hardware}, startup_image_sample_b_{controls,warp,hardware}, startup_gfx2hlsl_f32_nan{,_warp,_hardware}, startup_gfx2hlsl_f32_sdwa{,_warp,_hardware}, startup_gfx2hlsl_f16_alu_draw_{controls,warp,hardware}, startup_gfx2hlsl_draw_skip). AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-26 08:01:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T07:01:22Z.


I reproduced the Linux failure on this head. The f32_nan and f32_sdwa cases now call gpu_case_runner.run, so the existing subprocess.run mock misses them and Popen tries to execute the fake renderer. In startup_gfx2hlsl_draw_skip_check.py, set renderer_runner = getattr(module, "gpu_case_runner", module.subprocess) and patch renderer_runner.run. On Windows Python 3.12 this kept all 18 existing subcases green, including failure-before-skip = 1 and clean skip = 77.

The five runner tests also pass here, but emit ResourceWarning for unclosed pipes and a live child after fallback. Please close the stdio handles and wait for the process on every exit, including failed handshake and dead-server restart. The runner test should verify cleanup before calling the one-shot fallback.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7185015119 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#issuecomment-7185015119). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T07:01:22Z. --- I reproduced the Linux failure on this head. The f32_nan and f32_sdwa cases now call gpu_case_runner.run, so the existing subprocess.run mock misses them and Popen tries to execute the fake renderer. In startup_gfx2hlsl_draw_skip_check.py, set renderer_runner = getattr(module, "gpu_case_runner", module.subprocess) and patch renderer_runner.run. On Windows Python 3.12 this kept all 18 existing subcases green, including failure-before-skip = 1 and clean skip = 77. The five runner tests also pass here, but emit ResourceWarning for unclosed pipes and a live child after fallback. Please close the stdio handles and wait for the process on every exit, including failed handshake and dead-server restart. The runner test should verify cleanup before calling the one-shot fallback.
RavenCurseBurg commented 2026-11-26 08:01:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-26T07:43:21Z.


I will check the updated served renderer on native Windows D3D12 on the Intel UHD 770 and RTX 4060, with WARP as a control. I will compare the one-shot and served routes on the same executable, including wrong expected values followed by valid draws, and report the exact head and timings here.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7185762797 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#issuecomment-7185762797). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T07:43:21Z. --- I will check the updated served renderer on native Windows D3D12 on the Intel UHD 770 and RTX 4060, with WARP as a control. I will compare the one-shot and served routes on the same executable, including wrong expected values followed by valid draws, and report the exact head and timings here.
tedin7 commented 2026-11-26 08:01:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T07:50:04Z.


Thanks for the repro and the exact fix.

  • Linux failure: fixed in 6c2e55d1b. startup_gfx2hlsl_draw_skip_check.py now also patches gpu_case_runner.run, next to the existing subprocess.run patch, so the 18 subcases (failure-before-skip = 1, clean skip = 77) stay green. I kept both patches instead of getattr(module, "gpu_case_runner", ...) because the same loop also covers modules that still call subprocess.run.
  • ResourceWarning: fixed in aa6c9bd71. Every exit of a served process (failed handshake, skip 77, dead server and its restart, close at exit) now waits for the process, joins the two reader threads and closes stdin, stdout and stderr. New runner test test_every_exit_leaves_no_process_and_no_open_pipe checks that each of those servers has exited and has all three pipes closed, before the one-shot fallback result is used; I also fixed the test's own cleanup order, which emptied the server table before closing the servers. python3 -B -W error::ResourceWarning tests/gpu_case_runner_check.py: 6 tests OK; the four adopted checks also run clean with that flag.
  • Old versus new on a real card (RTX 3090, Wine + vkd3d-proton, same executable): f16_alu_draw 220/220, f32_nan 194/194, f32_sdwa 288/288, image_sample_b 72/72 identical (exit code, stdout, stderr); 113/113 wrong-value controls fail on both routes with the same message. Table in the description.

@RavenCurseBurg, thank you for checking native Windows D3D12 on the Intel UHD 770 and RTX 4060. The head to test is aa6c9bd71.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7185885399 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#issuecomment-7185885399). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T07:50:04Z. --- Thanks for the repro and the exact fix. - Linux failure: fixed in 6c2e55d1b. `startup_gfx2hlsl_draw_skip_check.py` now also patches `gpu_case_runner.run`, next to the existing `subprocess.run` patch, so the 18 subcases (failure-before-skip = 1, clean skip = 77) stay green. I kept both patches instead of `getattr(module, "gpu_case_runner", ...)` because the same loop also covers modules that still call `subprocess.run`. - ResourceWarning: fixed in aa6c9bd71. Every exit of a served process (failed handshake, skip 77, dead server and its restart, close at exit) now waits for the process, joins the two reader threads and closes stdin, stdout and stderr. New runner test `test_every_exit_leaves_no_process_and_no_open_pipe` checks that each of those servers has exited and has all three pipes closed, before the one-shot fallback result is used; I also fixed the test's own cleanup order, which emptied the server table before closing the servers. `python3 -B -W error::ResourceWarning tests/gpu_case_runner_check.py`: 6 tests OK; the four adopted checks also run clean with that flag. - Old versus new on a real card (RTX 3090, Wine + vkd3d-proton, same executable): f16_alu_draw 220/220, f32_nan 194/194, f32_sdwa 288/288, image_sample_b 72/72 identical (exit code, stdout, stderr); 113/113 wrong-value controls fail on both routes with the same message. Table in the description. @RavenCurseBurg, thank you for checking native Windows D3D12 on the Intel UHD 770 and RTX 4060. The head to test is aa6c9bd71. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-26 09:04:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T08:28:09Z.


Windows 11 build 26200, Python 3.12, exact 7e0a4e39: python -B -W error::ResourceWarning tests/gpu_case_runner_check.py failed 2/9. The crash reported a 300 s timeout immediately, and the 2 s hang case returned after 60.06 s. The separate draw-skip ordering test passed.

I isolated two causes. The Windows fake runs through a .cmd parent. Killing that parent leaves its sleeping Python child holding stdout/stderr, so cleanup blocks until the child exits. Launching the fake Python renderer directly made the 2 s hang test pass, but the crash still raced EOF against Popen.poll(). With the direct child plus a bounded self.proc.wait(timeout=max(0.0, deadline - time.monotonic())) when the reply is missing, all 9 tests passed with ResourceWarning promoted to an error. The exit-code check and the no-replay assertions stayed in place. Please make the Windows fake a direct child of the runner and preserve the one shared deadline when collecting the process status.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7186630687 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#issuecomment-7186630687). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T08:28:09Z. --- Windows 11 build 26200, Python 3.12, exact `7e0a4e39`: `python -B -W error::ResourceWarning tests/gpu_case_runner_check.py` failed 2/9. The crash reported a 300 s timeout immediately, and the 2 s hang case returned after 60.06 s. The separate draw-skip ordering test passed. I isolated two causes. The Windows fake runs through a .cmd parent. Killing that parent leaves its sleeping Python child holding stdout/stderr, so cleanup blocks until the child exits. Launching the fake Python renderer directly made the 2 s hang test pass, but the crash still raced EOF against Popen.poll(). With the direct child plus a bounded `self.proc.wait(timeout=max(0.0, deadline - time.monotonic()))` when the reply is missing, all 9 tests passed with ResourceWarning promoted to an error. The exit-code check and the no-replay assertions stayed in place. Please make the Windows fake a direct child of the runner and preserve the one shared deadline when collecting the process status.
RavenCurseBurg commented 2026-11-26 09:04:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-26T08:34:50Z.


Native Windows comparison at 7e0a4e39: all 2,694 one-shot/served pairs matched on exit code, full stdout and full stderr, including the repeated adapter banners. The comparison covers the four adopted checks on WARP, Intel UHD 770 and RTX 4060. The runner stayed attached to the live server throughout each suite.

Suite Fixture calls per adapter Extra wrong-value + restored pairs Total paired calls per adapter
image sample bias 72 4 + 4 80
binary16 ALU 220 32 + 32 284
binary32 NaN 194 13 + 13 220
binary32 SDWA 288 13 + 13 314

Each of the 62 additional wrong-value calls per adapter returned 1 through both routes and printed the same mismatch; the immediately following valid draw returned 0. For timing, one-shot/served summed renderer call times in seconds were WARP 147.86 / 14.99, UHD 770 524.30 / 36.81, RTX 4060 454.01 / 53.20. The three suites of adapter measurements ran concurrently on the same host, with alternating call order and shader compilation outside the timer. These are single-run measurements under load.

Windows 11 build 26100.9711, in-box D3D12, WARP 10.0.26100.9711, Intel 32.0.101.5973, NVIDIA 32.0.15.9579. The debug layer was unavailable. The local Zig 0.13/Clang build included the PR's actual service loop, argument and diagnostic paths, the three adopted operation handlers, desktop GPU setup and D3D12 draw implementations. The local executable selected those operations and explicitly flushed output at one-shot exit for MinGW. All four suites used both DXC and FXC. The comparison script also takes a standard full offscreen_check.exe:

python -B tests/verify_served_native_parity.py <renderer> <dxc> <fxc> <WARP|Intel|NVIDIA> <output-dir>

The separate process-lifecycle unit suite reproduced the two Windows failures already reported above, including the 2-second case returning after 60.43 seconds. The device comparisons above all completed. AI-assisted with Codex.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7186766645 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#issuecomment-7186766645). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T08:34:50Z. --- Native Windows comparison at `7e0a4e39`: all **2,694 one-shot/served pairs** matched on exit code, full stdout and full stderr, including the repeated adapter banners. The comparison covers the four adopted checks on WARP, Intel UHD 770 and RTX 4060. The runner stayed attached to the live server throughout each suite. | Suite | Fixture calls per adapter | Extra wrong-value + restored pairs | Total paired calls per adapter | |---|---:|---:|---:| | image sample bias | 72 | 4 + 4 | 80 | | binary16 ALU | 220 | 32 + 32 | 284 | | binary32 NaN | 194 | 13 + 13 | 220 | | binary32 SDWA | 288 | 13 + 13 | 314 | Each of the 62 additional wrong-value calls per adapter returned 1 through both routes and printed the same mismatch; the immediately following valid draw returned 0. For timing, one-shot/served summed renderer call times in seconds were WARP **147.86 / 14.99**, UHD 770 **524.30 / 36.81**, RTX 4060 **454.01 / 53.20**. The three suites of adapter measurements ran concurrently on the same host, with alternating call order and shader compilation outside the timer. These are single-run measurements under load. Windows 11 build 26100.9711, in-box D3D12, WARP 10.0.26100.9711, Intel 32.0.101.5973, NVIDIA 32.0.15.9579. The debug layer was unavailable. The local Zig 0.13/Clang build included the PR's actual service loop, argument and diagnostic paths, the three adopted operation handlers, desktop GPU setup and D3D12 draw implementations. The local executable selected those operations and explicitly flushed output at one-shot exit for MinGW. All four suites used both DXC and FXC. The [comparison script](https://github.com/RavenCurseBurg/Xbox2Windows/blob/2e8f1e7458b57ccb09b667e302469900f43fd232/tests/verify_served_native_parity.py) also takes a standard full `offscreen_check.exe`: ```text python -B tests/verify_served_native_parity.py <renderer> <dxc> <fxc> <WARP|Intel|NVIDIA> <output-dir> ``` The separate process-lifecycle unit suite reproduced the two Windows failures already reported above, including the 2-second case returning after 60.43 seconds. The device comparisons above all completed. AI-assisted with Codex.
tedin7 commented 2026-11-26 09:04:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T08:42:58Z.


Thank you both, this is exactly the data I needed.

@R0Y00: both causes fixed in 069f17228.

  • The runner now accepts the renderer as a command list, and the runner tests launch the fake interpreter and its script directly, so there is no .cmd or shell parent holding the pipes after a kill.
  • When a reply is missing, the runner waits for the process only up to the same case deadline (proc.wait(timeout=max(0, deadline - now))) before reading its exit status, so a crash reports exited (code 3) and not a timeout. One deadline per case stays.
  • The exit-code check and the no-replay assertion (the case log shows the crashing case once) are unchanged. On Linux: 9 tests OK with -W error::ResourceWarning, and the four adopted checks plus the draw-skip check pass. I cannot run Windows Python 3.12 here, so please re-run python -B -W error::ResourceWarning tests/gpu_case_runner_check.py on 069f17228.

@RavenCurseBurg: thank you for the 2,694 matching pairs on WARP, UHD 770 and RTX 4060, wrong-value controls included. Your numbers are for 7e0a4e39; the runner changed only in the process handling since, not in the protocol, the banners or the verdict mapping.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7186930308 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#issuecomment-7186930308). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T08:42:58Z. --- Thank you both, this is exactly the data I needed. @R0Y00: both causes fixed in 069f17228. - The runner now accepts the renderer as a command list, and the runner tests launch the fake interpreter and its script directly, so there is no `.cmd` or shell parent holding the pipes after a kill. - When a reply is missing, the runner waits for the process only up to the same case deadline (`proc.wait(timeout=max(0, deadline - now))`) before reading its exit status, so a crash reports `exited (code 3)` and not a timeout. One deadline per case stays. - The exit-code check and the no-replay assertion (the case log shows the crashing case once) are unchanged. On Linux: 9 tests OK with `-W error::ResourceWarning`, and the four adopted checks plus the draw-skip check pass. I cannot run Windows Python 3.12 here, so please re-run `python -B -W error::ResourceWarning tests/gpu_case_runner_check.py` on 069f17228. @RavenCurseBurg: thank you for the 2,694 matching pairs on WARP, UHD 770 and RTX 4060, wrong-value controls included. Your numbers are for 7e0a4e39; the runner changed only in the process handling since, not in the protocol, the banners or the verdict mapping. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-26 10:04:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T09:28:06Z.


Rechecked 069f1722 on native Windows 11 build 26200 with Python 3.12. python -B -W error::ResourceWarning tests/gpu_case_runner_check.py now passes 9/9, including the 2 s deadline and crash exit-code tests. startup_gfx2hlsl_draw_skip_check.py also passes. This resolves my two Windows runner findings. Raven's 2,694 paired GPU results above were on the preceding head; this run covers the revised process-handling tests.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7188030169 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#issuecomment-7188030169). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T09:28:06Z. --- Rechecked `069f1722` on native Windows 11 build 26200 with Python 3.12. `python -B -W error::ResourceWarning tests/gpu_case_runner_check.py` now passes 9/9, including the 2 s deadline and crash exit-code tests. `startup_gfx2hlsl_draw_skip_check.py` also passes. This resolves my two Windows runner findings. Raven's 2,694 paired GPU results above were on the preceding head; this run covers the revised process-handling tests.
tedin7 commented 2026-11-26 10:04:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T09:50:16Z.


@R0Y00: thank you for the native Windows re-check of 069f1722 (9/9 and the draw-skip check).

Gate status from our independent reviewer: code gate PASS on 069f17228. Win2025 dev and release 17/17 each (gpu_case_runner passes there in 13 s), served-versus-one-shot compared on every case of the four adopted checks with the banner included, wrong-value controls included: 0 mismatches. A RunPod run showed one intermittent 1800 s timeout of startup_gfx2hlsl_f32_sdwa_warp on that head; it did not repeat on the next head, and the re-gate on that head is running.

The head is now 43360b0e9: the client ends the served renderer with an explicit --end line before closing stdin (the service loop stops on it), because a Wine launcher may not pass the end of stdin on. An older renderer answers that line with exit 2 and still ends at the end of stdin. Nothing else changed in the protocol, banners or verdicts.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7188541654 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#issuecomment-7188541654). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T09:50:16Z. --- @R0Y00: thank you for the native Windows re-check of 069f1722 (9/9 and the draw-skip check). Gate status from our independent reviewer: code gate PASS on 069f17228. Win2025 dev and release 17/17 each (gpu_case_runner passes there in 13 s), served-versus-one-shot compared on every case of the four adopted checks with the banner included, wrong-value controls included: 0 mismatches. A RunPod run showed one intermittent 1800 s timeout of `startup_gfx2hlsl_f32_sdwa_warp` on that head; it did not repeat on the next head, and the re-gate on that head is running. The head is now 43360b0e9: the client ends the served renderer with an explicit `--end` line before closing stdin (the service loop stops on it), because a Wine launcher may not pass the end of stdin on. An older renderer answers that line with exit 2 and still ends at the end of stdin. Nothing else changed in the protocol, banners or verdicts. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot] commented 2026-11-26 10:52:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:52:39Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f5747cc0bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6072833634 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#pullrequestreview-6072833634). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T10:52:39Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `f5747cc0bf` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-26 11:03:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:36:23Z.


Independent review of head f5747cc0b (served GPU draw cases): PASS.

Verification:

  • Windows Server 2025 (D3D12 WARP), dev 17/17 and release 17/17 with ctest --no-tests=error -R 'gpu_case_runner|startup_gfx2hlsl_f16_alu_draw|startup_gfx2hlsl_f32_sdwa|startup_gfx2hlsl_f32_nan|startup_image_sample_b|startup_flat_param|draw_skip': gpu_case_runner, startup_flat_param_{controls,warp,hardware}, startup_image_sample_b_{controls,warp,hardware}, startup_gfx2hlsl_f32_nan{,_warp,_hardware}, startup_gfx2hlsl_f32_sdwa{,_warp,hardware}, startup_gfx2hlsl_f16_alu_draw{controls,warp,hardware}, startup_gfx2hlsl_draw_skip.
  • Same verdicts with and without the fast path: on the previous head, a patched runner sent every case of the four adopted checks through the served device and through the one-shot call and asserted identical exit code, stdout (banner included) and stderr: 16 tests, no mismatch, wrong-value controls included. The commits since only change how the renderer process is ended.
  • Review findings re-checked with controls that fail before the fix: a second-case debug warning now fails the sample_b-style check; a renderer crash after the handshake is a failed verdict and the case is not run again; both reply indices are validated; one deadline per case; a launcher child holding the pipes no longer blocks the end of the test (removing the group kill makes that test fail). Linux python3 -B tests/gpu_case_runner_check.py passes; mutating the failed verdict to a pass, dropping the index check or dropping the per-case banner each fail the check.
  • The PR body now describes the final behaviour (failed verdict instead of a retry, banner with every case, strict comparison).
  • Not run here: RunPod (non-blocking, off). A test that fails without the explicit --end line is still missing; closing stdin also ends the server in the fake renderer, so the line itself is covered only by the real Wine run.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189588050 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#issuecomment-7189588050). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T10:36:23Z. --- Independent review of head f5747cc0b (served GPU draw cases): PASS. Verification: - Windows Server 2025 (D3D12 WARP), dev 17/17 and release 17/17 with `ctest --no-tests=error -R 'gpu_case_runner|startup_gfx2hlsl_f16_alu_draw|startup_gfx2hlsl_f32_sdwa|startup_gfx2hlsl_f32_nan|startup_image_sample_b|startup_flat_param|draw_skip'`: gpu_case_runner, startup_flat_param_{controls,warp,hardware}, startup_image_sample_b_{controls,warp,hardware}, startup_gfx2hlsl_f32_nan{,_warp,_hardware}, startup_gfx2hlsl_f32_sdwa{,_warp,_hardware}, startup_gfx2hlsl_f16_alu_draw_{controls,warp,hardware}, startup_gfx2hlsl_draw_skip. - Same verdicts with and without the fast path: on the previous head, a patched runner sent every case of the four adopted checks through the served device and through the one-shot call and asserted identical exit code, stdout (banner included) and stderr: 16 tests, no mismatch, wrong-value controls included. The commits since only change how the renderer process is ended. - Review findings re-checked with controls that fail before the fix: a second-case debug warning now fails the sample_b-style check; a renderer crash after the handshake is a failed verdict and the case is not run again; both reply indices are validated; one deadline per case; a launcher child holding the pipes no longer blocks the end of the test (removing the group kill makes that test fail). Linux `python3 -B tests/gpu_case_runner_check.py` passes; mutating the failed verdict to a pass, dropping the index check or dropping the per-case banner each fail the check. - The PR body now describes the final behaviour (failed verdict instead of a retry, banner with every case, strict comparison). - Not run here: RunPod (non-blocking, off). A test that fails without the explicit `--end` line is still missing; closing stdin also ends the server in the fake renderer, so the line itself is covered only by the real Wine run. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 11:03:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:36:44Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T10:52:41.975949Z f5747cc Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189595874 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#issuecomment-7189595874). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T10:36:44Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"f5747cc0bf45b98728c70ee1c9699364fd799678","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T10:52:41.975949Z">2026-11-26T10:52:41.975949Z</relative-time> | `f5747cc` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot commented 2026-11-26 11:03:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:52:39Z.

Code review location: tests/gpu_case_runner.py; line 179

@@ -0,0 +1,212 @@
+"""Shared by the GPU checks: one D3D12 device per test instead of one offscreen_check process per case (issue #448).
+
+run(renderer, adapter, args)
+    The same as subprocess.run([renderer, adapter, *args], capture_output=True, text=True), but the case goes to a long-lived
+    `offscreen_check <adapter> --serve` process of this test (one device for all its cases). The returned
+    subprocess.CompletedProcess has the one-shot meaning: returncode 0 pass, 1 failure, 77 skip, 2 bad arguments. Its stdout
+    and stderr are the text the one-shot call would print, adapter banner included for EVERY case (so a check that looks for
+    "debug_layer=enabled" and "debug_errors=0 debug_warnings=0" sees them in each case, as it does in a one-shot call).
+
+    Only a server that cannot start falls back to the one-shot call (an older offscreen_check without `--serve`, no adapter,
+    X2W_FLAT_SERVER=0): no case has been sent yet, so the one-shot call gives the verdict. Once a case has been sent, a
+    renderer that dies, hangs past CASE_TIMEOUT_S, or answers with the wrong case number gives a FAILED verdict (returncode 1,
+    the reason on stderr) for that case; it is never run again, so a crash cannot turn into a pass. The next case starts a
+    new server.
+"""
+import atexit
+import os
+import queue
+import signal
+import subprocess
+import threading
+import time
+
+CASE_TIMEOUT_S = 300
+SERVER_OFF = os.environ.get('X2W_FLAT_SERVER') == '0'
+DEVICE_REMOVED = 'device removed during case'
+_servers = {}
+
+
+def _command(renderer):
+    """The renderer as a command prefix: a path, or a list such as an interpreter plus its script (a launcher in between would
+    keep the pipes open after the renderer is killed)."""
+    return [str(part) for part in renderer] if isinstance(renderer, (list, tuple)) else [str(renderer)]
+
+
+class _Lost(Exception):
+    """The server did not answer the case it was sent."""
+
+
+class _Server:
+    def __init__(self, renderer, adapter):
+        self.out, self.err = queue.Queue(), queue.Queue()
+        self.proc = subprocess.Popen([*_command(renderer), adapter, '--serve'], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+                                     stderr=subprocess.PIPE, text=True, bufsize=1,
+                                     start_new_session=os.name == 'posix')   # own process group: a launcher's children die with it
+        self.banner, self.banner_err, self.ready, self.returncode, self.stderr_text = '', '', False, None, ''
+        self.next_case = 0
+        self.threads = [threading.Thread(target=self._pump, args=(self.proc.stdout, self.out, 'X2WCASE '), daemon=True),
+                        threading.Thread(target=self._pump, args=(self.proc.stderr, self.err, 'X2WEND '), daemon=True)]
+        for thread in self.threads:
+            thread.start()
+        deadline = time.monotonic() + CASE_TIMEOUT_S
+        first = self._get(self.out, deadline)        # the banner, closed by the marker pair of case -1
+        banner_err = self._get(self.err, deadline)
+        if first is None or first[1] != -1 or first[2] != 0 or banner_err is None or banner_err[1] != -1:
+            self.proc.kill()                         # closed first (skip 77, an unknown mode, a crash) or a hang
+            self.proc.wait()
+            self.returncode = self.proc.returncode
+            self.stderr_text = ''.join(self._drain(self.err))
+            self.banner = first[0] if first else ''
+            self._release()
+            return
+        self.banner, self.banner_err, self.ready = first[0], banner_err[0], True
+
+    @staticmethod
+    def _pump(stream, sink, marker):
+        """Split a stream into per-case chunks at its marker line "<marker><case index> [exit code]"."""
+        chunk = []
+        for line in stream:
+            parts = line.split()
+            if line.startswith(marker) and len(parts) == (3 if marker == 'X2WCASE ' else 2):
+                try:
+                    index = int(parts[1])
+                    code = int(parts[2]) if marker == 'X2WCASE ' else 0
+                except ValueError:
+                    chunk.append(line)
+                    continue
+                sink.put((''.join(chunk), index, code))
+                chunk = []
+            else:
+                chunk.append(line)
+        if chunk:
+            sink.put((''.join(chunk), None, None))
+        sink.put(None)
+
+    @staticmethod
+    def _get(q, deadline):
+        """The next (text, case index, exit code) of a stream, or None at its end or the deadline."""
+        try:
+            item = q.get(timeout=max(0.0, deadline - time.monotonic()))
+        except queue.Empty:
+            return None
+        return item                                 # None at the end of the stream; an unmarked tail has index None
+
+    @staticmethod
+    def _drain(q):
+        items = []
+        while True:
+            try:
+                item = q.get(timeout=2)
+            except queue.Empty:
+                return items
+            if item is None:
+                return items
+            items.append(item[0])
+
+    def case(self, args):
+        """Send one case; the reply must carry exactly this case's number on both streams, else _Lost."""
+        index, self.next_case = self.next_case, self.next_case + 1
+        deadline = time.monotonic() + CASE_TIMEOUT_S
+        try:
+            self.proc.stdin.write('\t'.join(args) + '\n')
+            self.proc.stdin.flush()
+        except OSError as error:
+            raise _Lost('could not send the case: %s' % error)
+        out, err = self._get(self.out, deadline), self._get(self.err, deadline)
+        if out is None or err is None or out[1] is None or err[1] is None:
+            try:                                    # a dying process closes its pipes a moment before it can be reaped
+                self.proc.wait(timeout=max(0.0, deadline - time.monotonic()))
+            except subprocess.TimeoutExpired:
+                pass
+            state = 'timed out after %d s' % CASE_TIMEOUT_S if self.proc.poll() is None else 'exited (code %s)' % self.proc.poll()
+            raise _Lost('the renderer %s during the case' % state)
+        if out[1] != index or err[1] != index:
+            raise _Lost('the renderer answered case %s/%s to case %d' % (out[1], err[1], index))
+        return subprocess.CompletedProcess(self.proc.args, out[2], self.banner + out[0], self.banner_err + err[0])
+
+    def _kill_tree(self):
+        """Kill the renderer and everything it started (a Wine or shell launcher leaves a child that keeps the pipes open)."""
+        try:
+            if os.name == 'posix':
+                os.killpg(self.proc.pid, signal.SIGKILL)
+            else:
+                subprocess.run(['taskkill', '/F', '/T', '/PID', str(self.proc.pid)], capture_output=True)
+        except OSError:
+            pass
+        self.proc.kill()
+
+    def _release(self):
+        """Wait for the process, end its group, join the pump threads and close the pipes, so nothing is left behind."""
+        self.proc.wait()
+        self._kill_tree()
+        for thread in self.threads:                 # the pumps end at the end of the pipes
+            thread.join(timeout=5)
+        for stream, thread in ((self.proc.stdin, None), (self.proc.stdout, self.threads[0]), (self.proc.stderr, self.threads[1])):
+            if thread is None or not thread.is_alive():     # closing a pipe a pump is still reading would block
+                try:
+                    stream.close()
+                except (OSError, ValueError):
+                    pass
+
+    def kill(self):
+        self._kill_tree()
+        self._release()
+
+    def close(self):
+        try:
+            self.proc.stdin.write('--end\n')       # explicit: a launcher in between may not pass the end of stdin on
+            self.proc.stdin.close()
+            self.proc.wait(timeout=30)
+        except (OSError, ValueError, subprocess.TimeoutExpired):     # already closed, or it does not end
+            self._kill_tree()
+        self._release()
+
+
+def _close_all():
+    for server in _servers.values():
+        if server:
+            server.close()
+
+
+atexit.register(_close_all)
+
+
+def _failed(server, reason):
+    """The FAILED verdict of a case whose server did not answer it."""
+    text = ''.join(server._drain(server.err)) if server.proc.poll() is not None else ''
+    server.kill()
+    return subprocess.CompletedProcess(server.proc.args, 1, '', 'gpu_case_runner: %s\n%s' % (reason, text))

P2 Badge Retain renderer diagnostics when a served case is lost

When a renderer writes a diagnostic and then crashes or times out before its end markers, this returns only the generic _Lost message. For crashes, case() has already consumed the unmarked stderr chunk before raising; for timeouts, this skips draining while the renderer is alive and never recovers output after killing it. The empty stdout also drops the cached adapter/driver/debug-layer banner on first-case failures. A fake renderer printing an error before exiting with code 3 reproduces the diagnostic loss. Preserve the collected chunks, post-termination output and banner in the failed result.

AGENTS.md reference: AGENTS.md:L95-L96

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4707306454 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#discussion_r4707306454). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T10:52:39Z. **Code review location:** `tests/gpu_case_runner.py`; line 179 ~~~~diff @@ -0,0 +1,212 @@ +"""Shared by the GPU checks: one D3D12 device per test instead of one offscreen_check process per case (issue #448). + +run(renderer, adapter, args) + The same as subprocess.run([renderer, adapter, *args], capture_output=True, text=True), but the case goes to a long-lived + `offscreen_check <adapter> --serve` process of this test (one device for all its cases). The returned + subprocess.CompletedProcess has the one-shot meaning: returncode 0 pass, 1 failure, 77 skip, 2 bad arguments. Its stdout + and stderr are the text the one-shot call would print, adapter banner included for EVERY case (so a check that looks for + "debug_layer=enabled" and "debug_errors=0 debug_warnings=0" sees them in each case, as it does in a one-shot call). + + Only a server that cannot start falls back to the one-shot call (an older offscreen_check without `--serve`, no adapter, + X2W_FLAT_SERVER=0): no case has been sent yet, so the one-shot call gives the verdict. Once a case has been sent, a + renderer that dies, hangs past CASE_TIMEOUT_S, or answers with the wrong case number gives a FAILED verdict (returncode 1, + the reason on stderr) for that case; it is never run again, so a crash cannot turn into a pass. The next case starts a + new server. +""" +import atexit +import os +import queue +import signal +import subprocess +import threading +import time + +CASE_TIMEOUT_S = 300 +SERVER_OFF = os.environ.get('X2W_FLAT_SERVER') == '0' +DEVICE_REMOVED = 'device removed during case' +_servers = {} + + +def _command(renderer): + """The renderer as a command prefix: a path, or a list such as an interpreter plus its script (a launcher in between would + keep the pipes open after the renderer is killed).""" + return [str(part) for part in renderer] if isinstance(renderer, (list, tuple)) else [str(renderer)] + + +class _Lost(Exception): + """The server did not answer the case it was sent.""" + + +class _Server: + def __init__(self, renderer, adapter): + self.out, self.err = queue.Queue(), queue.Queue() + self.proc = subprocess.Popen([*_command(renderer), adapter, '--serve'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True, bufsize=1, + start_new_session=os.name == 'posix') # own process group: a launcher's children die with it + self.banner, self.banner_err, self.ready, self.returncode, self.stderr_text = '', '', False, None, '' + self.next_case = 0 + self.threads = [threading.Thread(target=self._pump, args=(self.proc.stdout, self.out, 'X2WCASE '), daemon=True), + threading.Thread(target=self._pump, args=(self.proc.stderr, self.err, 'X2WEND '), daemon=True)] + for thread in self.threads: + thread.start() + deadline = time.monotonic() + CASE_TIMEOUT_S + first = self._get(self.out, deadline) # the banner, closed by the marker pair of case -1 + banner_err = self._get(self.err, deadline) + if first is None or first[1] != -1 or first[2] != 0 or banner_err is None or banner_err[1] != -1: + self.proc.kill() # closed first (skip 77, an unknown mode, a crash) or a hang + self.proc.wait() + self.returncode = self.proc.returncode + self.stderr_text = ''.join(self._drain(self.err)) + self.banner = first[0] if first else '' + self._release() + return + self.banner, self.banner_err, self.ready = first[0], banner_err[0], True + + @staticmethod + def _pump(stream, sink, marker): + """Split a stream into per-case chunks at its marker line "<marker><case index> [exit code]".""" + chunk = [] + for line in stream: + parts = line.split() + if line.startswith(marker) and len(parts) == (3 if marker == 'X2WCASE ' else 2): + try: + index = int(parts[1]) + code = int(parts[2]) if marker == 'X2WCASE ' else 0 + except ValueError: + chunk.append(line) + continue + sink.put((''.join(chunk), index, code)) + chunk = [] + else: + chunk.append(line) + if chunk: + sink.put((''.join(chunk), None, None)) + sink.put(None) + + @staticmethod + def _get(q, deadline): + """The next (text, case index, exit code) of a stream, or None at its end or the deadline.""" + try: + item = q.get(timeout=max(0.0, deadline - time.monotonic())) + except queue.Empty: + return None + return item # None at the end of the stream; an unmarked tail has index None + + @staticmethod + def _drain(q): + items = [] + while True: + try: + item = q.get(timeout=2) + except queue.Empty: + return items + if item is None: + return items + items.append(item[0]) + + def case(self, args): + """Send one case; the reply must carry exactly this case's number on both streams, else _Lost.""" + index, self.next_case = self.next_case, self.next_case + 1 + deadline = time.monotonic() + CASE_TIMEOUT_S + try: + self.proc.stdin.write('\t'.join(args) + '\n') + self.proc.stdin.flush() + except OSError as error: + raise _Lost('could not send the case: %s' % error) + out, err = self._get(self.out, deadline), self._get(self.err, deadline) + if out is None or err is None or out[1] is None or err[1] is None: + try: # a dying process closes its pipes a moment before it can be reaped + self.proc.wait(timeout=max(0.0, deadline - time.monotonic())) + except subprocess.TimeoutExpired: + pass + state = 'timed out after %d s' % CASE_TIMEOUT_S if self.proc.poll() is None else 'exited (code %s)' % self.proc.poll() + raise _Lost('the renderer %s during the case' % state) + if out[1] != index or err[1] != index: + raise _Lost('the renderer answered case %s/%s to case %d' % (out[1], err[1], index)) + return subprocess.CompletedProcess(self.proc.args, out[2], self.banner + out[0], self.banner_err + err[0]) + + def _kill_tree(self): + """Kill the renderer and everything it started (a Wine or shell launcher leaves a child that keeps the pipes open).""" + try: + if os.name == 'posix': + os.killpg(self.proc.pid, signal.SIGKILL) + else: + subprocess.run(['taskkill', '/F', '/T', '/PID', str(self.proc.pid)], capture_output=True) + except OSError: + pass + self.proc.kill() + + def _release(self): + """Wait for the process, end its group, join the pump threads and close the pipes, so nothing is left behind.""" + self.proc.wait() + self._kill_tree() + for thread in self.threads: # the pumps end at the end of the pipes + thread.join(timeout=5) + for stream, thread in ((self.proc.stdin, None), (self.proc.stdout, self.threads[0]), (self.proc.stderr, self.threads[1])): + if thread is None or not thread.is_alive(): # closing a pipe a pump is still reading would block + try: + stream.close() + except (OSError, ValueError): + pass + + def kill(self): + self._kill_tree() + self._release() + + def close(self): + try: + self.proc.stdin.write('--end\n') # explicit: a launcher in between may not pass the end of stdin on + self.proc.stdin.close() + self.proc.wait(timeout=30) + except (OSError, ValueError, subprocess.TimeoutExpired): # already closed, or it does not end + self._kill_tree() + self._release() + + +def _close_all(): + for server in _servers.values(): + if server: + server.close() + + +atexit.register(_close_all) + + +def _failed(server, reason): + """The FAILED verdict of a case whose server did not answer it.""" + text = ''.join(server._drain(server.err)) if server.proc.poll() is not None else '' + server.kill() + return subprocess.CompletedProcess(server.proc.args, 1, '', 'gpu_case_runner: %s\n%s' % (reason, text)) ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Retain renderer diagnostics when a served case is lost** When a renderer writes a diagnostic and then crashes or times out before its end markers, this returns only the generic `_Lost` message. For crashes, `case()` has already consumed the unmarked stderr chunk before raising; for timeouts, this skips draining while the renderer is alive and never recovers output after killing it. The empty stdout also drops the cached adapter/driver/debug-layer banner on first-case failures. A fake renderer printing an error before exiting with code 3 reproduces the diagnostic loss. Preserve the collected chunks, post-termination output and banner in the failed result. AGENTS.md reference: [AGENTS.md:L95-L96](https://github.com/R0Y00/Xbox2Windows/blob/f5747cc0bf45b98728c70ee1c9699364fd799678/AGENTS.md#L95-L96) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-26 11:03:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:52:39Z.

Code review location: tests/gpu_case_runner_check.py; line 93

@@ -0,0 +1,210 @@
+"""tests/gpu_case_runner.py: the served cases answer like one-shot calls, and every failure of the server falls back to one.
+
+The renderer here is a fake offscreen_check (a Python script behind a one-line launcher) that speaks the `--serve` protocol of
+tests/offscreen_check.cpp: a banner closed by the marker pair of case -1, then per case the case text, "X2WEND <i>" on stderr and
+"X2WCASE <i> <exit code>" on stdout. Its one-shot mode prints the same text, so the two paths can be compared.
+"""
+import os
+import subprocess
+import sys
+import tempfile
+import time
+import unittest
+import unittest.mock
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+import gpu_case_runner as R  # noqa: E402
+
+FAKE = r'''
+import os, sys
+mode = sys.argv[1].split("=", 1)[1]
+adapter, args = sys.argv[2], sys.argv[3:]
+
+def one(args):
+    """The text and exit code of one case, as the real tool prints them."""
+    op = args[0]
+    with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cases.log"), "a") as log:
+        log.write(" ".join(args) + "\n")
+    if op == "--pass":
+        return "ok %s\ndebug_errors=0 debug_warnings=0\n" % args[1], "", 0
+    if op == "--warn":
+        return "ok %s\ndebug_errors=0 debug_warnings=1\n" % args[1], "", 0
+    if op == "--mismatch":
+        return "", "startup_flat_param mismatch %s\n" % args[1], 1
+    if op == "--skip":
+        return "skip: nothing\n", "", 77
+    return "", "Unknown GPU operation or invalid arguments: %s\n" % op, 2
+
+if mode == "grandchild":          # a launcher child that keeps the pipes open after the renderer is gone
+    import subprocess
+    child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(120)"])
+    with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "grandchild.pid"), "w") as pid_file:
+        pid_file.write(str(child.pid))
+banner = "backend=%s debug_layer=enabled\nadapter=Fake\n" % adapter
+if args and args[0] == "--serve":
+    if mode == "no-serve":
+        sys.stderr.write("Unknown GPU operation or invalid arguments: --serve\n")
+        sys.exit(2)
+    if mode == "no-adapter":
+        print("No D3D12-capable hardware adapter visible")
+        sys.exit(77)
+    sys.stdout.write(banner)
+    sys.stderr.write("XBOX2WINDOWS_ADAPTER: skipping Other\n")
+    sys.stderr.write("X2WEND -1\n")
+    print("X2WCASE -1 0", flush=True)
+    for index, line in enumerate(sys.stdin):
+        if line == "--end\n":
+            sys.exit(0)
+        out, err, code = one(line.rstrip("\n").split("\t"))
+        if mode == "die-at-%d" % index:
+            os._exit(3)
+        if mode == "hang-at-%d" % index:
+            import time
+            time.sleep(60)
+        if mode == "skew-at-%d" % index:
+            sys.stderr.write("X2WEND %d\n" % (index + 5))
+            print("X2WCASE %d 0" % index, flush=True)
+            continue
+        sys.stdout.write(out)
+        sys.stderr.write(err)
+        sys.stderr.write("X2WEND %d\n" % index)
+        print("X2WCASE %d %d" % (index, code), flush=True)
+    sys.exit(0)
+out, err, code = one(args)
+sys.stdout.write("ONESHOT " + banner + out)
+sys.stderr.write(err)
+sys.exit(code)
+'''
+
+
+def launcher(directory, name, mode):
+    """The renderer as an interpreter plus script, a direct child of the runner: killing it releases its pipes at once (a
+    .cmd or shell launcher in between would leave a sleeping grandchild holding them)."""
+    fake = directory / 'fake_offscreen.py'
+    fake.write_text(FAKE)
+    return [sys.executable, str(fake), '--mode=' + mode]
+
+
+class RunnerChecks(unittest.TestCase):
+    def setUp(self):
+        R._servers.clear()
+        self.addCleanup(R._servers.clear)
+        self.addCleanup(R._close_all)          # runs first: the servers of the test are closed before the table is emptied

P2 Badge Reset the opt-out flag for the served-path unit tests

When X2W_FLAT_SERVER=0 is set to exercise the supported one-shot path, R.SERVER_OFF is already True at import and this fixture never overrides it. The served-path tests consequently execute one-shot calls and fail—for example, test_served_cases_carry_their_own_text_and_exit_code receives the unexpected ONESHOT prefix. Since the runner check is registered in CMake, running the suite with the opt-out produces spurious failures even though the fallback works correctly. Save and restore R.SERVER_OFF in the fixture and set it to False for the served-path tests.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4707306463 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#discussion_r4707306463). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T10:52:39Z. **Code review location:** `tests/gpu_case_runner_check.py`; line 93 ~~~~diff @@ -0,0 +1,210 @@ +"""tests/gpu_case_runner.py: the served cases answer like one-shot calls, and every failure of the server falls back to one. + +The renderer here is a fake offscreen_check (a Python script behind a one-line launcher) that speaks the `--serve` protocol of +tests/offscreen_check.cpp: a banner closed by the marker pair of case -1, then per case the case text, "X2WEND <i>" on stderr and +"X2WCASE <i> <exit code>" on stdout. Its one-shot mode prints the same text, so the two paths can be compared. +""" +import os +import subprocess +import sys +import tempfile +import time +import unittest +import unittest.mock +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import gpu_case_runner as R # noqa: E402 + +FAKE = r''' +import os, sys +mode = sys.argv[1].split("=", 1)[1] +adapter, args = sys.argv[2], sys.argv[3:] + +def one(args): + """The text and exit code of one case, as the real tool prints them.""" + op = args[0] + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cases.log"), "a") as log: + log.write(" ".join(args) + "\n") + if op == "--pass": + return "ok %s\ndebug_errors=0 debug_warnings=0\n" % args[1], "", 0 + if op == "--warn": + return "ok %s\ndebug_errors=0 debug_warnings=1\n" % args[1], "", 0 + if op == "--mismatch": + return "", "startup_flat_param mismatch %s\n" % args[1], 1 + if op == "--skip": + return "skip: nothing\n", "", 77 + return "", "Unknown GPU operation or invalid arguments: %s\n" % op, 2 + +if mode == "grandchild": # a launcher child that keeps the pipes open after the renderer is gone + import subprocess + child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(120)"]) + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "grandchild.pid"), "w") as pid_file: + pid_file.write(str(child.pid)) +banner = "backend=%s debug_layer=enabled\nadapter=Fake\n" % adapter +if args and args[0] == "--serve": + if mode == "no-serve": + sys.stderr.write("Unknown GPU operation or invalid arguments: --serve\n") + sys.exit(2) + if mode == "no-adapter": + print("No D3D12-capable hardware adapter visible") + sys.exit(77) + sys.stdout.write(banner) + sys.stderr.write("XBOX2WINDOWS_ADAPTER: skipping Other\n") + sys.stderr.write("X2WEND -1\n") + print("X2WCASE -1 0", flush=True) + for index, line in enumerate(sys.stdin): + if line == "--end\n": + sys.exit(0) + out, err, code = one(line.rstrip("\n").split("\t")) + if mode == "die-at-%d" % index: + os._exit(3) + if mode == "hang-at-%d" % index: + import time + time.sleep(60) + if mode == "skew-at-%d" % index: + sys.stderr.write("X2WEND %d\n" % (index + 5)) + print("X2WCASE %d 0" % index, flush=True) + continue + sys.stdout.write(out) + sys.stderr.write(err) + sys.stderr.write("X2WEND %d\n" % index) + print("X2WCASE %d %d" % (index, code), flush=True) + sys.exit(0) +out, err, code = one(args) +sys.stdout.write("ONESHOT " + banner + out) +sys.stderr.write(err) +sys.exit(code) +''' + + +def launcher(directory, name, mode): + """The renderer as an interpreter plus script, a direct child of the runner: killing it releases its pipes at once (a + .cmd or shell launcher in between would leave a sleeping grandchild holding them).""" + fake = directory / 'fake_offscreen.py' + fake.write_text(FAKE) + return [sys.executable, str(fake), '--mode=' + mode] + + +class RunnerChecks(unittest.TestCase): + def setUp(self): + R._servers.clear() + self.addCleanup(R._servers.clear) + self.addCleanup(R._close_all) # runs first: the servers of the test are closed before the table is emptied ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Reset the opt-out flag for the served-path unit tests** When `X2W_FLAT_SERVER=0` is set to exercise the supported one-shot path, `R.SERVER_OFF` is already `True` at import and this fixture never overrides it. The served-path tests consequently execute one-shot calls and fail—for example, `test_served_cases_carry_their_own_text_and_exit_code` receives the unexpected `ONESHOT` prefix. Since the runner check is registered in CMake, running the suite with the opt-out produces spurious failures even though the fallback works correctly. Save and restore `R.SERVER_OFF` in the fixture and set it to `False` for the served-path tests. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-26 11:03:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:52:39Z.

Code review location: tests/gpu_case_runner_check.py; line 197

@@ -0,0 +1,210 @@
+"""tests/gpu_case_runner.py: the served cases answer like one-shot calls, and every failure of the server falls back to one.
+
+The renderer here is a fake offscreen_check (a Python script behind a one-line launcher) that speaks the `--serve` protocol of
+tests/offscreen_check.cpp: a banner closed by the marker pair of case -1, then per case the case text, "X2WEND <i>" on stderr and
+"X2WCASE <i> <exit code>" on stdout. Its one-shot mode prints the same text, so the two paths can be compared.
+"""
+import os
+import subprocess
+import sys
+import tempfile
+import time
+import unittest
+import unittest.mock
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+import gpu_case_runner as R  # noqa: E402
+
+FAKE = r'''
+import os, sys
+mode = sys.argv[1].split("=", 1)[1]
+adapter, args = sys.argv[2], sys.argv[3:]
+
+def one(args):
+    """The text and exit code of one case, as the real tool prints them."""
+    op = args[0]
+    with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cases.log"), "a") as log:
+        log.write(" ".join(args) + "\n")
+    if op == "--pass":
+        return "ok %s\ndebug_errors=0 debug_warnings=0\n" % args[1], "", 0
+    if op == "--warn":
+        return "ok %s\ndebug_errors=0 debug_warnings=1\n" % args[1], "", 0
+    if op == "--mismatch":
+        return "", "startup_flat_param mismatch %s\n" % args[1], 1
+    if op == "--skip":
+        return "skip: nothing\n", "", 77
+    return "", "Unknown GPU operation or invalid arguments: %s\n" % op, 2
+
+if mode == "grandchild":          # a launcher child that keeps the pipes open after the renderer is gone
+    import subprocess
+    child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(120)"])
+    with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "grandchild.pid"), "w") as pid_file:
+        pid_file.write(str(child.pid))
+banner = "backend=%s debug_layer=enabled\nadapter=Fake\n" % adapter
+if args and args[0] == "--serve":
+    if mode == "no-serve":
+        sys.stderr.write("Unknown GPU operation or invalid arguments: --serve\n")
+        sys.exit(2)
+    if mode == "no-adapter":
+        print("No D3D12-capable hardware adapter visible")
+        sys.exit(77)
+    sys.stdout.write(banner)
+    sys.stderr.write("XBOX2WINDOWS_ADAPTER: skipping Other\n")
+    sys.stderr.write("X2WEND -1\n")
+    print("X2WCASE -1 0", flush=True)
+    for index, line in enumerate(sys.stdin):
+        if line == "--end\n":
+            sys.exit(0)
+        out, err, code = one(line.rstrip("\n").split("\t"))
+        if mode == "die-at-%d" % index:
+            os._exit(3)
+        if mode == "hang-at-%d" % index:
+            import time
+            time.sleep(60)
+        if mode == "skew-at-%d" % index:
+            sys.stderr.write("X2WEND %d\n" % (index + 5))
+            print("X2WCASE %d 0" % index, flush=True)
+            continue
+        sys.stdout.write(out)
+        sys.stderr.write(err)
+        sys.stderr.write("X2WEND %d\n" % index)
+        print("X2WCASE %d %d" % (index, code), flush=True)
+    sys.exit(0)
+out, err, code = one(args)
+sys.stdout.write("ONESHOT " + banner + out)
+sys.stderr.write(err)
+sys.exit(code)
+'''
+
+
+def launcher(directory, name, mode):
+    """The renderer as an interpreter plus script, a direct child of the runner: killing it releases its pipes at once (a
+    .cmd or shell launcher in between would leave a sleeping grandchild holding them)."""
+    fake = directory / 'fake_offscreen.py'
+    fake.write_text(FAKE)
+    return [sys.executable, str(fake), '--mode=' + mode]
+
+
+class RunnerChecks(unittest.TestCase):
+    def setUp(self):
+        R._servers.clear()
+        self.addCleanup(R._servers.clear)
+        self.addCleanup(R._close_all)          # runs first: the servers of the test are closed before the table is emptied
+        self.tmp = tempfile.TemporaryDirectory()
+        self.addCleanup(self.tmp.cleanup)
+        self.dir = Path(self.tmp.name)
+
+    def run_case(self, renderer, *args):
+        return R.run(renderer, 'warp', args)
+
+    def test_served_cases_carry_their_own_text_and_exit_code(self):
+        renderer = launcher(self.dir, 'fake', 'serve')
+        first = self.run_case(renderer, '--pass', 'a')
+        second = self.run_case(renderer, '--mismatch', 'b')
+        third = self.run_case(renderer, '--pass', 'c')
+        self.assertEqual((first.returncode, second.returncode, third.returncode), (0, 1, 0))
+        self.assertEqual(first.stdout, 'backend=warp debug_layer=enabled\nadapter=Fake\nok a\ndebug_errors=0 debug_warnings=0\n')
+        self.assertEqual(first.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\n')
+        self.assertEqual(second.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\nstartup_flat_param mismatch b\n')
+        self.assertEqual(third.stdout, 'backend=warp debug_layer=enabled\nadapter=Fake\nok c\ndebug_errors=0 debug_warnings=0\n')  # banner on every case
+        self.assertEqual(third.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\n')
+        self.assertEqual(self.run_case(renderer, '--bogus').returncode, 2)
+
+    def test_skip_and_missing_adapter_keep_their_exit_code(self):
+        self.assertEqual(self.run_case(launcher(self.dir, 'skip', 'serve'), '--skip').returncode, 77)
+        none = self.run_case(launcher(self.dir, 'none', 'no-adapter'), '--pass', 'x')
+        self.assertEqual(none.returncode, 77)
+        self.assertIn('No D3D12-capable hardware adapter visible', none.stdout)
+
+    def test_a_renderer_without_serve_falls_back_to_one_shot_calls(self):
+        renderer = launcher(self.dir, 'old', 'no-serve')
+        result = self.run_case(renderer, '--mismatch', 'z')
+        self.assertEqual(result.returncode, 1)
+        self.assertTrue(result.stdout.startswith('ONESHOT '))
+        self.assertEqual(self.run_case(renderer, '--pass', 'q').returncode, 0)
+
+    def executed(self):
+        log = self.dir / 'cases.log'
+        return log.read_text().splitlines() if log.exists() else []
+
+    def test_a_crash_after_the_handshake_is_a_failed_verdict_and_the_case_is_not_run_again(self):
+        renderer = launcher(self.dir, 'dies', 'die-at-1')
+        self.assertEqual(self.run_case(renderer, '--pass', 'a').returncode, 0)
+        lost = self.run_case(renderer, '--pass', 'b')                 # the renderer dies on this case, which would pass if re-run
+        self.assertEqual(lost.returncode, 1)
+        self.assertIn('exited (code 3)', lost.stderr)
+        self.assertEqual(self.executed(), ['--pass a', '--pass b'])  # fake logs the case before dying; never a second time
+        self.assertEqual(self.run_case(renderer, '--pass', 'c').returncode, 0)     # the next case gets a new server
+
+    def test_a_silent_renderer_fails_the_case_after_one_deadline(self):
+        renderer = launcher(self.dir, 'hangs', 'hang-at-0')
+        self.addCleanup(setattr, R, 'CASE_TIMEOUT_S', R.CASE_TIMEOUT_S)
+        R.CASE_TIMEOUT_S = 2
+        started = time.monotonic()
+        lost = self.run_case(renderer, '--pass', 'a')
+        self.assertEqual(lost.returncode, 1)
+        self.assertIn('timed out after 2 s', lost.stderr)
+        self.assertLess(time.monotonic() - started, 4)               # one deadline for both streams, not one each
+
+    def test_a_reply_with_the_wrong_case_number_fails_the_case(self):
+        lost = self.run_case(launcher(self.dir, 'skew', 'skew-at-1'), '--pass', 'a')
+        self.assertEqual(lost.returncode, 0)
+        lost = self.run_case(launcher(self.dir, 'skew', 'skew-at-1'), '--pass', 'b')
+        self.assertEqual(lost.returncode, 1)
+        self.assertIn('answered case', lost.stderr)
+
+    def test_a_debug_warning_of_a_later_case_is_visible_to_the_check(self):
+        renderer = launcher(self.dir, 'fake', 'serve')
+        self.run_case(renderer, '--pass', 'a')
+        later = self.run_case(renderer, '--warn', 'b')
+        self.assertIn('debug_layer=enabled', later.stdout)           # the check looks for the status in every case
+        self.assertIn('debug_errors=0 debug_warnings=1', later.stdout)
+
+    def test_every_exit_leaves_no_process_and_no_open_pipe(self):
+        made = []
+        real = R._Server
+
+        def record(*args):
+            made.append(real(*args))
+            return made[-1]
+
+        with unittest.mock.patch.object(R, '_Server', record):
+            self.run_case(launcher(self.dir, 'old', 'no-serve'), '--pass', 'a')      # failed handshake, then the one-shot call
+            self.run_case(launcher(self.dir, 'none', 'no-adapter'), '--pass', 'a')   # skip 77 at the handshake
+            dies = launcher(self.dir, 'dies', 'die-at-1')
+            self.run_case(dies, '--pass', 'a')
+            self.run_case(dies, '--mismatch', 'b')                                   # dead server: failed verdict
+            self.run_case(dies, '--pass', 'c')                                       # next case, new server
+            R._close_all()                                                           # that server, at exit
+        self.assertEqual(len(made), 4)
+        for server in made:
+            self.assertIsNotNone(server.proc.poll())
+            self.assertTrue(all(s.closed for s in (server.proc.stdin, server.proc.stdout, server.proc.stderr)))
+
+    @unittest.skipUnless(os.name == 'posix', 'process groups')
+    def test_a_launcher_child_holding_the_pipes_does_not_block_the_end_of_the_test(self):
+        renderer = launcher(self.dir, 'grand', 'grandchild')
+        self.assertEqual(self.run_case(renderer, '--pass', 'a').returncode, 0)
+        pid = int((self.dir / 'grandchild.pid').read_text())
+        started = time.monotonic()
+        R._close_all()                                               # the renderer is gone but its child holds stdout and stderr
+        self.assertLess(time.monotonic() - started, 20)
+        for _ in range(50):                                          # the child was killed with the group
+            try:
+                os.kill(pid, 0)
+            except ProcessLookupError:
+                break

P2 Badge Distinguish terminated zombies from live launcher children

In a Linux container whose PID 1 does not reap orphaned children, _close_all() successfully kills the grandchild but its PID remains as a zombie. os.kill(pid, 0) still succeeds for that dead process, so this loop reaches self.fail() and the runner check rejects correct cleanup. This reproduces in the current container, where the child has state Z; all 10 tests pass under a reaping harness. Check whether the child is actually running or arrange for the fixture to reap it instead of requiring the PID to disappear.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4707306476 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#discussion_r4707306476). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T10:52:39Z. **Code review location:** `tests/gpu_case_runner_check.py`; line 197 ~~~~diff @@ -0,0 +1,210 @@ +"""tests/gpu_case_runner.py: the served cases answer like one-shot calls, and every failure of the server falls back to one. + +The renderer here is a fake offscreen_check (a Python script behind a one-line launcher) that speaks the `--serve` protocol of +tests/offscreen_check.cpp: a banner closed by the marker pair of case -1, then per case the case text, "X2WEND <i>" on stderr and +"X2WCASE <i> <exit code>" on stdout. Its one-shot mode prints the same text, so the two paths can be compared. +""" +import os +import subprocess +import sys +import tempfile +import time +import unittest +import unittest.mock +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import gpu_case_runner as R # noqa: E402 + +FAKE = r''' +import os, sys +mode = sys.argv[1].split("=", 1)[1] +adapter, args = sys.argv[2], sys.argv[3:] + +def one(args): + """The text and exit code of one case, as the real tool prints them.""" + op = args[0] + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cases.log"), "a") as log: + log.write(" ".join(args) + "\n") + if op == "--pass": + return "ok %s\ndebug_errors=0 debug_warnings=0\n" % args[1], "", 0 + if op == "--warn": + return "ok %s\ndebug_errors=0 debug_warnings=1\n" % args[1], "", 0 + if op == "--mismatch": + return "", "startup_flat_param mismatch %s\n" % args[1], 1 + if op == "--skip": + return "skip: nothing\n", "", 77 + return "", "Unknown GPU operation or invalid arguments: %s\n" % op, 2 + +if mode == "grandchild": # a launcher child that keeps the pipes open after the renderer is gone + import subprocess + child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(120)"]) + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "grandchild.pid"), "w") as pid_file: + pid_file.write(str(child.pid)) +banner = "backend=%s debug_layer=enabled\nadapter=Fake\n" % adapter +if args and args[0] == "--serve": + if mode == "no-serve": + sys.stderr.write("Unknown GPU operation or invalid arguments: --serve\n") + sys.exit(2) + if mode == "no-adapter": + print("No D3D12-capable hardware adapter visible") + sys.exit(77) + sys.stdout.write(banner) + sys.stderr.write("XBOX2WINDOWS_ADAPTER: skipping Other\n") + sys.stderr.write("X2WEND -1\n") + print("X2WCASE -1 0", flush=True) + for index, line in enumerate(sys.stdin): + if line == "--end\n": + sys.exit(0) + out, err, code = one(line.rstrip("\n").split("\t")) + if mode == "die-at-%d" % index: + os._exit(3) + if mode == "hang-at-%d" % index: + import time + time.sleep(60) + if mode == "skew-at-%d" % index: + sys.stderr.write("X2WEND %d\n" % (index + 5)) + print("X2WCASE %d 0" % index, flush=True) + continue + sys.stdout.write(out) + sys.stderr.write(err) + sys.stderr.write("X2WEND %d\n" % index) + print("X2WCASE %d %d" % (index, code), flush=True) + sys.exit(0) +out, err, code = one(args) +sys.stdout.write("ONESHOT " + banner + out) +sys.stderr.write(err) +sys.exit(code) +''' + + +def launcher(directory, name, mode): + """The renderer as an interpreter plus script, a direct child of the runner: killing it releases its pipes at once (a + .cmd or shell launcher in between would leave a sleeping grandchild holding them).""" + fake = directory / 'fake_offscreen.py' + fake.write_text(FAKE) + return [sys.executable, str(fake), '--mode=' + mode] + + +class RunnerChecks(unittest.TestCase): + def setUp(self): + R._servers.clear() + self.addCleanup(R._servers.clear) + self.addCleanup(R._close_all) # runs first: the servers of the test are closed before the table is emptied + self.tmp = tempfile.TemporaryDirectory() + self.addCleanup(self.tmp.cleanup) + self.dir = Path(self.tmp.name) + + def run_case(self, renderer, *args): + return R.run(renderer, 'warp', args) + + def test_served_cases_carry_their_own_text_and_exit_code(self): + renderer = launcher(self.dir, 'fake', 'serve') + first = self.run_case(renderer, '--pass', 'a') + second = self.run_case(renderer, '--mismatch', 'b') + third = self.run_case(renderer, '--pass', 'c') + self.assertEqual((first.returncode, second.returncode, third.returncode), (0, 1, 0)) + self.assertEqual(first.stdout, 'backend=warp debug_layer=enabled\nadapter=Fake\nok a\ndebug_errors=0 debug_warnings=0\n') + self.assertEqual(first.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\n') + self.assertEqual(second.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\nstartup_flat_param mismatch b\n') + self.assertEqual(third.stdout, 'backend=warp debug_layer=enabled\nadapter=Fake\nok c\ndebug_errors=0 debug_warnings=0\n') # banner on every case + self.assertEqual(third.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\n') + self.assertEqual(self.run_case(renderer, '--bogus').returncode, 2) + + def test_skip_and_missing_adapter_keep_their_exit_code(self): + self.assertEqual(self.run_case(launcher(self.dir, 'skip', 'serve'), '--skip').returncode, 77) + none = self.run_case(launcher(self.dir, 'none', 'no-adapter'), '--pass', 'x') + self.assertEqual(none.returncode, 77) + self.assertIn('No D3D12-capable hardware adapter visible', none.stdout) + + def test_a_renderer_without_serve_falls_back_to_one_shot_calls(self): + renderer = launcher(self.dir, 'old', 'no-serve') + result = self.run_case(renderer, '--mismatch', 'z') + self.assertEqual(result.returncode, 1) + self.assertTrue(result.stdout.startswith('ONESHOT ')) + self.assertEqual(self.run_case(renderer, '--pass', 'q').returncode, 0) + + def executed(self): + log = self.dir / 'cases.log' + return log.read_text().splitlines() if log.exists() else [] + + def test_a_crash_after_the_handshake_is_a_failed_verdict_and_the_case_is_not_run_again(self): + renderer = launcher(self.dir, 'dies', 'die-at-1') + self.assertEqual(self.run_case(renderer, '--pass', 'a').returncode, 0) + lost = self.run_case(renderer, '--pass', 'b') # the renderer dies on this case, which would pass if re-run + self.assertEqual(lost.returncode, 1) + self.assertIn('exited (code 3)', lost.stderr) + self.assertEqual(self.executed(), ['--pass a', '--pass b']) # fake logs the case before dying; never a second time + self.assertEqual(self.run_case(renderer, '--pass', 'c').returncode, 0) # the next case gets a new server + + def test_a_silent_renderer_fails_the_case_after_one_deadline(self): + renderer = launcher(self.dir, 'hangs', 'hang-at-0') + self.addCleanup(setattr, R, 'CASE_TIMEOUT_S', R.CASE_TIMEOUT_S) + R.CASE_TIMEOUT_S = 2 + started = time.monotonic() + lost = self.run_case(renderer, '--pass', 'a') + self.assertEqual(lost.returncode, 1) + self.assertIn('timed out after 2 s', lost.stderr) + self.assertLess(time.monotonic() - started, 4) # one deadline for both streams, not one each + + def test_a_reply_with_the_wrong_case_number_fails_the_case(self): + lost = self.run_case(launcher(self.dir, 'skew', 'skew-at-1'), '--pass', 'a') + self.assertEqual(lost.returncode, 0) + lost = self.run_case(launcher(self.dir, 'skew', 'skew-at-1'), '--pass', 'b') + self.assertEqual(lost.returncode, 1) + self.assertIn('answered case', lost.stderr) + + def test_a_debug_warning_of_a_later_case_is_visible_to_the_check(self): + renderer = launcher(self.dir, 'fake', 'serve') + self.run_case(renderer, '--pass', 'a') + later = self.run_case(renderer, '--warn', 'b') + self.assertIn('debug_layer=enabled', later.stdout) # the check looks for the status in every case + self.assertIn('debug_errors=0 debug_warnings=1', later.stdout) + + def test_every_exit_leaves_no_process_and_no_open_pipe(self): + made = [] + real = R._Server + + def record(*args): + made.append(real(*args)) + return made[-1] + + with unittest.mock.patch.object(R, '_Server', record): + self.run_case(launcher(self.dir, 'old', 'no-serve'), '--pass', 'a') # failed handshake, then the one-shot call + self.run_case(launcher(self.dir, 'none', 'no-adapter'), '--pass', 'a') # skip 77 at the handshake + dies = launcher(self.dir, 'dies', 'die-at-1') + self.run_case(dies, '--pass', 'a') + self.run_case(dies, '--mismatch', 'b') # dead server: failed verdict + self.run_case(dies, '--pass', 'c') # next case, new server + R._close_all() # that server, at exit + self.assertEqual(len(made), 4) + for server in made: + self.assertIsNotNone(server.proc.poll()) + self.assertTrue(all(s.closed for s in (server.proc.stdin, server.proc.stdout, server.proc.stderr))) + + @unittest.skipUnless(os.name == 'posix', 'process groups') + def test_a_launcher_child_holding_the_pipes_does_not_block_the_end_of_the_test(self): + renderer = launcher(self.dir, 'grand', 'grandchild') + self.assertEqual(self.run_case(renderer, '--pass', 'a').returncode, 0) + pid = int((self.dir / 'grandchild.pid').read_text()) + started = time.monotonic() + R._close_all() # the renderer is gone but its child holds stdout and stderr + self.assertLess(time.monotonic() - started, 20) + for _ in range(50): # the child was killed with the group + try: + os.kill(pid, 0) + except ProcessLookupError: + break ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Distinguish terminated zombies from live launcher children** In a Linux container whose PID 1 does not reap orphaned children, `_close_all()` successfully kills the grandchild but its PID remains as a zombie. `os.kill(pid, 0)` still succeeds for that dead process, so this loop reaches `self.fail()` and the runner check rejects correct cleanup. This reproduces in the current container, where the child has state `Z`; all 10 tests pass under a reaping harness. Check whether the child is actually running or arrange for the fixture to reap it instead of requiring the PID to disappear. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-26 12:04:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:24Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6073796494 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#pullrequestreview-6073796494). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T12:02:24Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 12:04:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:28Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6073797350 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#pullrequestreview-6073797350). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T12:02:28Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 12:04:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:31Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6073797933 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#pullrequestreview-6073797933). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T12:02:31Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 12:04:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:24Z.

Code review location: tests/gpu_case_runner.py; line 179

@@ -0,0 +1,212 @@
+"""Shared by the GPU checks: one D3D12 device per test instead of one offscreen_check process per case (issue #448).
+
+run(renderer, adapter, args)
+    The same as subprocess.run([renderer, adapter, *args], capture_output=True, text=True), but the case goes to a long-lived
+    `offscreen_check <adapter> --serve` process of this test (one device for all its cases). The returned
+    subprocess.CompletedProcess has the one-shot meaning: returncode 0 pass, 1 failure, 77 skip, 2 bad arguments. Its stdout
+    and stderr are the text the one-shot call would print, adapter banner included for EVERY case (so a check that looks for
+    "debug_layer=enabled" and "debug_errors=0 debug_warnings=0" sees them in each case, as it does in a one-shot call).
+
+    Only a server that cannot start falls back to the one-shot call (an older offscreen_check without `--serve`, no adapter,
+    X2W_FLAT_SERVER=0): no case has been sent yet, so the one-shot call gives the verdict. Once a case has been sent, a
+    renderer that dies, hangs past CASE_TIMEOUT_S, or answers with the wrong case number gives a FAILED verdict (returncode 1,
+    the reason on stderr) for that case; it is never run again, so a crash cannot turn into a pass. The next case starts a
+    new server.
+"""
+import atexit
+import os
+import queue
+import signal
+import subprocess
+import threading
+import time
+
+CASE_TIMEOUT_S = 300
+SERVER_OFF = os.environ.get('X2W_FLAT_SERVER') == '0'
+DEVICE_REMOVED = 'device removed during case'
+_servers = {}
+
+
+def _command(renderer):
+    """The renderer as a command prefix: a path, or a list such as an interpreter plus its script (a launcher in between would
+    keep the pipes open after the renderer is killed)."""
+    return [str(part) for part in renderer] if isinstance(renderer, (list, tuple)) else [str(renderer)]
+
+
+class _Lost(Exception):
+    """The server did not answer the case it was sent."""
+
+
+class _Server:
+    def __init__(self, renderer, adapter):
+        self.out, self.err = queue.Queue(), queue.Queue()
+        self.proc = subprocess.Popen([*_command(renderer), adapter, '--serve'], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+                                     stderr=subprocess.PIPE, text=True, bufsize=1,
+                                     start_new_session=os.name == 'posix')   # own process group: a launcher's children die with it
+        self.banner, self.banner_err, self.ready, self.returncode, self.stderr_text = '', '', False, None, ''
+        self.next_case = 0
+        self.threads = [threading.Thread(target=self._pump, args=(self.proc.stdout, self.out, 'X2WCASE '), daemon=True),
+                        threading.Thread(target=self._pump, args=(self.proc.stderr, self.err, 'X2WEND '), daemon=True)]
+        for thread in self.threads:
+            thread.start()
+        deadline = time.monotonic() + CASE_TIMEOUT_S
+        first = self._get(self.out, deadline)        # the banner, closed by the marker pair of case -1
+        banner_err = self._get(self.err, deadline)
+        if first is None or first[1] != -1 or first[2] != 0 or banner_err is None or banner_err[1] != -1:
+            self.proc.kill()                         # closed first (skip 77, an unknown mode, a crash) or a hang
+            self.proc.wait()
+            self.returncode = self.proc.returncode
+            self.stderr_text = ''.join(self._drain(self.err))
+            self.banner = first[0] if first else ''
+            self._release()
+            return
+        self.banner, self.banner_err, self.ready = first[0], banner_err[0], True
+
+    @staticmethod
+    def _pump(stream, sink, marker):
+        """Split a stream into per-case chunks at its marker line "<marker><case index> [exit code]"."""
+        chunk = []
+        for line in stream:
+            parts = line.split()
+            if line.startswith(marker) and len(parts) == (3 if marker == 'X2WCASE ' else 2):
+                try:
+                    index = int(parts[1])
+                    code = int(parts[2]) if marker == 'X2WCASE ' else 0
+                except ValueError:
+                    chunk.append(line)
+                    continue
+                sink.put((''.join(chunk), index, code))
+                chunk = []
+            else:
+                chunk.append(line)
+        if chunk:
+            sink.put((''.join(chunk), None, None))
+        sink.put(None)
+
+    @staticmethod
+    def _get(q, deadline):
+        """The next (text, case index, exit code) of a stream, or None at its end or the deadline."""
+        try:
+            item = q.get(timeout=max(0.0, deadline - time.monotonic()))
+        except queue.Empty:
+            return None
+        return item                                 # None at the end of the stream; an unmarked tail has index None
+
+    @staticmethod
+    def _drain(q):
+        items = []
+        while True:
+            try:
+                item = q.get(timeout=2)
+            except queue.Empty:
+                return items
+            if item is None:
+                return items
+            items.append(item[0])
+
+    def case(self, args):
+        """Send one case; the reply must carry exactly this case's number on both streams, else _Lost."""
+        index, self.next_case = self.next_case, self.next_case + 1
+        deadline = time.monotonic() + CASE_TIMEOUT_S
+        try:
+            self.proc.stdin.write('\t'.join(args) + '\n')
+            self.proc.stdin.flush()
+        except OSError as error:
+            raise _Lost('could not send the case: %s' % error)
+        out, err = self._get(self.out, deadline), self._get(self.err, deadline)
+        if out is None or err is None or out[1] is None or err[1] is None:
+            try:                                    # a dying process closes its pipes a moment before it can be reaped
+                self.proc.wait(timeout=max(0.0, deadline - time.monotonic()))
+            except subprocess.TimeoutExpired:
+                pass
+            state = 'timed out after %d s' % CASE_TIMEOUT_S if self.proc.poll() is None else 'exited (code %s)' % self.proc.poll()
+            raise _Lost('the renderer %s during the case' % state)
+        if out[1] != index or err[1] != index:
+            raise _Lost('the renderer answered case %s/%s to case %d' % (out[1], err[1], index))
+        return subprocess.CompletedProcess(self.proc.args, out[2], self.banner + out[0], self.banner_err + err[0])
+
+    def _kill_tree(self):
+        """Kill the renderer and everything it started (a Wine or shell launcher leaves a child that keeps the pipes open)."""
+        try:
+            if os.name == 'posix':
+                os.killpg(self.proc.pid, signal.SIGKILL)
+            else:
+                subprocess.run(['taskkill', '/F', '/T', '/PID', str(self.proc.pid)], capture_output=True)
+        except OSError:
+            pass
+        self.proc.kill()
+
+    def _release(self):
+        """Wait for the process, end its group, join the pump threads and close the pipes, so nothing is left behind."""
+        self.proc.wait()
+        self._kill_tree()
+        for thread in self.threads:                 # the pumps end at the end of the pipes
+            thread.join(timeout=5)
+        for stream, thread in ((self.proc.stdin, None), (self.proc.stdout, self.threads[0]), (self.proc.stderr, self.threads[1])):
+            if thread is None or not thread.is_alive():     # closing a pipe a pump is still reading would block
+                try:
+                    stream.close()
+                except (OSError, ValueError):
+                    pass
+
+    def kill(self):
+        self._kill_tree()
+        self._release()
+
+    def close(self):
+        try:
+            self.proc.stdin.write('--end\n')       # explicit: a launcher in between may not pass the end of stdin on
+            self.proc.stdin.close()
+            self.proc.wait(timeout=30)
+        except (OSError, ValueError, subprocess.TimeoutExpired):     # already closed, or it does not end
+            self._kill_tree()
+        self._release()
+
+
+def _close_all():
+    for server in _servers.values():
+        if server:
+            server.close()
+
+
+atexit.register(_close_all)
+
+
+def _failed(server, reason):
+    """The FAILED verdict of a case whose server did not answer it."""
+    text = ''.join(server._drain(server.err)) if server.proc.poll() is not None else ''
+    server.kill()
+    return subprocess.CompletedProcess(server.proc.args, 1, '', 'gpu_case_runner: %s\n%s' % (reason, text))

Fixed in f01ff5b6c (head 619ae700 after merging main): a lost case now returns the adapter banner, what the renderer printed for the case before it was lost, and everything still queued after the process group is killed. New test test_a_crash_keeps_the_diagnostics_and_the_banner, and the silent-renderer test checks the same; both failed before the change. Ran tests/gpu_case_runner_check.py: 11/11 OK.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4708075531 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#discussion_r4708075531). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T12:02:24Z. **Code review location:** `tests/gpu_case_runner.py`; line 179 ~~~~diff @@ -0,0 +1,212 @@ +"""Shared by the GPU checks: one D3D12 device per test instead of one offscreen_check process per case (issue #448). + +run(renderer, adapter, args) + The same as subprocess.run([renderer, adapter, *args], capture_output=True, text=True), but the case goes to a long-lived + `offscreen_check <adapter> --serve` process of this test (one device for all its cases). The returned + subprocess.CompletedProcess has the one-shot meaning: returncode 0 pass, 1 failure, 77 skip, 2 bad arguments. Its stdout + and stderr are the text the one-shot call would print, adapter banner included for EVERY case (so a check that looks for + "debug_layer=enabled" and "debug_errors=0 debug_warnings=0" sees them in each case, as it does in a one-shot call). + + Only a server that cannot start falls back to the one-shot call (an older offscreen_check without `--serve`, no adapter, + X2W_FLAT_SERVER=0): no case has been sent yet, so the one-shot call gives the verdict. Once a case has been sent, a + renderer that dies, hangs past CASE_TIMEOUT_S, or answers with the wrong case number gives a FAILED verdict (returncode 1, + the reason on stderr) for that case; it is never run again, so a crash cannot turn into a pass. The next case starts a + new server. +""" +import atexit +import os +import queue +import signal +import subprocess +import threading +import time + +CASE_TIMEOUT_S = 300 +SERVER_OFF = os.environ.get('X2W_FLAT_SERVER') == '0' +DEVICE_REMOVED = 'device removed during case' +_servers = {} + + +def _command(renderer): + """The renderer as a command prefix: a path, or a list such as an interpreter plus its script (a launcher in between would + keep the pipes open after the renderer is killed).""" + return [str(part) for part in renderer] if isinstance(renderer, (list, tuple)) else [str(renderer)] + + +class _Lost(Exception): + """The server did not answer the case it was sent.""" + + +class _Server: + def __init__(self, renderer, adapter): + self.out, self.err = queue.Queue(), queue.Queue() + self.proc = subprocess.Popen([*_command(renderer), adapter, '--serve'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True, bufsize=1, + start_new_session=os.name == 'posix') # own process group: a launcher's children die with it + self.banner, self.banner_err, self.ready, self.returncode, self.stderr_text = '', '', False, None, '' + self.next_case = 0 + self.threads = [threading.Thread(target=self._pump, args=(self.proc.stdout, self.out, 'X2WCASE '), daemon=True), + threading.Thread(target=self._pump, args=(self.proc.stderr, self.err, 'X2WEND '), daemon=True)] + for thread in self.threads: + thread.start() + deadline = time.monotonic() + CASE_TIMEOUT_S + first = self._get(self.out, deadline) # the banner, closed by the marker pair of case -1 + banner_err = self._get(self.err, deadline) + if first is None or first[1] != -1 or first[2] != 0 or banner_err is None or banner_err[1] != -1: + self.proc.kill() # closed first (skip 77, an unknown mode, a crash) or a hang + self.proc.wait() + self.returncode = self.proc.returncode + self.stderr_text = ''.join(self._drain(self.err)) + self.banner = first[0] if first else '' + self._release() + return + self.banner, self.banner_err, self.ready = first[0], banner_err[0], True + + @staticmethod + def _pump(stream, sink, marker): + """Split a stream into per-case chunks at its marker line "<marker><case index> [exit code]".""" + chunk = [] + for line in stream: + parts = line.split() + if line.startswith(marker) and len(parts) == (3 if marker == 'X2WCASE ' else 2): + try: + index = int(parts[1]) + code = int(parts[2]) if marker == 'X2WCASE ' else 0 + except ValueError: + chunk.append(line) + continue + sink.put((''.join(chunk), index, code)) + chunk = [] + else: + chunk.append(line) + if chunk: + sink.put((''.join(chunk), None, None)) + sink.put(None) + + @staticmethod + def _get(q, deadline): + """The next (text, case index, exit code) of a stream, or None at its end or the deadline.""" + try: + item = q.get(timeout=max(0.0, deadline - time.monotonic())) + except queue.Empty: + return None + return item # None at the end of the stream; an unmarked tail has index None + + @staticmethod + def _drain(q): + items = [] + while True: + try: + item = q.get(timeout=2) + except queue.Empty: + return items + if item is None: + return items + items.append(item[0]) + + def case(self, args): + """Send one case; the reply must carry exactly this case's number on both streams, else _Lost.""" + index, self.next_case = self.next_case, self.next_case + 1 + deadline = time.monotonic() + CASE_TIMEOUT_S + try: + self.proc.stdin.write('\t'.join(args) + '\n') + self.proc.stdin.flush() + except OSError as error: + raise _Lost('could not send the case: %s' % error) + out, err = self._get(self.out, deadline), self._get(self.err, deadline) + if out is None or err is None or out[1] is None or err[1] is None: + try: # a dying process closes its pipes a moment before it can be reaped + self.proc.wait(timeout=max(0.0, deadline - time.monotonic())) + except subprocess.TimeoutExpired: + pass + state = 'timed out after %d s' % CASE_TIMEOUT_S if self.proc.poll() is None else 'exited (code %s)' % self.proc.poll() + raise _Lost('the renderer %s during the case' % state) + if out[1] != index or err[1] != index: + raise _Lost('the renderer answered case %s/%s to case %d' % (out[1], err[1], index)) + return subprocess.CompletedProcess(self.proc.args, out[2], self.banner + out[0], self.banner_err + err[0]) + + def _kill_tree(self): + """Kill the renderer and everything it started (a Wine or shell launcher leaves a child that keeps the pipes open).""" + try: + if os.name == 'posix': + os.killpg(self.proc.pid, signal.SIGKILL) + else: + subprocess.run(['taskkill', '/F', '/T', '/PID', str(self.proc.pid)], capture_output=True) + except OSError: + pass + self.proc.kill() + + def _release(self): + """Wait for the process, end its group, join the pump threads and close the pipes, so nothing is left behind.""" + self.proc.wait() + self._kill_tree() + for thread in self.threads: # the pumps end at the end of the pipes + thread.join(timeout=5) + for stream, thread in ((self.proc.stdin, None), (self.proc.stdout, self.threads[0]), (self.proc.stderr, self.threads[1])): + if thread is None or not thread.is_alive(): # closing a pipe a pump is still reading would block + try: + stream.close() + except (OSError, ValueError): + pass + + def kill(self): + self._kill_tree() + self._release() + + def close(self): + try: + self.proc.stdin.write('--end\n') # explicit: a launcher in between may not pass the end of stdin on + self.proc.stdin.close() + self.proc.wait(timeout=30) + except (OSError, ValueError, subprocess.TimeoutExpired): # already closed, or it does not end + self._kill_tree() + self._release() + + +def _close_all(): + for server in _servers.values(): + if server: + server.close() + + +atexit.register(_close_all) + + +def _failed(server, reason): + """The FAILED verdict of a case whose server did not answer it.""" + text = ''.join(server._drain(server.err)) if server.proc.poll() is not None else '' + server.kill() + return subprocess.CompletedProcess(server.proc.args, 1, '', 'gpu_case_runner: %s\n%s' % (reason, text)) ~~~~ --- Fixed in f01ff5b6c (head 619ae700 after merging main): a lost case now returns the adapter banner, what the renderer printed for the case before it was lost, and everything still queued after the process group is killed. New test test_a_crash_keeps_the_diagnostics_and_the_banner, and the silent-renderer test checks the same; both failed before the change. Ran tests/gpu_case_runner_check.py: 11/11 OK. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 12:04:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:28Z.

Code review location: tests/gpu_case_runner_check.py; line 93

@@ -0,0 +1,210 @@
+"""tests/gpu_case_runner.py: the served cases answer like one-shot calls, and every failure of the server falls back to one.
+
+The renderer here is a fake offscreen_check (a Python script behind a one-line launcher) that speaks the `--serve` protocol of
+tests/offscreen_check.cpp: a banner closed by the marker pair of case -1, then per case the case text, "X2WEND <i>" on stderr and
+"X2WCASE <i> <exit code>" on stdout. Its one-shot mode prints the same text, so the two paths can be compared.
+"""
+import os
+import subprocess
+import sys
+import tempfile
+import time
+import unittest
+import unittest.mock
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+import gpu_case_runner as R  # noqa: E402
+
+FAKE = r'''
+import os, sys
+mode = sys.argv[1].split("=", 1)[1]
+adapter, args = sys.argv[2], sys.argv[3:]
+
+def one(args):
+    """The text and exit code of one case, as the real tool prints them."""
+    op = args[0]
+    with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cases.log"), "a") as log:
+        log.write(" ".join(args) + "\n")
+    if op == "--pass":
+        return "ok %s\ndebug_errors=0 debug_warnings=0\n" % args[1], "", 0
+    if op == "--warn":
+        return "ok %s\ndebug_errors=0 debug_warnings=1\n" % args[1], "", 0
+    if op == "--mismatch":
+        return "", "startup_flat_param mismatch %s\n" % args[1], 1
+    if op == "--skip":
+        return "skip: nothing\n", "", 77
+    return "", "Unknown GPU operation or invalid arguments: %s\n" % op, 2
+
+if mode == "grandchild":          # a launcher child that keeps the pipes open after the renderer is gone
+    import subprocess
+    child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(120)"])
+    with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "grandchild.pid"), "w") as pid_file:
+        pid_file.write(str(child.pid))
+banner = "backend=%s debug_layer=enabled\nadapter=Fake\n" % adapter
+if args and args[0] == "--serve":
+    if mode == "no-serve":
+        sys.stderr.write("Unknown GPU operation or invalid arguments: --serve\n")
+        sys.exit(2)
+    if mode == "no-adapter":
+        print("No D3D12-capable hardware adapter visible")
+        sys.exit(77)
+    sys.stdout.write(banner)
+    sys.stderr.write("XBOX2WINDOWS_ADAPTER: skipping Other\n")
+    sys.stderr.write("X2WEND -1\n")
+    print("X2WCASE -1 0", flush=True)
+    for index, line in enumerate(sys.stdin):
+        if line == "--end\n":
+            sys.exit(0)
+        out, err, code = one(line.rstrip("\n").split("\t"))
+        if mode == "die-at-%d" % index:
+            os._exit(3)
+        if mode == "hang-at-%d" % index:
+            import time
+            time.sleep(60)
+        if mode == "skew-at-%d" % index:
+            sys.stderr.write("X2WEND %d\n" % (index + 5))
+            print("X2WCASE %d 0" % index, flush=True)
+            continue
+        sys.stdout.write(out)
+        sys.stderr.write(err)
+        sys.stderr.write("X2WEND %d\n" % index)
+        print("X2WCASE %d %d" % (index, code), flush=True)
+    sys.exit(0)
+out, err, code = one(args)
+sys.stdout.write("ONESHOT " + banner + out)
+sys.stderr.write(err)
+sys.exit(code)
+'''
+
+
+def launcher(directory, name, mode):
+    """The renderer as an interpreter plus script, a direct child of the runner: killing it releases its pipes at once (a
+    .cmd or shell launcher in between would leave a sleeping grandchild holding them)."""
+    fake = directory / 'fake_offscreen.py'
+    fake.write_text(FAKE)
+    return [sys.executable, str(fake), '--mode=' + mode]
+
+
+class RunnerChecks(unittest.TestCase):
+    def setUp(self):
+        R._servers.clear()
+        self.addCleanup(R._servers.clear)
+        self.addCleanup(R._close_all)          # runs first: the servers of the test are closed before the table is emptied

Fixed in f01ff5b6c: the fixture patches R.SERVER_OFF to False for every test and restores it; the opt-out test patches it to True. Ran tests/gpu_case_runner_check.py with X2W_FLAT_SERVER=0 in the environment: 11/11 OK (6 failures before the change).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4708076120 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#discussion_r4708076120). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T12:02:28Z. **Code review location:** `tests/gpu_case_runner_check.py`; line 93 ~~~~diff @@ -0,0 +1,210 @@ +"""tests/gpu_case_runner.py: the served cases answer like one-shot calls, and every failure of the server falls back to one. + +The renderer here is a fake offscreen_check (a Python script behind a one-line launcher) that speaks the `--serve` protocol of +tests/offscreen_check.cpp: a banner closed by the marker pair of case -1, then per case the case text, "X2WEND <i>" on stderr and +"X2WCASE <i> <exit code>" on stdout. Its one-shot mode prints the same text, so the two paths can be compared. +""" +import os +import subprocess +import sys +import tempfile +import time +import unittest +import unittest.mock +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import gpu_case_runner as R # noqa: E402 + +FAKE = r''' +import os, sys +mode = sys.argv[1].split("=", 1)[1] +adapter, args = sys.argv[2], sys.argv[3:] + +def one(args): + """The text and exit code of one case, as the real tool prints them.""" + op = args[0] + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cases.log"), "a") as log: + log.write(" ".join(args) + "\n") + if op == "--pass": + return "ok %s\ndebug_errors=0 debug_warnings=0\n" % args[1], "", 0 + if op == "--warn": + return "ok %s\ndebug_errors=0 debug_warnings=1\n" % args[1], "", 0 + if op == "--mismatch": + return "", "startup_flat_param mismatch %s\n" % args[1], 1 + if op == "--skip": + return "skip: nothing\n", "", 77 + return "", "Unknown GPU operation or invalid arguments: %s\n" % op, 2 + +if mode == "grandchild": # a launcher child that keeps the pipes open after the renderer is gone + import subprocess + child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(120)"]) + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "grandchild.pid"), "w") as pid_file: + pid_file.write(str(child.pid)) +banner = "backend=%s debug_layer=enabled\nadapter=Fake\n" % adapter +if args and args[0] == "--serve": + if mode == "no-serve": + sys.stderr.write("Unknown GPU operation or invalid arguments: --serve\n") + sys.exit(2) + if mode == "no-adapter": + print("No D3D12-capable hardware adapter visible") + sys.exit(77) + sys.stdout.write(banner) + sys.stderr.write("XBOX2WINDOWS_ADAPTER: skipping Other\n") + sys.stderr.write("X2WEND -1\n") + print("X2WCASE -1 0", flush=True) + for index, line in enumerate(sys.stdin): + if line == "--end\n": + sys.exit(0) + out, err, code = one(line.rstrip("\n").split("\t")) + if mode == "die-at-%d" % index: + os._exit(3) + if mode == "hang-at-%d" % index: + import time + time.sleep(60) + if mode == "skew-at-%d" % index: + sys.stderr.write("X2WEND %d\n" % (index + 5)) + print("X2WCASE %d 0" % index, flush=True) + continue + sys.stdout.write(out) + sys.stderr.write(err) + sys.stderr.write("X2WEND %d\n" % index) + print("X2WCASE %d %d" % (index, code), flush=True) + sys.exit(0) +out, err, code = one(args) +sys.stdout.write("ONESHOT " + banner + out) +sys.stderr.write(err) +sys.exit(code) +''' + + +def launcher(directory, name, mode): + """The renderer as an interpreter plus script, a direct child of the runner: killing it releases its pipes at once (a + .cmd or shell launcher in between would leave a sleeping grandchild holding them).""" + fake = directory / 'fake_offscreen.py' + fake.write_text(FAKE) + return [sys.executable, str(fake), '--mode=' + mode] + + +class RunnerChecks(unittest.TestCase): + def setUp(self): + R._servers.clear() + self.addCleanup(R._servers.clear) + self.addCleanup(R._close_all) # runs first: the servers of the test are closed before the table is emptied ~~~~ --- Fixed in f01ff5b6c: the fixture patches R.SERVER_OFF to False for every test and restores it; the opt-out test patches it to True. Ran tests/gpu_case_runner_check.py with X2W_FLAT_SERVER=0 in the environment: 11/11 OK (6 failures before the change). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 12:04:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T12:02:31Z.

Code review location: tests/gpu_case_runner_check.py; line 197

@@ -0,0 +1,210 @@
+"""tests/gpu_case_runner.py: the served cases answer like one-shot calls, and every failure of the server falls back to one.
+
+The renderer here is a fake offscreen_check (a Python script behind a one-line launcher) that speaks the `--serve` protocol of
+tests/offscreen_check.cpp: a banner closed by the marker pair of case -1, then per case the case text, "X2WEND <i>" on stderr and
+"X2WCASE <i> <exit code>" on stdout. Its one-shot mode prints the same text, so the two paths can be compared.
+"""
+import os
+import subprocess
+import sys
+import tempfile
+import time
+import unittest
+import unittest.mock
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+import gpu_case_runner as R  # noqa: E402
+
+FAKE = r'''
+import os, sys
+mode = sys.argv[1].split("=", 1)[1]
+adapter, args = sys.argv[2], sys.argv[3:]
+
+def one(args):
+    """The text and exit code of one case, as the real tool prints them."""
+    op = args[0]
+    with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cases.log"), "a") as log:
+        log.write(" ".join(args) + "\n")
+    if op == "--pass":
+        return "ok %s\ndebug_errors=0 debug_warnings=0\n" % args[1], "", 0
+    if op == "--warn":
+        return "ok %s\ndebug_errors=0 debug_warnings=1\n" % args[1], "", 0
+    if op == "--mismatch":
+        return "", "startup_flat_param mismatch %s\n" % args[1], 1
+    if op == "--skip":
+        return "skip: nothing\n", "", 77
+    return "", "Unknown GPU operation or invalid arguments: %s\n" % op, 2
+
+if mode == "grandchild":          # a launcher child that keeps the pipes open after the renderer is gone
+    import subprocess
+    child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(120)"])
+    with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "grandchild.pid"), "w") as pid_file:
+        pid_file.write(str(child.pid))
+banner = "backend=%s debug_layer=enabled\nadapter=Fake\n" % adapter
+if args and args[0] == "--serve":
+    if mode == "no-serve":
+        sys.stderr.write("Unknown GPU operation or invalid arguments: --serve\n")
+        sys.exit(2)
+    if mode == "no-adapter":
+        print("No D3D12-capable hardware adapter visible")
+        sys.exit(77)
+    sys.stdout.write(banner)
+    sys.stderr.write("XBOX2WINDOWS_ADAPTER: skipping Other\n")
+    sys.stderr.write("X2WEND -1\n")
+    print("X2WCASE -1 0", flush=True)
+    for index, line in enumerate(sys.stdin):
+        if line == "--end\n":
+            sys.exit(0)
+        out, err, code = one(line.rstrip("\n").split("\t"))
+        if mode == "die-at-%d" % index:
+            os._exit(3)
+        if mode == "hang-at-%d" % index:
+            import time
+            time.sleep(60)
+        if mode == "skew-at-%d" % index:
+            sys.stderr.write("X2WEND %d\n" % (index + 5))
+            print("X2WCASE %d 0" % index, flush=True)
+            continue
+        sys.stdout.write(out)
+        sys.stderr.write(err)
+        sys.stderr.write("X2WEND %d\n" % index)
+        print("X2WCASE %d %d" % (index, code), flush=True)
+    sys.exit(0)
+out, err, code = one(args)
+sys.stdout.write("ONESHOT " + banner + out)
+sys.stderr.write(err)
+sys.exit(code)
+'''
+
+
+def launcher(directory, name, mode):
+    """The renderer as an interpreter plus script, a direct child of the runner: killing it releases its pipes at once (a
+    .cmd or shell launcher in between would leave a sleeping grandchild holding them)."""
+    fake = directory / 'fake_offscreen.py'
+    fake.write_text(FAKE)
+    return [sys.executable, str(fake), '--mode=' + mode]
+
+
+class RunnerChecks(unittest.TestCase):
+    def setUp(self):
+        R._servers.clear()
+        self.addCleanup(R._servers.clear)
+        self.addCleanup(R._close_all)          # runs first: the servers of the test are closed before the table is emptied
+        self.tmp = tempfile.TemporaryDirectory()
+        self.addCleanup(self.tmp.cleanup)
+        self.dir = Path(self.tmp.name)
+
+    def run_case(self, renderer, *args):
+        return R.run(renderer, 'warp', args)
+
+    def test_served_cases_carry_their_own_text_and_exit_code(self):
+        renderer = launcher(self.dir, 'fake', 'serve')
+        first = self.run_case(renderer, '--pass', 'a')
+        second = self.run_case(renderer, '--mismatch', 'b')
+        third = self.run_case(renderer, '--pass', 'c')
+        self.assertEqual((first.returncode, second.returncode, third.returncode), (0, 1, 0))
+        self.assertEqual(first.stdout, 'backend=warp debug_layer=enabled\nadapter=Fake\nok a\ndebug_errors=0 debug_warnings=0\n')
+        self.assertEqual(first.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\n')
+        self.assertEqual(second.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\nstartup_flat_param mismatch b\n')
+        self.assertEqual(third.stdout, 'backend=warp debug_layer=enabled\nadapter=Fake\nok c\ndebug_errors=0 debug_warnings=0\n')  # banner on every case
+        self.assertEqual(third.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\n')
+        self.assertEqual(self.run_case(renderer, '--bogus').returncode, 2)
+
+    def test_skip_and_missing_adapter_keep_their_exit_code(self):
+        self.assertEqual(self.run_case(launcher(self.dir, 'skip', 'serve'), '--skip').returncode, 77)
+        none = self.run_case(launcher(self.dir, 'none', 'no-adapter'), '--pass', 'x')
+        self.assertEqual(none.returncode, 77)
+        self.assertIn('No D3D12-capable hardware adapter visible', none.stdout)
+
+    def test_a_renderer_without_serve_falls_back_to_one_shot_calls(self):
+        renderer = launcher(self.dir, 'old', 'no-serve')
+        result = self.run_case(renderer, '--mismatch', 'z')
+        self.assertEqual(result.returncode, 1)
+        self.assertTrue(result.stdout.startswith('ONESHOT '))
+        self.assertEqual(self.run_case(renderer, '--pass', 'q').returncode, 0)
+
+    def executed(self):
+        log = self.dir / 'cases.log'
+        return log.read_text().splitlines() if log.exists() else []
+
+    def test_a_crash_after_the_handshake_is_a_failed_verdict_and_the_case_is_not_run_again(self):
+        renderer = launcher(self.dir, 'dies', 'die-at-1')
+        self.assertEqual(self.run_case(renderer, '--pass', 'a').returncode, 0)
+        lost = self.run_case(renderer, '--pass', 'b')                 # the renderer dies on this case, which would pass if re-run
+        self.assertEqual(lost.returncode, 1)
+        self.assertIn('exited (code 3)', lost.stderr)
+        self.assertEqual(self.executed(), ['--pass a', '--pass b'])  # fake logs the case before dying; never a second time
+        self.assertEqual(self.run_case(renderer, '--pass', 'c').returncode, 0)     # the next case gets a new server
+
+    def test_a_silent_renderer_fails_the_case_after_one_deadline(self):
+        renderer = launcher(self.dir, 'hangs', 'hang-at-0')
+        self.addCleanup(setattr, R, 'CASE_TIMEOUT_S', R.CASE_TIMEOUT_S)
+        R.CASE_TIMEOUT_S = 2
+        started = time.monotonic()
+        lost = self.run_case(renderer, '--pass', 'a')
+        self.assertEqual(lost.returncode, 1)
+        self.assertIn('timed out after 2 s', lost.stderr)
+        self.assertLess(time.monotonic() - started, 4)               # one deadline for both streams, not one each
+
+    def test_a_reply_with_the_wrong_case_number_fails_the_case(self):
+        lost = self.run_case(launcher(self.dir, 'skew', 'skew-at-1'), '--pass', 'a')
+        self.assertEqual(lost.returncode, 0)
+        lost = self.run_case(launcher(self.dir, 'skew', 'skew-at-1'), '--pass', 'b')
+        self.assertEqual(lost.returncode, 1)
+        self.assertIn('answered case', lost.stderr)
+
+    def test_a_debug_warning_of_a_later_case_is_visible_to_the_check(self):
+        renderer = launcher(self.dir, 'fake', 'serve')
+        self.run_case(renderer, '--pass', 'a')
+        later = self.run_case(renderer, '--warn', 'b')
+        self.assertIn('debug_layer=enabled', later.stdout)           # the check looks for the status in every case
+        self.assertIn('debug_errors=0 debug_warnings=1', later.stdout)
+
+    def test_every_exit_leaves_no_process_and_no_open_pipe(self):
+        made = []
+        real = R._Server
+
+        def record(*args):
+            made.append(real(*args))
+            return made[-1]
+
+        with unittest.mock.patch.object(R, '_Server', record):
+            self.run_case(launcher(self.dir, 'old', 'no-serve'), '--pass', 'a')      # failed handshake, then the one-shot call
+            self.run_case(launcher(self.dir, 'none', 'no-adapter'), '--pass', 'a')   # skip 77 at the handshake
+            dies = launcher(self.dir, 'dies', 'die-at-1')
+            self.run_case(dies, '--pass', 'a')
+            self.run_case(dies, '--mismatch', 'b')                                   # dead server: failed verdict
+            self.run_case(dies, '--pass', 'c')                                       # next case, new server
+            R._close_all()                                                           # that server, at exit
+        self.assertEqual(len(made), 4)
+        for server in made:
+            self.assertIsNotNone(server.proc.poll())
+            self.assertTrue(all(s.closed for s in (server.proc.stdin, server.proc.stdout, server.proc.stderr)))
+
+    @unittest.skipUnless(os.name == 'posix', 'process groups')
+    def test_a_launcher_child_holding_the_pipes_does_not_block_the_end_of_the_test(self):
+        renderer = launcher(self.dir, 'grand', 'grandchild')
+        self.assertEqual(self.run_case(renderer, '--pass', 'a').returncode, 0)
+        pid = int((self.dir / 'grandchild.pid').read_text())
+        started = time.monotonic()
+        R._close_all()                                               # the renderer is gone but its child holds stdout and stderr
+        self.assertLess(time.monotonic() - started, 20)
+        for _ in range(50):                                          # the child was killed with the group
+            try:
+                os.kill(pid, 0)
+            except ProcessLookupError:
+                break

Fixed in f01ff5b6c: the check treats a killed child that nobody reaped (state Z in /proc) as gone, so it no longer depends on PID 1 reaping orphans. Ran tests/gpu_case_runner_check.py: 11/11 OK.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4708076601 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#discussion_r4708076601). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T12:02:31Z. **Code review location:** `tests/gpu_case_runner_check.py`; line 197 ~~~~diff @@ -0,0 +1,210 @@ +"""tests/gpu_case_runner.py: the served cases answer like one-shot calls, and every failure of the server falls back to one. + +The renderer here is a fake offscreen_check (a Python script behind a one-line launcher) that speaks the `--serve` protocol of +tests/offscreen_check.cpp: a banner closed by the marker pair of case -1, then per case the case text, "X2WEND <i>" on stderr and +"X2WCASE <i> <exit code>" on stdout. Its one-shot mode prints the same text, so the two paths can be compared. +""" +import os +import subprocess +import sys +import tempfile +import time +import unittest +import unittest.mock +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import gpu_case_runner as R # noqa: E402 + +FAKE = r''' +import os, sys +mode = sys.argv[1].split("=", 1)[1] +adapter, args = sys.argv[2], sys.argv[3:] + +def one(args): + """The text and exit code of one case, as the real tool prints them.""" + op = args[0] + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cases.log"), "a") as log: + log.write(" ".join(args) + "\n") + if op == "--pass": + return "ok %s\ndebug_errors=0 debug_warnings=0\n" % args[1], "", 0 + if op == "--warn": + return "ok %s\ndebug_errors=0 debug_warnings=1\n" % args[1], "", 0 + if op == "--mismatch": + return "", "startup_flat_param mismatch %s\n" % args[1], 1 + if op == "--skip": + return "skip: nothing\n", "", 77 + return "", "Unknown GPU operation or invalid arguments: %s\n" % op, 2 + +if mode == "grandchild": # a launcher child that keeps the pipes open after the renderer is gone + import subprocess + child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(120)"]) + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "grandchild.pid"), "w") as pid_file: + pid_file.write(str(child.pid)) +banner = "backend=%s debug_layer=enabled\nadapter=Fake\n" % adapter +if args and args[0] == "--serve": + if mode == "no-serve": + sys.stderr.write("Unknown GPU operation or invalid arguments: --serve\n") + sys.exit(2) + if mode == "no-adapter": + print("No D3D12-capable hardware adapter visible") + sys.exit(77) + sys.stdout.write(banner) + sys.stderr.write("XBOX2WINDOWS_ADAPTER: skipping Other\n") + sys.stderr.write("X2WEND -1\n") + print("X2WCASE -1 0", flush=True) + for index, line in enumerate(sys.stdin): + if line == "--end\n": + sys.exit(0) + out, err, code = one(line.rstrip("\n").split("\t")) + if mode == "die-at-%d" % index: + os._exit(3) + if mode == "hang-at-%d" % index: + import time + time.sleep(60) + if mode == "skew-at-%d" % index: + sys.stderr.write("X2WEND %d\n" % (index + 5)) + print("X2WCASE %d 0" % index, flush=True) + continue + sys.stdout.write(out) + sys.stderr.write(err) + sys.stderr.write("X2WEND %d\n" % index) + print("X2WCASE %d %d" % (index, code), flush=True) + sys.exit(0) +out, err, code = one(args) +sys.stdout.write("ONESHOT " + banner + out) +sys.stderr.write(err) +sys.exit(code) +''' + + +def launcher(directory, name, mode): + """The renderer as an interpreter plus script, a direct child of the runner: killing it releases its pipes at once (a + .cmd or shell launcher in between would leave a sleeping grandchild holding them).""" + fake = directory / 'fake_offscreen.py' + fake.write_text(FAKE) + return [sys.executable, str(fake), '--mode=' + mode] + + +class RunnerChecks(unittest.TestCase): + def setUp(self): + R._servers.clear() + self.addCleanup(R._servers.clear) + self.addCleanup(R._close_all) # runs first: the servers of the test are closed before the table is emptied + self.tmp = tempfile.TemporaryDirectory() + self.addCleanup(self.tmp.cleanup) + self.dir = Path(self.tmp.name) + + def run_case(self, renderer, *args): + return R.run(renderer, 'warp', args) + + def test_served_cases_carry_their_own_text_and_exit_code(self): + renderer = launcher(self.dir, 'fake', 'serve') + first = self.run_case(renderer, '--pass', 'a') + second = self.run_case(renderer, '--mismatch', 'b') + third = self.run_case(renderer, '--pass', 'c') + self.assertEqual((first.returncode, second.returncode, third.returncode), (0, 1, 0)) + self.assertEqual(first.stdout, 'backend=warp debug_layer=enabled\nadapter=Fake\nok a\ndebug_errors=0 debug_warnings=0\n') + self.assertEqual(first.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\n') + self.assertEqual(second.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\nstartup_flat_param mismatch b\n') + self.assertEqual(third.stdout, 'backend=warp debug_layer=enabled\nadapter=Fake\nok c\ndebug_errors=0 debug_warnings=0\n') # banner on every case + self.assertEqual(third.stderr, 'XBOX2WINDOWS_ADAPTER: skipping Other\n') + self.assertEqual(self.run_case(renderer, '--bogus').returncode, 2) + + def test_skip_and_missing_adapter_keep_their_exit_code(self): + self.assertEqual(self.run_case(launcher(self.dir, 'skip', 'serve'), '--skip').returncode, 77) + none = self.run_case(launcher(self.dir, 'none', 'no-adapter'), '--pass', 'x') + self.assertEqual(none.returncode, 77) + self.assertIn('No D3D12-capable hardware adapter visible', none.stdout) + + def test_a_renderer_without_serve_falls_back_to_one_shot_calls(self): + renderer = launcher(self.dir, 'old', 'no-serve') + result = self.run_case(renderer, '--mismatch', 'z') + self.assertEqual(result.returncode, 1) + self.assertTrue(result.stdout.startswith('ONESHOT ')) + self.assertEqual(self.run_case(renderer, '--pass', 'q').returncode, 0) + + def executed(self): + log = self.dir / 'cases.log' + return log.read_text().splitlines() if log.exists() else [] + + def test_a_crash_after_the_handshake_is_a_failed_verdict_and_the_case_is_not_run_again(self): + renderer = launcher(self.dir, 'dies', 'die-at-1') + self.assertEqual(self.run_case(renderer, '--pass', 'a').returncode, 0) + lost = self.run_case(renderer, '--pass', 'b') # the renderer dies on this case, which would pass if re-run + self.assertEqual(lost.returncode, 1) + self.assertIn('exited (code 3)', lost.stderr) + self.assertEqual(self.executed(), ['--pass a', '--pass b']) # fake logs the case before dying; never a second time + self.assertEqual(self.run_case(renderer, '--pass', 'c').returncode, 0) # the next case gets a new server + + def test_a_silent_renderer_fails_the_case_after_one_deadline(self): + renderer = launcher(self.dir, 'hangs', 'hang-at-0') + self.addCleanup(setattr, R, 'CASE_TIMEOUT_S', R.CASE_TIMEOUT_S) + R.CASE_TIMEOUT_S = 2 + started = time.monotonic() + lost = self.run_case(renderer, '--pass', 'a') + self.assertEqual(lost.returncode, 1) + self.assertIn('timed out after 2 s', lost.stderr) + self.assertLess(time.monotonic() - started, 4) # one deadline for both streams, not one each + + def test_a_reply_with_the_wrong_case_number_fails_the_case(self): + lost = self.run_case(launcher(self.dir, 'skew', 'skew-at-1'), '--pass', 'a') + self.assertEqual(lost.returncode, 0) + lost = self.run_case(launcher(self.dir, 'skew', 'skew-at-1'), '--pass', 'b') + self.assertEqual(lost.returncode, 1) + self.assertIn('answered case', lost.stderr) + + def test_a_debug_warning_of_a_later_case_is_visible_to_the_check(self): + renderer = launcher(self.dir, 'fake', 'serve') + self.run_case(renderer, '--pass', 'a') + later = self.run_case(renderer, '--warn', 'b') + self.assertIn('debug_layer=enabled', later.stdout) # the check looks for the status in every case + self.assertIn('debug_errors=0 debug_warnings=1', later.stdout) + + def test_every_exit_leaves_no_process_and_no_open_pipe(self): + made = [] + real = R._Server + + def record(*args): + made.append(real(*args)) + return made[-1] + + with unittest.mock.patch.object(R, '_Server', record): + self.run_case(launcher(self.dir, 'old', 'no-serve'), '--pass', 'a') # failed handshake, then the one-shot call + self.run_case(launcher(self.dir, 'none', 'no-adapter'), '--pass', 'a') # skip 77 at the handshake + dies = launcher(self.dir, 'dies', 'die-at-1') + self.run_case(dies, '--pass', 'a') + self.run_case(dies, '--mismatch', 'b') # dead server: failed verdict + self.run_case(dies, '--pass', 'c') # next case, new server + R._close_all() # that server, at exit + self.assertEqual(len(made), 4) + for server in made: + self.assertIsNotNone(server.proc.poll()) + self.assertTrue(all(s.closed for s in (server.proc.stdin, server.proc.stdout, server.proc.stderr))) + + @unittest.skipUnless(os.name == 'posix', 'process groups') + def test_a_launcher_child_holding_the_pipes_does_not_block_the_end_of_the_test(self): + renderer = launcher(self.dir, 'grand', 'grandchild') + self.assertEqual(self.run_case(renderer, '--pass', 'a').returncode, 0) + pid = int((self.dir / 'grandchild.pid').read_text()) + started = time.monotonic() + R._close_all() # the renderer is gone but its child holds stdout and stderr + self.assertLess(time.monotonic() - started, 20) + for _ in range(50): # the child was killed with the group + try: + os.kill(pid, 0) + except ProcessLookupError: + break ~~~~ --- Fixed in f01ff5b6c: the check treats a killed child that nobody reaped (state Z in /proc) as gone, so it no longer depends on PID 1 reaping orphans. Ran tests/gpu_case_runner_check.py: 11/11 OK. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 14:00:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:37:52Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 619ae7009534dcbfce40cfd60d309bfe2ac885fd:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target offscreen_check -- -j 2): 54.60s (configure 2.52s)
    • Test (ctest --preset dev -R '^gpu_case_runner$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (16.54s: gpu_case_runner 16.38s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target offscreen_check -- -j 2): 53.76s (configure 2.62s)
    • Test (ctest --preset release -R '^gpu_case_runner$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (15.27s: gpu_case_runner 15.06s)
  • Windows Python checks: tests/gpu_case_runner_check.py ok (14.9s), tests/startup_flat_param_check.py ok (0.2s), tests/startup_image_sample_b_check.py ok (0.3s), tests/startup_gfx2hlsl_f32_nan_check.py ok (5.5s)
  • sccache: 247/280 hits; wall 156.1s
    tested: 619ae700 via fetch (pull/2766/head, no patch)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7193617919 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#issuecomment-7193617919). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T13:37:52Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `619ae7009534dcbfce40cfd60d309bfe2ac885fd`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target offscreen_check -- -j 2`): `54.60s` (configure `2.52s`) - Test (`ctest --preset dev -R '^gpu_case_runner$' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`16.54s`: `gpu_case_runner` `16.38s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target offscreen_check -- -j 2`): `53.76s` (configure `2.62s`) - Test (`ctest --preset release -R '^gpu_case_runner$' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`15.27s`: `gpu_case_runner` `15.06s`) - **Windows Python checks**: `tests/gpu_case_runner_check.py` ok (`14.9s`), `tests/startup_flat_param_check.py` ok (`0.2s`), `tests/startup_image_sample_b_check.py` ok (`0.3s`), `tests/startup_gfx2hlsl_f32_nan_check.py` ok (`5.5s`) - `sccache`: 247/280 hits; wall `156.1s` tested: 619ae700 via fetch (pull/2766/head, no patch) AI-assisted; commands listed were executed locally.
pigalot commented 2026-11-27 18:18:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T18:18:54Z.

Review: APPROVED


Independently reviewed 619ae700 integrated over main 429f11d5 (tree a8658aad, clean merge).

What I traced. I read the --serve loop in tests/offscreen_check.cpp. Each case goes through resolve_cli and run_operation_spec on the existing device, the same path as a one-shot call. Stored debug messages are cleared after each case, and a removed device answers its case and then ends the loop.

On the client side (tests/gpu_case_runner.py):

  • a case that is lost, silent or answered with the wrong number gets returncode 1 and is never replayed;
  • arguments that contain a tab or newline fall back to the one-shot call.

What I ran. I built offscreen_check in dev and release. I then ran every CTest entry whose script imports gpu_case_runner or startup_flat_param_check, which is 305 tests: 122 _hardware, 122 _warp, plus the controls and Python checks. The non-hardware ones ran with -j 8 and the hardware ones with -j 1:
ctest --test-dir out/build/<preset> --no-tests=error -j 1 --output-on-failure -R '^(<the 122 _hardware names>)$'

  • Release /O2: 305/305 passed, no skips.
  • Debug: 304/305 passed, no skips. The one failure is startup_slot67_indirect_dispatch_{warp,hardware}. It launches startup_stream_consumer, which I had not built in that tree, through plain subprocess.run, and it does not use the runner. It only matched my name filter by prefix.
  • Debug layer: debug_layer=enabled appears in all 72 served cases of startup_image_sample_b_hardware, so the banner is repeated per case as described.

Runner check. python -B -W error::ResourceWarning tests/gpu_case_runner_check.py passed 3 of 3 runs: 11 tests, 8.5 s each. The one skip is the POSIX-only launcher-child test.

Mutant. I made a lost case return 0 in _failed. That fails four runner tests: crash after the handshake, crash keeps diagnostics, wrong case number, and silent renderer. On main 429f11d5, gpu_case_runner is not registered. git diff --check is clean.

Speed on a real card, Release, debug layer on, one run each:

test served X2W_FLAT_SERVER=0
startup_image_sample_b_hardware 4.7 s 19.2 s
startup_gfx2hlsl_f32_nan_hardware 9.5 s 48.6 s
startup_gfx2hlsl_f32_sdwa_hardware 12.8 s 70.9 s

Non-blocking finding. The server reads a case with fgets into a 64 KiB buffer, so a longer line is read as two cases. Both halves are answered with consecutive numbers, so the client's index check still matches, and every later verdict shifts by one case.

On WARP, through gpu_case_runner.run with out/build/dev/offscreen_check.exe, I sent six calls in order:

  1. --compute-root
  2. --compute-root <70,000-char arg>
  3. --compute-root
  4. --compute-root
  5. --bogus-op
  6. --compute-root

They returned 0, 2, 2, 0, 0, 2 where one-shot semantics give 0, 2, 0, 0, 2, 0. The invalid operation came back as a pass.

No current caller can reach this. Every adopted case was a one-shot command line, which Windows caps at 32,767 characters; a one-shot call of the 70,000-char case fails with WinError 206. But the served path now accepts lines that the one-shot path rejects, so a future caller could hit it silently. Either fix would close it: send lines of 64 KiB or more through the one-shot call, which fails loudly, or read whole lines on the server, for example with std::getline. This is not a reason to hold the PR.

Verdict: approve on 619ae700.

Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; debug layer on.
CI: Build and test on Windows passes on 619ae700. All review threads are resolved.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6092014897 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2766#pullrequestreview-6092014897). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T18:18:54Z. **Review:** APPROVED --- Independently reviewed `619ae700` integrated over `main` `429f11d5` (tree `a8658aad`, clean merge). **What I traced.** I read the `--serve` loop in `tests/offscreen_check.cpp`. Each case goes through `resolve_cli` and `run_operation_spec` on the existing device, the same path as a one-shot call. Stored debug messages are cleared after each case, and a removed device answers its case and then ends the loop. On the client side (`tests/gpu_case_runner.py`): - a case that is lost, silent or answered with the wrong number gets returncode 1 and is never replayed; - arguments that contain a tab or newline fall back to the one-shot call. **What I ran.** I built `offscreen_check` in `dev` and `release`. I then ran every CTest entry whose script imports `gpu_case_runner` or `startup_flat_param_check`, which is 305 tests: 122 `_hardware`, 122 `_warp`, plus the controls and Python checks. The non-hardware ones ran with `-j 8` and the hardware ones with `-j 1`: `ctest --test-dir out/build/<preset> --no-tests=error -j 1 --output-on-failure -R '^(<the 122 _hardware names>)$'` - **Release `/O2`:** 305/305 passed, no skips. - **Debug:** 304/305 passed, no skips. The one failure is `startup_slot67_indirect_dispatch_{warp,hardware}`. It launches `startup_stream_consumer`, which I had not built in that tree, through plain `subprocess.run`, and it does not use the runner. It only matched my name filter by prefix. - **Debug layer:** `debug_layer=enabled` appears in all 72 served cases of `startup_image_sample_b_hardware`, so the banner is repeated per case as described. **Runner check.** `python -B -W error::ResourceWarning tests/gpu_case_runner_check.py` passed 3 of 3 runs: 11 tests, 8.5 s each. The one skip is the POSIX-only launcher-child test. **Mutant.** I made a lost case return 0 in `_failed`. That fails four runner tests: crash after the handshake, crash keeps diagnostics, wrong case number, and silent renderer. On `main` `429f11d5`, `gpu_case_runner` is not registered. `git diff --check` is clean. **Speed on a real card, Release, debug layer on, one run each:** | test | served | `X2W_FLAT_SERVER=0` | |---|---|---| | `startup_image_sample_b_hardware` | 4.7 s | 19.2 s | | `startup_gfx2hlsl_f32_nan_hardware` | 9.5 s | 48.6 s | | `startup_gfx2hlsl_f32_sdwa_hardware` | 12.8 s | 70.9 s | **Non-blocking finding.** The server reads a case with `fgets` into a 64 KiB buffer, so a longer line is read as two cases. Both halves are answered with consecutive numbers, so the client's index check still matches, and every later verdict shifts by one case. On WARP, through `gpu_case_runner.run` with `out/build/dev/offscreen_check.exe`, I sent six calls in order: 1. `--compute-root` 2. `--compute-root <70,000-char arg>` 3. `--compute-root` 4. `--compute-root` 5. `--bogus-op` 6. `--compute-root` They returned `0, 2, 2, 0, 0, 2` where one-shot semantics give `0, 2, 0, 0, 2, 0`. The invalid operation came back as a pass. No current caller can reach this. Every adopted case was a one-shot command line, which Windows caps at 32,767 characters; a one-shot call of the 70,000-char case fails with `WinError 206`. But the served path now accepts lines that the one-shot path rejects, so a future caller could hit it silently. Either fix would close it: send lines of 64 KiB or more through the one-shot call, which fails loudly, or read whole lines on the server, for example with `std::getline`. This is not a reason to hold the PR. **Verdict:** approve on `619ae700`. Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; debug layer on. CI: `Build and test on Windows` passes on `619ae700`. All review threads are resolved. This reply was AI-assisted.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2758
No description provided.