runtime: add a read-only shader-pack compatibility check #2417

Closed
marcelofrayha wants to merge 1 commit from upstream-pr/2417 into main
marcelofrayha commented 2026-11-27 02:17:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by marcelofrayha on 2026-11-27T02:17:01Z.


Claimed in the coordination issue as: RT-SHADER-PACK-CHECK

Depends on: none. There are textual conflicts with #1885 and #2192 in the builder/probe code; this change shares the existing driver rules without changing translation flag selection. It does not depend on the runtime fallback or pipeline-check PRs.

What and why

Add gta6rt --check-shader-pack [DIR] to catch mesh and barycentric mismatches before precompiling pipelines. It uses the same physical Vulkan adapter selection as --run with the Vulkan backend and reads only shader indexes. It does not open game files, create a logical Vulkan device, compile pipelines, or write caches.

The report distinguishes missing native GPU features, known driver issues (using the same rules as make_game.py), and translated fallbacks the runtime does not yet support. Unrecognized stages and unreadable optional indexes are reported without hiding blockers found in readable indexes. Exit codes: 0 no mismatch found, 1 blockers, 2 incomplete without known blockers.

Tested

  • Linux CTest: shader_library and shader_pack_check, including synthetic driver IDs, unknown stages, and malformed optional indexes.
  • Python: test_vk_subgroup_info.py and test_make_game_translator_flags.py (89 tests), test_text_write_line_endings.py, and make_game.py --help.
  • Windows cross-build and seven synthetic Wine CLI cases; expected diagnostics and exit codes, no logical device creation or runtime cache writes. No retail run or shader retranslation.

GPUs tested: AMD Radeon RX 5700 XT (RADV) and Lavapipe/llvmpipe (LLVM 21.1.8), both Mesa 26.0.8-1ubuntu0.3 on Linux under Wine 10.0. The affected Intel/AMD driver cases were tested with synthetic adapter data, not on affected hardware.

