make_game: --gpu-info FILE decides the shaders stage for the PC that will run the port #61

Open
github-bot wants to merge 1 commit from github-bot/gh-61 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:10 UTC · original
ubiquitarianism:old-pr/9784 → main · +175 −15 · 3 files · 1 commits · draft

Carried over from old PR 9784 by Bruce1419 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9784, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
Bruce1419: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue as: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116525882 (new item)

Depends on: #5530, #8068 (both change runtime_gpu_per_vertex / wave64_settings, which this PR also touches; whichever lands second rebases)

What and why

The shaders stage asks the build machine's GPU whether to emulate wave64 and which fallback flags to turn on. When
the shaders are translated somewhere other than the PC that will run the port, it answers for the wrong GPU. Under
WSL the only Vulkan device is llvmpipe, which reports max_subgroup_size 8 and per_vertex_inputs false (measured
on Ubuntu 26.04 under WSL2). A WSL build for an RX 6900 XT therefore turned on wave64 emulation and
--f16-interp-fallback, though that GPU needs neither, and the only workaround was hiding WSL's Vulkan loader
(VK_DRIVER_FILES) and passing --wave64-emulate off.

--gpu-info FILE takes the answers python -I tools/vk_subgroup_info.py > gpu.json saved on the target PC.

  • Every probe question comes from the file:
    • the wave64 mode, with auto's subgroup size taken from the file's max_subgroup_size;
    • --f16-interp-fallback;
    • --pc-tail-ubo;
    • --bary-fallback;
    • Intel's --mesh-compute.
  • Nothing runs on the build machine: neither the probe nor vulkaninfo.
  • A file that is not the tool's answer stops the build with the reason: a missing file, no JSON object on its
    last line, or the tool's own {"error": ...} record.
  • One probe path: runtime_gpu_per_vertex() now reads runtime_gpu_info() like the other questions, instead
    of starting the probe itself.
  • README: documents the option next to --wave64-emulate.

Tested

Windows 11 Pro (build 26100), AMD Radeon RX 6900 XT, AMD driver 32.0.21045.29003, Python 3.14.7; WSL2 Ubuntu
26.04 with Python 3.14.4.

  • New tests in tests/test_make_game_wave64.py (GpuInfoFileTest, 5 tests), all failing before the change:
    • the file is read like the tool's output;
    • each kind of bad file stops the build;
    • every probe question is answered from the file while subprocess.run refuses any call;
    • the wave64 decisions for RDNA2 on AMD's Windows driver, a 32-wide target, a 64-wide target and a file without
      a size;
    • main() with an llvmpipe build machine: without the option it translates emulated with
      --f16-interp-fallback, and with the RX 6900 XT's file it translates native with no flags and asks the build
      machine nothing.
  • Existing tests pass on this branch: python -I on test_make_game_wave64, test_make_game_argparse,
    test_make_game_preflight, test_make_game_translator_flags and test_vk_subgroup_info.
  • Unrelated guard failures: test_docs_cli_flags, test_docs_links, test_docs_env_vars,
    test_text_write_line_endings and test_docs_repo_paths fail with the same messages on clean main. The change
    adds no entry to any of them.
  • In real WSL: I saved the RX 6900 XT's answers on Windows and loaded them in WSL with llvmpipe visible.
    • Without the file: llvmpipe, per_vertex False, wave64 emulation on.
    • With the file: RX 6900 XT, per_vertex True, max_push_constants 256, no mesh crash, native wave64.
    • No subprocess was started.

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: no translator change.)

🤖 Generated with Claude Code

