shader: harden depth_mask_aot CLI error handling and add pure-Python tests #2101
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2108"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T00:32:09Z.
Change
Harden the CLI entry point and lowering error paths in
tools/depth_mask_aot.pyand add a pure-Python unit/CLI test suite (tests/depth_mask_aot_cli_check.py, registered inCMakeLists.txtasdepth_mask_aot_cli):main(argv=None) -> intaccept an explicitargvlist and return an exit status, usingparser.exit(1, ...)for operational errors (OSError,ValueError,struct.error,zlib.error) instead of printing raw Python tracebacks.--tablepairs are non-empty with non-negative SGPR and byte offset values, validate.hlsldestination suffix and distinct input/output resolved paths, and reject DXBC containers missing aDXILpart with an explicitValueError..tmpartifacts leak.v_fmac_f32_e32destination register lookups inlower()with an explicitValueError("Unwritten vector register")instead of raisingKeyError._e64lowering, mocked end-to-end CLI output generation, malformed DXBC containers, invalid CLI output paths/--tablevalues, missingDXIL/container I/O errors, unsupported instructions, and atomic temp-file cleanup on write failure.Verification
Commit:
a9da90ec(rebased ontoupstream/main5a0b0aad).out/pe-env/Scripts/python.exe -B tests/depth_mask_aot_cli_check.py -v-> exit0(Ran 7 tests in 0.758s,OK)out/pe-env/Scripts/python.exe -B tests/dxcontainer_part_offsets_check.py-> exit0out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py-> exit0(form coverage checks passed)out/pe-env/Scripts/python.exe -B tests/docs_links_check.py-> exit0(Checked 18 Markdown files and 395 links.)out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py-> exit0(Checked 1421 tracked source, script and build/CI files: no bidirectional controls.)v_fmac_f32_e32unwritten dest, missingDXIL, temp-file cleanup onOSError, negative/empty--table, non-.hlslsuffix, anddest == src) each causedtests/depth_mask_aot_cli_check.pyto fail (exit1).No capability skips (exit 77).
Evidence and follow-up
All DXBC/FSSM containers and decoded instruction streams in
tests/depth_mask_aot_cli_check.pyare synthetically constructed in Python within the test file under the repository MIT license. The pure-Python CLI suite mocks LLVM disassembly to exercise container parsing, CLI validation, lowering, and atomic output handling without requiringLLVM-C.dllor a GPU; end-to-end LLVM + D3D12 verification remains covered bytests/depth_mask_check.py.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:43:00Z.
Review: COMMENTED
Review of head
a9da90ec907a00326118a5cbd4d9e7cfd2593079(shader: harden depth_mask_aot CLI error handling, add pure-Python tests).Result: no P1, no P2, 2 P3.
Commands executed locally:
git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflicts.gh pr checks 2108: all run jobs pass (Windows, Linux Python checks, gfx1013 fixtures).git diff --check origin/main...HEAD: OK.python3 tests/bidi_controls_check.py: pass.python3 tests/docs_links_check.py: pass.python3 -B tests/depth_mask_aot_cli_check.py: 7 tests OK.python3 x2w_pipe.py win2025 2108 --wait 900(CMake touched): Debug (dev preset) and Release /O2 both 5/5 (depth_mask_aot_cliplus the fourdepth_mask_*_draw_warpsuites).Mutations (each reverted with
git checkout -- .):tools/depth_mask_aot.py:223guardif dest not in vectorreplaced byif False:depth_mask_aot_cli_check.pyfails (errors=1). Killed.tools/depth_mask_aot.pytmp_path.replace(dest)replaced by a no-op rename: fails (failures=1, errors=1). Killed.Code read: error paths now return exit 1 with a message for OSError, ValueError, struct.error and zlib.error. The output is written through a temp file and then replaced, and the temp file is removed on failure. A container with no DXIL part and an unwritten
v_fmac_f32destination now give clean errors. The only in-tree caller is the module import inshader_profile_audit.py, andmain()is unchanged for it.P3:
tools/depth_mask_aot.py:315-325(NamedTemporaryFile+replace): the temp file is created with mode 0600, so the generated.hlslnow ends up 0600 instead of the umask default (0644). This can surprise other users or CI steps that read the output. Consideros.chmodto0o666 & ~umaskbefore the replace.tools/depth_mask_aot.py:286:--tableis checked for non-negative values, but a huge offset or SGPR is only caught later bylower. Non-blocking; a cap or a test for it would be tidier.AI-assisted; commands listed were executed locally.