AI-assisted: yes.

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption, including in logs or reports quoted here.
  • Translator contract update: not applicable; no new translator rule.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5520036184 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2417). Originally posted by [marcelofrayha](https://github.com/marcelofrayha) on 2026-11-27T02:17:01Z. --- Claimed in the coordination issue as: [RT-SHADER-PACK-CHECK](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7206392462) Depends on: none. There are textual conflicts with #1885 and #2192 in the builder/probe code; this change shares the existing driver rules without changing translation flag selection. It does not depend on the runtime fallback or pipeline-check PRs. ### What and why Add `gta6rt --check-shader-pack [DIR]` to catch mesh and barycentric mismatches before precompiling pipelines. It uses the same physical Vulkan adapter selection as `--run` with the Vulkan backend and reads only shader indexes. It does not open game files, create a logical Vulkan device, compile pipelines, or write caches. The report distinguishes missing native GPU features, known driver issues (using the same rules as `make_game.py`), and translated fallbacks the runtime does not yet support. Unrecognized stages and unreadable optional indexes are reported without hiding blockers found in readable indexes. Exit codes: `0` no mismatch found, `1` blockers, `2` incomplete without known blockers. ### Tested - Linux CTest: `shader_library` and `shader_pack_check`, including synthetic driver IDs, unknown stages, and malformed optional indexes. - Python: `test_vk_subgroup_info.py` and `test_make_game_translator_flags.py` (89 tests), `test_text_write_line_endings.py`, and `make_game.py --help`. - Windows cross-build and seven synthetic Wine CLI cases; expected diagnostics and exit codes, no logical device creation or runtime cache writes. No retail run or shader retranslation. GPUs tested: AMD Radeon RX 5700 XT (RADV) and Lavapipe/llvmpipe (LLVM 21.1.8), both Mesa 26.0.8-1ubuntu0.3 on Linux under Wine 10.0. The affected Intel/AMD driver cases were tested with synthetic adapter data, not on affected hardware. AI-assisted: yes. ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption, including in logs or reports quoted here. - [ ] Translator contract update: not applicable; no new translator rule.
ecox982745 commented 2026-11-27 02:48:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-27T02:48:46Z.


Verified the CLI on native Windows 11, RTX 4090, NVIDIA 616.64 at 7f3892a4. I built gta6rt.exe with MSVC and used the translator's metadata for the hand-written ps_bary and ms_tri fixtures, each in native and fallback mode, with synthetic lookup hashes.

All nine CLI cases returned the expected code. The native pixel/mesh pair returned 0. The fallback pair returned 1 and reported both blockers even with an unreadable optional index. An incomplete pack, a missing main index, and an unmatched adapter filter returned 2. A non-ASCII directory worked through the positional argument, LEONIDA_SHADERS, and UTF-8 shader_path.txt. When those settings pointed at different packs, the explicit argument won over the environment, which won over the file.

I also checked the read-only behavior. With VK_LOADER_DEBUG=all, the checker logged vkCreateInstance only among the two creation calls. A separate small draw on the same loader logged both vkCreateInstance and vkCreateDevice. File names, sizes, and modification times in the pack and runtime scratch directories stayed unchanged during all nine checks. Both relevant CTests and all 89 Python tests passed. The checker only queried adapter capabilities. No game data or gameplay run was involved.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7208458218 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2417#issuecomment-7208458218). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-27T02:48:46Z. --- Verified the CLI on **native Windows 11, RTX 4090, NVIDIA 616.64** at `7f3892a4`. I built `gta6rt.exe` with MSVC and used the translator's metadata for the hand-written `ps_bary` and `ms_tri` fixtures, each in native and fallback mode, with synthetic lookup hashes. All nine CLI cases returned the expected code. The native pixel/mesh pair returned 0. The fallback pair returned 1 and reported both blockers even with an unreadable optional index. An incomplete pack, a missing main index, and an unmatched adapter filter returned 2. A non-ASCII directory worked through the positional argument, `LEONIDA_SHADERS`, and UTF-8 `shader_path.txt`. When those settings pointed at different packs, the explicit argument won over the environment, which won over the file. I also checked the read-only behavior. With `VK_LOADER_DEBUG=all`, the checker logged `vkCreateInstance` only among the two creation calls. A separate small draw on the same loader logged both `vkCreateInstance` and `vkCreateDevice`. File names, sizes, and modification times in the pack and runtime scratch directories stayed unchanged during all nine checks. Both relevant CTests and all 89 Python tests passed. The checker only queried adapter capabilities. No game data or gameplay run was involved.
tiguan26 commented 2026-11-27 05:53:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T05:53:38Z.

Review: APPROVED


Approving. Checked on 7f3892a43, which merges cleanly onto main.

Built shader_pack_check_test and gta6rt (clang-cl, cross-built). Under Wine on llvmpipe the ctest passes. I ran gta6rt --check-shader-pack on hand-made indexes (no game data): one ms entry, one ps entry that needs native barycentrics, one ps with bary_fallback_input and a vs. It reports llvmpipe as native mesh yes, barycentrics no, counts 1 + 1 blockers, exits 1. A pack with only a vs exits 0 ("no known mesh/barycentric mismatch"), a missing directory exits 2 ("cannot open ...index.json"), and two arguments print the usage. tests/test_vk_subgroup_info.py and tests/test_make_game_translator_flags.py: 89 passed.

Read the diff. The probe stops before the logical device, and OwnedRuntime has no destructor, so the explicit destroy_instance on the probe path is the only one (no double destroy). read_shader_index moving out of load_index keeps the BOM and object checks. The rules table is now one source for C++ and Python, and the gfx90c and ANV entries are the same IDs that were removed from vk_subgroup_info.py. I checked that nothing copies that script out of the tree, so reading runtime/src/shader_driver_rules.inc by relative path is safe. And main's runtime indeed reads neither mesh_compute nor bary_fallback_input, so "cannot replay" and "not implemented" are accurate today.

Two small things, not blockers. With a missing or unreadable directory it still probes the GPU before reporting the index error, and the device line prints after the error; reading the main index first would fail fast. And usage() returns 2, the same code as "incomplete check", so a script calling it with bad arguments can't tell the two apart.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6084058535 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2417#pullrequestreview-6084058535). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-27T05:53:38Z. **Review:** APPROVED --- Approving. Checked on 7f3892a43, which merges cleanly onto main. Built `shader_pack_check_test` and `gta6rt` (clang-cl, cross-built). Under Wine on llvmpipe the ctest passes. I ran `gta6rt --check-shader-pack` on hand-made indexes (no game data): one ms entry, one ps entry that needs native barycentrics, one ps with `bary_fallback_input` and a vs. It reports llvmpipe as native mesh yes, barycentrics no, counts 1 + 1 blockers, exits 1. A pack with only a vs exits 0 ("no known mesh/barycentric mismatch"), a missing directory exits 2 ("cannot open ...index.json"), and two arguments print the usage. `tests/test_vk_subgroup_info.py` and `tests/test_make_game_translator_flags.py`: 89 passed. Read the diff. The probe stops before the logical device, and `OwnedRuntime` has no destructor, so the explicit `destroy_instance` on the probe path is the only one (no double destroy). `read_shader_index` moving out of `load_index` keeps the BOM and object checks. The rules table is now one source for C++ and Python, and the gfx90c and ANV entries are the same IDs that were removed from `vk_subgroup_info.py`. I checked that nothing copies that script out of the tree, so reading `runtime/src/shader_driver_rules.inc` by relative path is safe. And main's runtime indeed reads neither `mesh_compute` nor `bary_fallback_input`, so "cannot replay" and "not implemented" are accurate today. Two small things, not blockers. With a missing or unreadable directory it still probes the GPU before reporting the index error, and the device line prints after the error; reading the main index first would fail fast. And `usage()` returns 2, the same code as "incomplete check", so a script calling it with bad arguments can't tell the two apart.
zmasi commented 2026-11-27 11:16:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-27T11:16:58Z.


Verified 7f3892a43 under Wine on physical fixed-wave64 gfx906 (RADV 26.0.8), with neither native mesh nor native fragment barycentrics. A compatible synthetic index exited 0; native mesh, native barycentrics and fallbacks unsupported by this PR’s runtime exited 1. Incomplete metadata or an unreadable optional index without a known blocker exited 2. Combining a blocker with an unreadable index still gave 1 and reported the incomplete scan. A failed adapter selection was correctly distinguished from a pack blocker.

On a local 29,279-module pack, the index-only check counted 9,282 mesh-as-compute modules, 527 fallback pixel modules and 0 unknown, matching an independent index count. All five index digests and the pack’s file metadata were unchanged. The checker process opened the indexes read-only; its driver activity matched enumeration, not the device-creation control, and it wrote no pipeline-cache blobs. That is a check of this PR head, not a claim that pipelines were compiled or drawn.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7216893011 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2417#issuecomment-7216893011). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-27T11:16:58Z. --- Verified `7f3892a43` under Wine on physical fixed-wave64 gfx906 (RADV 26.0.8), with neither native mesh nor native fragment barycentrics. A compatible synthetic index exited **0**; native mesh, native barycentrics and fallbacks unsupported by this PR’s runtime exited **1**. Incomplete metadata or an unreadable optional index without a known blocker exited **2**. Combining a blocker with an unreadable index still gave **1** and reported the incomplete scan. A failed adapter selection was correctly distinguished from a pack blocker. On a local 29,279-module pack, the index-only check counted 9,282 mesh-as-compute modules, 527 fallback pixel modules and 0 unknown, matching an independent index count. All five index digests and the pack’s file metadata were unchanged. The checker process opened the indexes read-only; its driver activity matched enumeration, not the device-creation control, and it wrote no pipeline-cache blobs. That is a check of this PR head, not a claim that pipelines were compiled or drawn. AI-assisted.
KelboLive commented 2026-11-30 17:23:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-11-30T17:23:54Z.


Independent check on Windows (not the author), at 7f3892a43.

  • Built shader_pack_check_test and ran it: exit 0 (the test prints nothing on success).
  • tests/test_make_game_translator_flags.py: 34 tests OK; tests/test_vk_subgroup_info.py: 55 tests OK.

Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, Python 3.12.10, Vulkan SDK 1.4.363.0.

AI-assisted: yes (opencode).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7286210982 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2417#issuecomment-7286210982). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-30T17:23:54Z. --- Independent check on Windows (not the author), at `7f3892a43`. - Built `shader_pack_check_test` and ran it: **exit 0** (the test prints nothing on success). - `tests/test_make_game_translator_flags.py`: **34 tests OK**; `tests/test_vk_subgroup_info.py`: **55 tests OK**. Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, Python 3.12.10, Vulkan SDK 1.4.363.0. AI-assisted: yes (opencode).
aslan2142 commented 2026-12-01 17:25:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:25:52Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319287075 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2417#issuecomment-7319287075). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:25:52Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!2417
No description provided.