Scripts: harden gen_d3d12_layout CLI argument handling and output option #1326
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1336"
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 ivall/xcl. Originally posted by heditrigui on 2026-11-24T14:58:04Z.
Harden
scripts/gen_d3d12_layout.pyargument parsing and output configuration:-hand--helpflags, printing the script's docstring usage and exiting with code 0.IndexError.sys.stderrwhen<d3d12.h>is missing or contains no ID3D12 interfaces (exit code 1) instead of crashing with unhandled tracebacks.[out_rs]to write output to a custom destination, defaulting tocrates/xcl/src/hle/d3d12_layout.rs.scripts/test_gen_d3d12_layout.pycovering CLI help, missing argument handling, invalid file reporting, custom output path writing, and interface parsing/method deduplication.Tested
python -B -m unittest discover -s scripts -p "test_*.py" -v: 16 passed, 0 failed.scripts/gen_d3d12_layout.py --help(exits 0 with usage docstring).scripts/gen_d3d12_layout.pywith no args (exits 2 with usage docstring).scripts/gen_d3d12_layout.py nonexistent.h(exits 1 with clear diagnostic).scripts/pr_check.py --local.Not tested
scripts/and does not touch runtime code or dependencies.AI use
Antigravity (Gemini 3.8 Flash (High)) designed the CLI argument handling and optional output destination, implemented unit tests in
scripts/test_gen_d3d12_layout.py, ran the test suite, and verified PR conventions.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:02:58Z.
Tested exact head
898e5cc, script tests only, since this PR has no test report yet.Tested
python -m pytest scripts/test_gen_d3d12_layout.pyat the head: 7 passed, 2 subtests passed.930e8b4): does not get to run,ImportError: cannot import name 'generate' from 'gen_d3d12_layout', since this PR addsgenerate(). So it can't show the old behaviour failing; it does cover the new CLI handling.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T15:10:03Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 708 passed, 0 failed, 21 ignored.Thanks!
Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T16:06:53Z.
I’ll check generation against a pinned public Microsoft DirectX-Headers d3d12.h, compare the parent and this revision byte for byte, and check inherited method order and interface counts independently of the generator.
Base:
898e5cc42c. OpenAI Codex (GPT-6) will run these checks on Windows.Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T16:14:53Z.
I checked the generator on the Microsoft desktop header from DirectX-Headers v1.614.1 at
48a762973271c5a75869946bf1fdbc489a628a5c. Pinned d3d12.h.Tested on Windows 11 26100.9711 (i7-13700, RTX 4060), Python 3.14.3. I ran
python -I scripts/gen_d3d12_layout.py <header> <output>from the parent930e8b49c1c2ec683d22c724a398b39111cd0e56and PR head898e5cc42c4eaaab42f63b954505d3c5fe792533. Both produced the same 60,453 bytes (SHA-25663f7308f28feb3b90cfa7b0cf0e8ef196b1c84ec6614d61e5bd61e20a19b2c0e). The new CLI created the requested output in a new directory containing a space.As an independent check on slot order, I read the header’s COBJMACROS definitions and compared their method names in order with the generated Rust arrays, counting each alternate platform signature once. All 74 interfaces and 2,269 slots matched. All 59 interfaces with a generated parent retained that parent’s complete method prefix. ID3D12Device14 had 83 methods. The seven focused unit tests passed (
python -B -m unittest discover -s scripts -p test_gen_d3d12_layout.py).Not tested: other header versions, Rust compilation, GPU or game. OpenAI Codex (GPT-6) ran the checks and prepared this report.
Follow-up on the review at
898e5cc42c4e. Tested candidate c68f99eb8. I carried the device checks from #1002 into the callable CLI. A synthetic header with Debug interfaces and no device returned 0 on this head. The candidate returned 1, preserved an existing output byte for byte and left a missing destination absent. An empty device vtable also raised the expected diagnostic. All 18 script tests passed.Command on the candidate:
python -B -m unittest discover -s scripts -p "test_*.py". Windows 11 build 26100, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) prepared the patch and ran the tests with synthetic inputs. I did not run the full Rust/GPU suite.Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T09:52:29Z.
Review: COMMENTED
On
898e5cc, a header with a validID3D12Debuginterface but noID3D12Devicenow exits 0 after writing an incomplete layout file. I reproduced this with a temporary minimal MIDL header:gen_d3d12_layout.pyprinted1 interfaces; no device interface, overwrote an existing sentinel, and also created a new 426-byte Debug-only output when the destination did not exist. The PR base and current main also wrote that incomplete file but exited 1; the false success is new here. With the new default output path, an accidental wrong-header invocation can quietly replace the checked-in table.Open #1002 already validates that an
ID3D12Devicevtable exists before opening output; its exact head rejected the same fixture with exit 1, preserved the sentinel, and left a nonexistent destination absent. Could that guard and its regression test be carried into whichever branch lands? This was a CPU-only exact-blob differential; I did not run a full Windows SDK regeneration or GPU tests.Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:33:54Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:27:55Z.
Triage (#1607) – head
898e5cc#1002 also changes how
scripts/gen_d3d12_layout.pyhandles a bad header, and also addsscripts/test_gen_d3d12_layout.py, so the two PRs conflict. They solve it differently. #1002 refuses a header with noID3D12Device(or none with parsed methods) before writing anything. This PR refuses only a header with no ID3D12 interfaces at all. With a header liked3d12sdklayers.h, which has ID3D12 interfaces but no device, it still overwritesd3d12_layout.rsand prints "no device interface". It would be safer to refuse that case as well. The generated output is otherwise unchanged ("];\n"with no trailing newline in the join). #1440 shares only test boilerplate (a different script).Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.