**@⁠Andretuta** on GitHub · 2026-11-24 02:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/61) `ubiquitarianism:old-pr/9784` → `main` · +175 −15 · 3 files · 1 commits · draft > Carried over from **old PR 9784** by `Bruce1419` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9784`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `Bruce1419`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claimed in the coordination issue as: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116525882 (new item) Depends on: `#5530`, `#8068` (both change `runtime_gpu_per_vertex` / `wave64_settings`, which this PR also touches; whichever lands second rebases) ### What and why The shaders stage asks the build machine's GPU whether to emulate wave64 and which fallback flags to turn on. When the shaders are translated somewhere other than the PC that will run the port, it answers for the wrong GPU. Under WSL the only Vulkan device is llvmpipe, which reports `max_subgroup_size` 8 and `per_vertex_inputs` false (measured on Ubuntu 26.04 under WSL2). A WSL build for an RX 6900 XT therefore turned on wave64 emulation and `--f16-interp-fallback`, though that GPU needs neither, and the only workaround was hiding WSL's Vulkan loader (`VK_DRIVER_FILES`) and passing `--wave64-emulate off`. `--gpu-info FILE` takes the answers `python -I tools/vk_subgroup_info.py > gpu.json` saved on the target PC. - **Every probe question comes from the file:** - the wave64 mode, with `auto`'s subgroup size taken from the file's `max_subgroup_size`; - `--f16-interp-fallback`; - `--pc-tail-ubo`; - `--bary-fallback`; - Intel's `--mesh-compute`. - **Nothing runs on the build machine:** neither the probe nor `vulkaninfo`. - **A file that is not the tool's answer stops the build with the reason:** a missing file, no JSON object on its last line, or the tool's own `{"error": ...}` record. - **One probe path:** `runtime_gpu_per_vertex()` now reads `runtime_gpu_info()` like the other questions, instead of starting the probe itself. - **README:** documents the option next to `--wave64-emulate`. ### Tested Windows 11 Pro (build 26100), AMD Radeon RX 6900 XT, AMD driver 32.0.21045.29003, Python 3.14.7; WSL2 Ubuntu 26.04 with Python 3.14.4. - **New tests in `tests/test_make_game_wave64.py` (`GpuInfoFileTest`, 5 tests), all failing before the change:** - the file is read like the tool's output; - each kind of bad file stops the build; - every probe question is answered from the file while `subprocess.run` refuses any call; - the wave64 decisions for RDNA2 on AMD's Windows driver, a 32-wide target, a 64-wide target and a file without a size; - `main()` with an llvmpipe build machine: without the option it translates emulated with `--f16-interp-fallback`, and with the RX 6900 XT's file it translates native with no flags and asks the build machine nothing. - **Existing tests pass on this branch:** `python -I` on test_make_game_wave64, test_make_game_argparse, test_make_game_preflight, test_make_game_translator_flags and test_vk_subgroup_info. - **Unrelated guard failures:** test_docs_cli_flags, test_docs_links, test_docs_env_vars, test_text_write_line_endings and test_docs_repo_paths fail with the same messages on clean `main`. The change adds no entry to any of them. - **In real WSL:** I saved the RX 6900 XT's answers on Windows and loaded them in WSL with llvmpipe visible. - Without the file: llvmpipe, `per_vertex` False, wave64 emulation on. - With the file: RX 6900 XT, `per_vertex` True, `max_push_constants` 256, no mesh crash, native wave64. - No subprocess was started. AI-assisted: yes (Claude Code) ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (Not applicable: no translator change.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The shaders stage asks the build machine's GPU whether to emulate wave64 and which fallback flags to turn on. Under
WSL the only Vulkan device is llvmpipe (8-wide, no PerVertexKHR), so a build there for an RX 6900 XT turned on
wave64 emulation and --f16-interp-fallback, neither of which that GPU needs, and the only way out was to hide WSL's
Vulkan loader. Measured on Ubuntu 26.04 under WSL2: llvmpipe answers per_vertex_inputs false and
max_subgroup_size 8.

--gpu-info FILE takes the answers `python -I tools/vk_subgroup_info.py` saved on the target PC. Every probe
question is answered from it: the wave64 mode, --f16-interp-fallback, --pc-tail-ubo, --bary-fallback, and Intel's
--mesh-compute. Nothing on the build machine runs, not the probe and not vulkaninfo; auto's subgroup size comes
from the file's max_subgroup_size. A file that is not the tool's answer stops the build: no JSON object on its
last line, or the tool's own error record. runtime_gpu_per_vertex now reads runtime_gpu_info() like the other
questions, instead of starting the probe itself.

Tests (test_make_game_wave64.py, GpuInfoFileTest): the file is read like the tool's output; bad files stop with
the reason; every question comes from the file with subprocess.run refusing any call; the wave64 decisions for
RDNA2/Windows, a 32-wide and a 64-wide target; and main() with an llvmpipe build machine, which before the change
translates emulated with --f16-interp-fallback and with it native with no flags. Checked in WSL against the real
RX 6900 XT answers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:42:44 +00:00
Author
Owner

@⁠wavehs on GitHub · 2026-11-24 02:33 UTC · original

macOS arm64 verification (Apple M3 Pro) — the file really does replace every GPU question, the new tests bite, and one promise in the README is wider than the check

Head f24768124, merge-base 2d53a8055; merged onto main (9ec34cdff) as 74a2647d3 with no conflicts. 3 files +175/−15. Host: macOS 27.2.1, Apple M3 Pro (arm64), CPython 3.15.2, Apple clang 21.0.0, llvm-mc 23.1.5, MoltenVK 1.4.0, KosmicKrisp (Mesa 26.3.0).

Check Merged 74a2647d3 main 9ec34cdff
tests/test_make_game_wave64.py 43/43 OK (0.5 s) same file, base make_game.py: 9 errors (NC below)
scripts/run_semantic_tests.py tests/semantic 463 files, 6,075 tests, 2 failed 463 / 6,075 / 2
the two failing files test_exec_computed, test_image_atomics_guard the same two
run_gpu_tests.py, all cases, MoltenVK 182/248 passed, 61 skipped 182/248, 61 skipped
run_gpu_tests.py, all cases, KosmicKrisp 177/248 passed, 64 skipped 177/248, 64 skipped
python -m compileall -q make_game.py tools tests, python -I make_game.py --help clean; --gpu-info FILE in the usage and help —

The GPU rows are identical line for line to main on both drivers after normalising the work paths, as expected: nothing here is read by the translator or the GPU harness.

Negative control: the base make_game.py (2d53a8055) with the new test file gives FAILED (errors=9) — the five sub-cases of test_a_bad_file_stops_the_build_with_the_reason plus test_the_file_is_read_like_the_tools_output, test_every_gpu_question_is_answered_from_the_file, test_wave64_auto_decides_for_the_target_gpu and test_main_uses_the_file_for_the_shaders_stage, all AttributeError: module 'make_game' has no attribute 'GPU_INFO_FROM_FILE'. Every test that existed before still passes, so the class is the whole delta.

End-to-end on this machine, not just the mocks. I ran the real python -I tools/vk_subgroup_info.py (Apple M3 Pro: max_subgroup_size 32, per_vertex_inputs false, max_push_constants_size 4096, native64 false), then fed that exact JSON in through GPU_INFO_FROM_FILE and compared each accessor with its live probe:

wave64        live=(True, True)   file=(True, True)
per_vertex    live=False          file=False
bary_fallback live=False          file=False
push          live=4096           file=4096
mesh_crash    live=False          file=False
info          live == file        (all 20 keys identical)

So the key names in the file are the ones the accessors read — max_subgroup_size, not subgroup_size; mesh_in_supported_stages, not mesh_in_required_stages — which is the failure a test with hand-written JSON cannot catch. (The live path logged "smallest maximum subgroup size is 4" from vulkaninfo on this host and the file says 32; both are below 64, so the decision is the same. That vulkaninfo parse is untouched by this PR.)

