Skip to content

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

Closed
marcelofrayha wants to merge 1 commit into
ProjectLeonida:mainfrom
marcelofrayha:rt-shader-pack-check
Closed

marcelofrayha wants to merge 1 commit into
ProjectLeonida:mainfrom
marcelofrayha:rt-shader-pack-check

Conversation

@marcelofrayha

@marcelofrayha marcelofrayha commented Nov 27, 2026 •

Copy link
Copy Markdown

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.

@ecox982745

Copy link
Copy Markdown
Contributor

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 tiguan26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Checked on 7f3892a, 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

zmasi commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Collaborator

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.

@aslan2142 aslan2142 closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants