Scripts: keep the D3D12 layout when the header has no device #995

Open
timorjay wants to merge 2 commits from upstream-pr/1002 into main
timorjay commented 2026-11-24 10:14:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by timorjay on 2026-11-24T10:14:36Z.


With the Windows SDK's d3d12sdklayers.h as input, the generator replaced the existing interface table with 6,947 bytes of debug interfaces, then failed because it could not find a device. A recognized device with no parsed methods could also replace the layout with an empty method list.

What is in it

  • scripts/gen_d3d12_layout.py finds the device before opening the output and reports which header it expected.
  • scripts/test_gen_d3d12_layout.py checks that a header without a device preserves an existing destination and leaves an absent destination absent.
  • RavenCurseBurg’s follow-up checks every recognized device for methods before opening the output, including mixed base and derived headers. Original commit

Tested

  • Windows 11 Pro 26300.9974, Ryzen 7 9800X3D, RTX 5090 D v2 (32.0.16.1742), rustc 1.98.1, debug, Python 3.14.7.
  • On 5c59a59, python -B -m unittest discover -s scripts -p "test_*.py" -v passed 5/5. The prior head e08daa9 created or replaced the layout in all six combinations of an empty device alone, empty derived device, or empty base device with an existing or missing output. The new head rejected all six and preserved the original state.
  • Outputs on 5c59a59 matched e08daa9 byte for byte for Microsoft DirectX-Headers v1.614.1 (74 interfaces, 60,453 bytes) and 61c77189 (102 interfaces, 77,439 bytes), and for a valid synthetic base/derived pair.
  • On e08daa9, the Python suite passed 4/4. The original missing-device test failed on parent 09940bb.
  • With valid d3d12.h from Windows SDK 10.0.26100 and Microsoft DirectX-Headers 61c77189, output matched the parent byte for byte (81 and 102 interfaces). The latter also matched the table in Git.
  • On e08daa9, cargo build --locked --workspace passed. cargo test --locked --workspace --no-fail-fast -- --test-threads=4: 715 passed, 1 failed, 41 ignored. Two of the 715 reported SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware.
  • test_title_runs_and_game_folder_is_untouched failed on both this commit and 09940bb: the synthetic title exited successfully, but report.called_stubs was empty.

Not tested

  • The follow-up changes only the generator and its Python tests. The Rust/GPU suite was last run on e08daa9. Retail gameplay and other GPUs were outside these checks. The patch changes the generator and its test only.

AI use

  • OpenAI Codex (GPT-6) wrote the initial patch and test, ran the checks, independently verified the follow-up and drafted this description.
