[PR #194] [MERGED] runtime: build.py shader rules depend on every translator module (OLD-3752) #246

Closed
opened 2026-11-26 20:17:15 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/194
Author: @ItsMrDubey
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism

Base: main ← Head: cmake-spirv-translator-deps


📝 Commits (1)

  • bc887c4 runtime: the build.py shader rules rebuild when any translator module changes

📊 Changes

3 files changed (+142 additions, -23 deletions)

View changed files

📝 runtime/CMakeLists.txt (+10 -23)
➕ runtime/cmake/translator_deps.cmake (+31 -0)
➕ tests/test_cmake_translator_deps.py (+101 -0)

📄 Description

Claimed in the coordination issue as: OLD-3752 (BUILD-1064) (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7119646964)

What and why

Old #3752: the eight add_custom_command rules in runtime/CMakeLists.txt that run runtime/test/shaders/build.py (M1.5, bindless, M2, M2 formats, M3, M4, buffer UAV and the four subgroup cases, 11 Ninja edges) listed only build.py, compute_fixture.py (bindless didn't list even that), tools/rdna2spirv.py and their .asm files. If you edited a module the translator imports (tools/spirv_asm.py, spirv_asm_tables.py, shader_ir.py, mc_command.py, spirv_opt.py, wave64_halves.py, ...), nothing was rebuilt, and the tests kept running the old SPIR-V.

Fix: runtime/cmake/translator_deps.cmake sets LEONIDA_TRANSLATOR_DEPS once. It holds build.py and compute_fixture.py, the tools scripts build.py runs (rdna2spirv.py, plus vk_subgroup_info.py, whose answer selects --bary-fallback), everything those scripts import transitively within tools/ (function-level imports included), and tools/gfx10_formats.json, which rdna2spirv.py reads. CMakeLists.txt includes the file after include(CTest), and every build.py rule now has DEPENDS ${LEONIDA_TRANSLATOR_DEPS} followed by its .asm files. I used an explicit list because the repo doesn't glob sources.

tests/test_cmake_translator_deps.py (new) fails if any of these drift:

  • the list's .py entries must equal the import closure of build.py plus the tools scripts it names, computed with ast, like TranslationSourcesTest does for make_game.TRANSLATION_SOURCES
  • its data files must equal the non-.py entries of TRANSLATION_SOURCES
  • every build.py rule must depend on the list
  • cmake -P must resolve the list to files that exist (skipped without cmake)

Tested

Windows 11, Python 3.11.9, CMake 4.4.5 (pip), Ninja 1.13.2, MSVC 14.29, no GPU needed.

  • python -I tests/test_cmake_translator_deps.py: 5 tests OK (cmake on PATH). On origin/main's CMakeLists, 1 test fails and 3 error. If spirv_asm_tables.py is removed from the list, the closure and stale-helper tests fail.

  • python -I tests/test_cmake_vulkan_missing.py: OK. python -I tests/test_shader_stage_resume.py TranslationSourcesTest: OK.

  • python -I scripts/check_no_game_data.py on all three files: clean.

  • Real configure and Ninja build in a separate build dir. This machine has no llvm-mc, Vulkan SDK or full 10.0.26100 SDK, so I configured with:

    • an empty vulkan/vulkan.h as Vulkan_INCLUDE_DIR
    • placeholder LEONIDA_SPIRV_AS/_VAL paths
    • GTA6RT_SDK_HAS_ROOT_SIGNATURE_1_2=1 preset
    • Python3_EXECUTABLE set to a shim that hands build.py invocations to a stub that writes the same output files (everything else goes to the real Python).

    The CMake rules and the Ninja graph are the real ones; only the translation step is stubbed. I built generated/bindless_shaders/spirv/vs_ids.spv (the edge with no compiled order-only deps), checked that ninja -n reports "no work to do", then touched each tools file and ran ninja -n again:

    touched origin/main this branch
    rdna2spirv.py rebuilds rebuilds
    spirv_asm.py, spirv_asm_tables.py, shader_ir.py, mc_command.py, spirv_opt.py, wave64_halves.py no work to do (stale) rebuilds

    ninja -t query on all 11 translator outputs: 1 tools input each before (rdna2spirv.py), 20 after (19 modules + gfx10_formats.json).

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • No new translator rule, so nothing to add to the contract table of docs/design.md.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/194 **Author:** [@ItsMrDubey](https://github.com/ItsMrDubey) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@ubiquitarianism](https://github.com/ubiquitarianism) **Base:** `main` ← **Head:** `cmake-spirv-translator-deps` --- ### 📝 Commits (1) - [`bc887c4`](https://github.com/ubiquitarianism/leonida/commit/bc887c43669410149523522a920d01d293028b9e) runtime: the build.py shader rules rebuild when any translator module changes ### 📊 Changes **3 files changed** (+142 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+10 -23) ➕ `runtime/cmake/translator_deps.cmake` (+31 -0) ➕ `tests/test_cmake_translator_deps.py` (+101 -0) </details> ### 📄 Description Claimed in the coordination issue as: OLD-3752 (BUILD-1064) (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7119646964) ### What and why Old #3752: the eight `add_custom_command` rules in `runtime/CMakeLists.txt` that run `runtime/test/shaders/build.py` (M1.5, bindless, M2, M2 formats, M3, M4, buffer UAV and the four subgroup cases, 11 Ninja edges) listed only `build.py`, `compute_fixture.py` (bindless didn't list even that), `tools/rdna2spirv.py` and their `.asm` files. If you edited a module the translator imports (`tools/spirv_asm.py`, `spirv_asm_tables.py`, `shader_ir.py`, `mc_command.py`, `spirv_opt.py`, `wave64_halves.py`, ...), nothing was rebuilt, and the tests kept running the old SPIR-V. Fix: `runtime/cmake/translator_deps.cmake` sets `LEONIDA_TRANSLATOR_DEPS` once. It holds build.py and compute_fixture.py, the tools scripts build.py runs (`rdna2spirv.py`, plus `vk_subgroup_info.py`, whose answer selects `--bary-fallback`), everything those scripts import transitively within `tools/` (function-level imports included), and `tools/gfx10_formats.json`, which rdna2spirv.py reads. CMakeLists.txt includes the file after `include(CTest)`, and every build.py rule now has `DEPENDS ${LEONIDA_TRANSLATOR_DEPS}` followed by its `.asm` files. I used an explicit list because the repo doesn't glob sources. `tests/test_cmake_translator_deps.py` (new) fails if any of these drift: - the list's `.py` entries must equal the import closure of build.py plus the tools scripts it names, computed with `ast`, like `TranslationSourcesTest` does for `make_game.TRANSLATION_SOURCES` - its data files must equal the non-`.py` entries of `TRANSLATION_SOURCES` - every build.py rule must depend on the list - `cmake -P` must resolve the list to files that exist (skipped without cmake) ### Tested Windows 11, Python 3.11.9, CMake 4.4.5 (pip), Ninja 1.13.2, MSVC 14.29, no GPU needed. - `python -I tests/test_cmake_translator_deps.py`: 5 tests OK (cmake on PATH). On origin/main's CMakeLists, 1 test fails and 3 error. If `spirv_asm_tables.py` is removed from the list, the closure and stale-helper tests fail. - `python -I tests/test_cmake_vulkan_missing.py`: OK. `python -I tests/test_shader_stage_resume.py TranslationSourcesTest`: OK. - `python -I scripts/check_no_game_data.py` on all three files: clean. - Real configure and Ninja build in a separate build dir. This machine has no llvm-mc, Vulkan SDK or full 10.0.26100 SDK, so I configured with: - an empty `vulkan/vulkan.h` as `Vulkan_INCLUDE_DIR` - placeholder `LEONIDA_SPIRV_AS`/`_VAL` paths - `GTA6RT_SDK_HAS_ROOT_SIGNATURE_1_2=1` preset - `Python3_EXECUTABLE` set to a shim that hands build.py invocations to a stub that writes the same output files (everything else goes to the real Python). The CMake rules and the Ninja graph are the real ones; only the translation step is stubbed. I built `generated/bindless_shaders/spirv/vs_ids.spv` (the edge with no compiled order-only deps), checked that `ninja -n` reports "no work to do", then touched each tools file and ran `ninja -n` again: | touched | origin/main | this branch | |---|---|---| | rdna2spirv.py | rebuilds | rebuilds | | spirv_asm.py, spirv_asm_tables.py, shader_ir.py, mc_command.py, spirv_opt.py, wave64_halves.py | **no work to do** (stale) | rebuilds | `ninja -t query` on all 11 translator outputs: 1 tools input each before (rdna2spirv.py), 20 after (19 modules + gfx10_formats.json). AI-assisted: yes ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] No new translator rule, so nothing to add to the contract table of `docs/design.md`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:15 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#246
No description provided.