The plumbing is complete. Every GPU-derived decision in main() goes through runtime_gpu_info(), and that is the one function the file replaces: wave64_settings (size only in the non-RDNA2 branch, exactly as the probe path), runtime_gpu_per_vertex (--f16-interp-fallback), runtime_gpu_barycentric_fallback (--bary-fallback), runtime_gpu_mesh_draws_crash (--mesh-compute on Intel's driver), runtime_gpu_max_push_constants (--pc-tail-ubo). Those are the five README bullets, and --texel-offset-fallback is correctly absent — it is not decided from the GPU. preflight() and the game check do not probe, so "neither vulkaninfo nor the probe runs on the build machine" holds (the test asserts asked == []; my run confirms it).

One finding, small but the kind this repo cares about. load_gpu_info accepts any JSON object on the last line, so the README's "A file that is not the tool's answer stops the build" is not true. Measured with the merged tree:

{"capabilities": {"device": {}}, "devices": [{"deviceName": "x"}]}   -> accepted   (a vulkaninfo --json, not the tool)
{}                                                                   -> accepted
{"device": "?"}                                                      -> accepted   (deliberate: no size is "unknown", tested)

The first two then answer every GPU question "unknown": wave64 emulation on, --f16-interp-fallback/--bary-fallback/--pc-tail-ubo from the recorded flags, --mesh-compute from the record — i.e. the silent pre-PR behavior this flag exists to avoid, with only shaders: couldn't read the GPU's subgroup size from --gpu-info to show for it. The fix is one line: accept the file only when it has at least one of the tool's keys (device, max_subgroup_size, driver_id), which keeps {"device": "?"} valid and rejects {} and a vulkaninfo dump. Worth doing because the failure is silent and looks like success until a shader misbehaves on the target.

No game files. AI-assisted.

**@⁠wavehs** on GitHub · 2026-11-24 02:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/61#issuecomment-7120263119) **macOS arm64 verification (Apple M3 Pro) — the file really does replace every GPU question, the new tests bite, and one promise in the README is wider than the check** Head `f24768124`, merge-base `2d53a8055`; merged onto `main` (`9ec34cdff`) as `74a2647d3` with no conflicts. 3 files +175/−15. Host: macOS 27.2.1, Apple M3 Pro (arm64), CPython 3.15.2, Apple clang 21.0.0, llvm-mc 23.1.5, MoltenVK 1.4.0, KosmicKrisp (Mesa 26.3.0). | Check | Merged `74a2647d3` | `main` `9ec34cdff` | |---|---|---| | `tests/test_make_game_wave64.py` | **43/43 OK** (0.5 s) | same file, base `make_game.py`: **9 errors** (NC below) | | `scripts/run_semantic_tests.py tests/semantic` | **463 files, 6,075 tests, 2 failed** | 463 / 6,075 / 2 | | the two failing files | `test_exec_computed`, `test_image_atomics_guard` | the same two | | `run_gpu_tests.py`, all cases, MoltenVK | **182/248 passed, 61 skipped** | 182/248, 61 skipped | | `run_gpu_tests.py`, all cases, KosmicKrisp | **177/248 passed, 64 skipped** | 177/248, 64 skipped | | `python -m compileall -q make_game.py tools tests`, `python -I make_game.py --help` | clean; `--gpu-info FILE` in the usage and help | — | The GPU rows are identical line for line to `main` on both drivers after normalising the work paths, as expected: nothing here is read by the translator or the GPU harness. **Negative control:** the base `make_game.py` (`2d53a8055`) with the new test file gives `FAILED (errors=9)` — the five sub-cases of `test_a_bad_file_stops_the_build_with_the_reason` plus `test_the_file_is_read_like_the_tools_output`, `test_every_gpu_question_is_answered_from_the_file`, `test_wave64_auto_decides_for_the_target_gpu` and `test_main_uses_the_file_for_the_shaders_stage`, all `AttributeError: module 'make_game' has no attribute 'GPU_INFO_FROM_FILE'`. Every test that existed before still passes, so the class is the whole delta. **End-to-end on this machine, not just the mocks.** I ran the real `python -I tools/vk_subgroup_info.py` (Apple M3 Pro: `max_subgroup_size` 32, `per_vertex_inputs` false, `max_push_constants_size` 4096, `native64` false), then fed that exact JSON in through `GPU_INFO_FROM_FILE` and compared each accessor with its live probe: ``` wave64 live=(True, True) file=(True, True) per_vertex live=False file=False bary_fallback live=False file=False push live=4096 file=4096 mesh_crash live=False file=False info live == file (all 20 keys identical) ``` So the key names in the file are the ones the accessors read — `max_subgroup_size`, not `subgroup_size`; `mesh_in_supported_stages`, not `mesh_in_required_stages` — which is the failure a test with hand-written JSON cannot catch. (The live path logged "smallest maximum subgroup size is 4" from `vulkaninfo` on this host and the file says 32; both are below 64, so the decision is the same. That `vulkaninfo` parse is untouched by this PR.) **The plumbing is complete.** Every GPU-derived decision in `main()` goes through `runtime_gpu_info()`, and that is the one function the file replaces: `wave64_settings` (size only in the non-RDNA2 branch, exactly as the probe path), `runtime_gpu_per_vertex` (`--f16-interp-fallback`), `runtime_gpu_barycentric_fallback` (`--bary-fallback`), `runtime_gpu_mesh_draws_crash` (`--mesh-compute` on Intel's driver), `runtime_gpu_max_push_constants` (`--pc-tail-ubo`). Those are the five README bullets, and `--texel-offset-fallback` is correctly absent — it is not decided from the GPU. `preflight()` and the game check do not probe, so "neither `vulkaninfo` nor the probe runs on the build machine" holds (the test asserts `asked == []`; my run confirms it). **One finding, small but the kind this repo cares about.** `load_gpu_info` accepts **any** JSON object on the last line, so the README's "A file that is not the tool's answer stops the build" is not true. Measured with the merged tree: ``` {"capabilities": {"device": {}}, "devices": [{"deviceName": "x"}]} -> accepted (a vulkaninfo --json, not the tool) {} -> accepted {"device": "?"} -> accepted (deliberate: no size is "unknown", tested) ``` The first two then answer every GPU question "unknown": wave64 emulation on, `--f16-interp-fallback`/`--bary-fallback`/`--pc-tail-ubo` from the recorded flags, `--mesh-compute` from the record — i.e. the silent pre-PR behavior this flag exists to avoid, with only `shaders: couldn't read the GPU's subgroup size from --gpu-info` to show for it. The fix is one line: accept the file only when it has at least one of the tool's keys (`device`, `max_subgroup_size`, `driver_id`), which keeps `{"device": "?"}` valid and rejects `{}` and a `vulkaninfo` dump. Worth doing because the failure is silent and looks like success until a shader misbehaves on the target. No game files. AI-assisted.
This pull request has changes conflicting with the target branch.
  • make_game.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/61/head:github-bot/gh-61'
git switch 'github-bot/gh-61'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-61'
git switch 'github-bot/gh-61'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-61'
git switch 'github-bot/gh-61'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-61'
git switch 'main'
git merge --squash 'github-bot/gh-61'
git switch 'main'
git merge --ff-only 'github-bot/gh-61'
git switch 'main'
git merge 'github-bot/gh-61'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.