<!-- greyfinch-sync:ivall/xcl:issue:5470204181 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1002). Originally posted by [timorjay](https://github.com/timorjay) on 2026-11-24T10:14:36Z. --- With the Windows SDK's `d3d12sdklayers.h` as input, the generator replaced the existing interface table with 6,947 bytes of debug interfaces, then failed because it could not find a device. A recognized device with no parsed methods could also replace the layout with an empty method list. **What is in it** - `scripts/gen_d3d12_layout.py` finds the device before opening the output and reports which header it expected. - `scripts/test_gen_d3d12_layout.py` checks that a header without a device preserves an existing destination and leaves an absent destination absent. - RavenCurseBurg’s follow-up checks every recognized device for methods before opening the output, including mixed base and derived headers. [Original commit](https://github.com/RavenCurseBurg/xcl/commit/5c59a591123648efbf0fe4fa87d3366bfeac4f90) **Tested** - Windows 11 Pro 26300.9974, Ryzen 7 9800X3D, RTX 5090 D v2 (32.0.16.1742), rustc 1.98.1, debug, Python 3.14.7. - On `5c59a59`, `python -B -m unittest discover -s scripts -p "test_*.py" -v` passed 5/5. The prior head `e08daa9` created or replaced the layout in all six combinations of an empty device alone, empty derived device, or empty base device with an existing or missing output. The new head rejected all six and preserved the original state. - Outputs on `5c59a59` matched `e08daa9` byte for byte for Microsoft DirectX-Headers v1.614.1 (74 interfaces, 60,453 bytes) and `61c77189` (102 interfaces, 77,439 bytes), and for a valid synthetic base/derived pair. - On `e08daa9`, the Python suite passed 4/4. The original missing-device test failed on parent `09940bb`. - With valid `d3d12.h` from Windows SDK 10.0.26100 and Microsoft DirectX-Headers `61c77189`, output matched the parent byte for byte (81 and 102 interfaces). The latter also matched the table in Git. - On `e08daa9`, `cargo build --locked --workspace` passed. `cargo test --locked --workspace --no-fail-fast -- --test-threads=4`: 715 passed, 1 failed, 41 ignored. Two of the 715 reported `SKIPPED` (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware`. - `test_title_runs_and_game_folder_is_untouched` failed on both this commit and `09940bb`: the synthetic title exited successfully, but `report.called_stubs` was empty. **Not tested** - The follow-up changes only the generator and its Python tests. The Rust/GPU suite was last run on `e08daa9`. Retail gameplay and other GPUs were outside these checks. The patch changes the generator and its test only. **AI use** - OpenAI Codex (GPT-6) wrote the initial patch and test, ran the checks, independently verified the follow-up and drafted this description.
dcastell1 commented 2026-11-24 11:05:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T10:35:37Z.


Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@6efdabc (baseline 727 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
727 passed; 0 failed; 41 ignored   (exit 0)

Same count as the baseline (keeping the D3D12 layout when the header has no declaration), nothing regresses.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

<!-- greyfinch-sync:ivall/xcl:comment:7128986624 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1002#issuecomment-7128986624). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T10:35:37Z. --- Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on `main@6efdabc` (baseline **727 passed, 0 failed, 41 ignored** on this box): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 727 passed; 0 failed; 41 ignored (exit 0) ``` Same count as the baseline (keeping the D3D12 layout when the header has no declaration), nothing regresses. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
DavidM1911 commented 2026-11-24 12:05:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T11:34:08Z.


Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X; Python 3, debug.

  • python scripts/test_gen_d3d12_layout.py: 1 test, OK — the new test feeds the generator a header with ID3D12Debug but no device interface, asserts it exits non-zero with expected d3d12.h, that a pre-existing output file is left byte-identical, and that no new output is created. The 5-line generator change gates output writing on finding the device vtable.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

<!-- greyfinch-sync:ivall/xcl:comment:7130264280 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1002#issuecomment-7130264280). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T11:34:08Z. --- Independent verification, merged onto current `main` `384f7f7` locally (clean merge). **Machine:** Windows 11, Ryzen 9 7900X; Python 3, debug. - `python scripts/test_gen_d3d12_layout.py`: **1 test, OK** — the new test feeds the generator a header with `ID3D12Debug` but no device interface, asserts it exits non-zero with `expected d3d12.h`, that a pre-existing output file is left byte-identical, and that no new output is created. The 5-line generator change gates output writing on finding the device vtable. AI use: test runs by Devin (Cognition, SWE-2); no code changes.
RavenCurseBurg commented 2026-11-25 21:05:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T20:36:50Z.


Verified the fast-forward to 5c59a591123648efbf0fe4fa87d3366bfeac4f90, the original fork commit with RavenCurseBurg as author. On this upstream head the complete Python suite passed 5/5. I also reran six invalid-header CLI cases: an empty base only, an empty derived table with a populated base, and an empty base with a populated derived table, each with and without a previous output file. Every run preserved the existing bytes or left the missing path absent. A valid base/derived pair still generated both interface names and the expected methods. Windows 11, Core i7-13700, Python 3.14.3, no Rust or GPU run. OpenAI Codex (GPT-6) reran the checks.

Earlier verification

Tested on e08daa9c7a39068bd881e931d8b5f439e954c272, Windows 11 build 26100.9711, Core i7-13700, Python 3.14.3.

python -I scripts/gen_d3d12_layout.py synthetic.h layout.rs returned 0 and wrote methods: &[] when a device IID and vtable name matched but the table had no parsed methods. I tested an empty device alone, an empty derived device alongside a populated base, and the reverse. In all three cases the generator also replaced a pre-existing output.

The candidate fix and regression name the empty device and stop before opening the output. All six combinations of those headers with an existing or missing output preserved the previous bytes or left the path absent. A valid base/derived pair still generated correctly. With Microsoft's DirectX-Headers v1.614.1 desktop header, the original and candidate generated identical 60,453-byte files: 74 interfaces, 83 methods on ID3D12Device14.

python -B scripts/test_gen_d3d12_layout.py passed 2/2 and python -B -m unittest discover -s scripts passed 5/5. Both new empty-device subcases failed against the PR head.

Not tested — The Rust workspace or GPU runtime. OpenAI Codex (GPT-6) generated the fixtures, implemented and tested the candidate, and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7173929260 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1002#issuecomment-7173929260). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T20:36:50Z. --- Verified the fast-forward to `5c59a591123648efbf0fe4fa87d3366bfeac4f90`, the original fork commit with RavenCurseBurg as author. On this upstream head the complete Python suite passed 5/5. I also reran six invalid-header CLI cases: an empty base only, an empty derived table with a populated base, and an empty base with a populated derived table, each with and without a previous output file. Every run preserved the existing bytes or left the missing path absent. A valid base/derived pair still generated both interface names and the expected methods. Windows 11, Core i7-13700, Python 3.14.3, no Rust or GPU run. OpenAI Codex (GPT-6) reran the checks. <details> <summary>Earlier verification</summary> **Tested** on `e08daa9c7a39068bd881e931d8b5f439e954c272`, Windows 11 build 26100.9711, Core i7-13700, Python 3.14.3. `python -I scripts/gen_d3d12_layout.py synthetic.h layout.rs` returned 0 and wrote `methods: &[]` when a device IID and vtable name matched but the table had no parsed methods. I tested an empty device alone, an empty derived device alongside a populated base, and the reverse. In all three cases the generator also replaced a pre-existing output. The [candidate fix and regression](https://github.com/RavenCurseBurg/xcl/commit/5c59a591123648efbf0fe4fa87d3366bfeac4f90) name the empty device and stop before opening the output. All six combinations of those headers with an existing or missing output preserved the previous bytes or left the path absent. A valid base/derived pair still generated correctly. With Microsoft's [DirectX-Headers v1.614.1 desktop header](https://github.com/microsoft/DirectX-Headers/blob/48a762973271c5a75869946bf1fdbc489a628a5c/include/directx/d3d12.h), the original and candidate generated identical 60,453-byte files: 74 interfaces, 83 methods on `ID3D12Device14`. `python -B scripts/test_gen_d3d12_layout.py` passed 2/2 and `python -B -m unittest discover -s scripts` passed 5/5. Both new empty-device subcases failed against the PR head. **Not tested** — The Rust workspace or GPU runtime. OpenAI Codex (GPT-6) generated the fixtures, implemented and tested the candidate, and wrote this report. </details>
timorjay commented 2026-11-26 01:05:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by timorjay on 2026-11-26T00:37:36Z.


Thanks for the reproducer and the patch. I fast-forwarded this PR to your original commit 5c59a59 so your authorship is preserved. On Windows with Python 3.14.7, I reproduced the overwrite or unwanted file creation in all six cases on e08daa9. The new head rejects all six, and the script suite passes 5/5. The generated layouts are byte-identical on both heads for Microsoft DirectX-Headers v1.614.1 and 61c77189. The PR description records the commands and the revision of the previous GPU run.

Codex-assisted reproduction and verification.

<!-- greyfinch-sync:ivall/xcl:comment:7178950369 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1002#issuecomment-7178950369). Originally posted by [timorjay](https://github.com/timorjay) on 2026-11-26T00:37:36Z. --- Thanks for the reproducer and the patch. I fast-forwarded this PR to your original commit `5c59a59` so your authorship is preserved. On Windows with Python 3.14.7, I reproduced the overwrite or unwanted file creation in all six cases on `e08daa9`. The new head rejects all six, and the script suite passes 5/5. The generated layouts are byte-identical on both heads for Microsoft DirectX-Headers v1.614.1 and `61c77189`. The PR description records the commands and the revision of the previous GPU run. Codex-assisted reproduction and verification.
DavidM1911 commented 2026-11-26 04:07:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T03:32:07Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7181803389 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1002#issuecomment-7181803389). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T03:32:07Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
github-actions[bot] commented 2026-11-30 08:42:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:42:07Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7273235755 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1002#issuecomment-7273235755). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:42:07Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 04:37:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:37:03Z.


Triage (#1607) – head 5c59a59

No merged change covers this: main's gen_d3d12_layout.py still writes the output and only then looks for a device. #1336 also edits this script and also adds scripts/test_gen_d3d12_layout.py, so the two conflict. #1336 refuses only a header with no ID3D12 interfaces at all. With d3d12sdklayers.h it would still overwrite the table with the debug interfaces ("no device interface"), which is the case this PR rejects.
No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7300916974 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1002#issuecomment-7300916974). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:37:03Z. --- **Triage (#1607)** – head 5c59a59 No merged change covers this: main's `gen_d3d12_layout.py` still writes the output and only then looks for a device. #1336 also edits this script and also adds `scripts/test_gen_d3d12_layout.py`, so the two conflict. #1336 refuses only a header with no ID3D12 interfaces at all. With `d3d12sdklayers.h` it would still overwrite the table with the debug interfaces ("no device interface"), which is the case this PR rejects. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1002:upstream-pr/1002'
git switch 'upstream-pr/1002'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/1002'
git switch 'upstream-pr/1002'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1002'
git switch 'upstream-pr/1002'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1002'
git switch 'main'
git merge --squash 'upstream-pr/1002'
git switch 'main'
git merge --ff-only 'upstream-pr/1002'
git switch 'main'
git merge 'upstream-pr/1002'
git push origin 'main'
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
xcl-dev/xcl!995
No description provided.