[PR #1073] [CLOSED] rdna2spirv: compact SPIR-V modules on request (SHADER-COMPACT-SPIRV) #1109

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1073
Author: @Moriz82
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: split/shader-compact-spirv


📝 Commits (1)

  • 363fed0 rdna2spirv: compact SPIR-V modules on request (SHADER-COMPACT-SPIRV)

📊 Changes

2 files changed (+4 additions, -0 deletions)

View changed files

📝 docs/design.md (+1 -0)
📝 tests/test_make_game_translator_flags.py (+3 -0)

📄 Description

Rebased onto bfef489c at 363fed0f. Main already exposes SPIR-V compaction. This diff adds the contract row and tests that the build command forwards the flag. The two focused suites ran 49 cases with five Windows-only skips.

Claimed in the coordination issue as: SHADER-COMPACT-SPIRV (claim).

Part of the split of #984 into small pull requests.

Depends on: none
Overlaps: #984 is the parent integration. #544 changes the existing Python optimizer. The two options can run independently. A merge-tree check against #1068 also completed without conflicts.

What and why

The translator and shader build rejected --compact-spirv on Linux. To try smaller modules, a developer had to run the optimizer separately and validate the result again. This adds the option to both entry points. It runs local load elimination, redundancy elimination and dead-code elimination on the assembled staging file before the normal validation and publication step. It preserves stage interfaces, descriptor bindings and specialization constants. Compaction is off by default. Only an opted-in build needs spirv-opt.

A hand-written pixel program produced a 4,076-byte module by default and a 908-byte module with compaction. Both the Python assembler and spirv-as produced those sizes. All four outputs passed Vulkan 1.2 validation and had matching shader index metadata. This is a synthetic size comparison.

Tested

Ran the compiler tests on Linux and cross-built the Windows runtime.

Applied only the two test additions to pristine main 32950551e, then ran the same commands on this child:

Command Main plus tests Child
python3 -I tests/test_native_tool_paths.py AssembleSpirv.test_compact_binary_before_publish 1 error. The assembler function rejected the compact keyword. 1 passed
python3 -I tests/test_make_game_translator_flags.py MainWiringTest.test_compact_spirv_reaches_the_shaders_stage 1 error. The build CLI rejected --compact-spirv. 1 passed
Command or check Child result
python3 -I tests/test_native_tool_paths.py 8 passed, 5 Windows-only skips
python3 -I tests/test_make_game_translator_flags.py 34 passed
python3 -I tests/test_run_gpu_tests_python_assembler.py 10 passed
python3 -I scripts/run_semantic_tests.py tests/semantic -j 2 6,168 tests in 470 files, zero failing files. Standalone run 643 s, full CI repeat 455 s.
python3 -I -m compileall -q make_game.py tools tests Passed
Python CI loop over 520 nonsemantic files, using python3 -I <file> or python3 -I -m pytest -q <file> One failing file on each tree, tests/test_imhex_patterns.py. The same 6 of its 9 tests failed. Zero new failing files.
python3 -I scripts/check_no_game_data.py Passed, 2,457 tracked entries
cmake -S runtime -B runtime/build/boot and cmake --build runtime/build/boot --target gta6rt -j6 Linked the x86-64 Windows executable using the configured cross-toolchain.

On a second synthetic module, spirv-dis retained the location, descriptor set, binding and specialization ID after compaction, and the dead add disappeared. An optimizer failure took the existing rejection path and left zero stale modules or staging files. With spirv-opt absent, the default CLI succeeded and the compact CLI reported the missing tool with exit code 2.

GPUs tested: none. The tests ran on the CPU. Native Windows, Wine, AMD GPU and Intel GPU runs were not performed.

AI-assisted: yes

Checklist

  • Based on upstream main at the cut, 32950551e. Merged cleanly in a temporary checkout of the newer 3aa975421. The native tool paths, build flag and build destination suites ran 56 cases there, with 51 passes and five Windows-only skips.
  • One topic in one commit.
  • Synthetic inputs and a passing game-data check.
  • The SPIR-V compaction contract and its confirmation are in the translator contract table in docs/design.md.

🤖 Generated with Claude Code


🔄 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/1073 **Author:** [@Moriz82](https://github.com/Moriz82) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `split/shader-compact-spirv` --- ### 📝 Commits (1) - [`363fed0`](https://github.com/ubiquitarianism/leonida/commit/363fed0f1f735239843dda5efd0e8379f6c381ee) rdna2spirv: compact SPIR-V modules on request (SHADER-COMPACT-SPIRV) ### 📊 Changes **2 files changed** (+4 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -0) 📝 `tests/test_make_game_translator_flags.py` (+3 -0) </details> ### 📄 Description **Rebased onto `bfef489c` at `363fed0f`.** Main already exposes SPIR-V compaction. This diff adds the contract row and tests that the build command forwards the flag. The two focused suites ran 49 cases with five Windows-only skips. Claimed in the coordination issue as: SHADER-COMPACT-SPIRV ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7139774662)). Part of the split of #984 into small pull requests. Depends on: none Overlaps: #984 is the parent integration. #544 changes the existing Python optimizer. The two options can run independently. A merge-tree check against #1068 also completed without conflicts. ### What and why The translator and shader build rejected `--compact-spirv` on Linux. To try smaller modules, a developer had to run the optimizer separately and validate the result again. This adds the option to both entry points. It runs local load elimination, redundancy elimination and dead-code elimination on the assembled staging file before the normal validation and publication step. It preserves stage interfaces, descriptor bindings and specialization constants. Compaction is off by default. Only an opted-in build needs `spirv-opt`. A hand-written pixel program produced a 4,076-byte module by default and a 908-byte module with compaction. Both the Python assembler and `spirv-as` produced those sizes. All four outputs passed Vulkan 1.2 validation and had matching shader index metadata. This is a synthetic size comparison. ### Tested Ran the compiler tests on Linux and cross-built the Windows runtime. Applied only the two test additions to pristine main `32950551e`, then ran the same commands on this child: | Command | Main plus tests | Child | |---|---|---| | `python3 -I tests/test_native_tool_paths.py AssembleSpirv.test_compact_binary_before_publish` | 1 error. The assembler function rejected the `compact` keyword. | 1 passed | | `python3 -I tests/test_make_game_translator_flags.py MainWiringTest.test_compact_spirv_reaches_the_shaders_stage` | 1 error. The build CLI rejected `--compact-spirv`. | 1 passed | | Command or check | Child result | |---|---| | `python3 -I tests/test_native_tool_paths.py` | 8 passed, 5 Windows-only skips | | `python3 -I tests/test_make_game_translator_flags.py` | 34 passed | | `python3 -I tests/test_run_gpu_tests_python_assembler.py` | 10 passed | | `python3 -I scripts/run_semantic_tests.py tests/semantic -j 2` | 6,168 tests in 470 files, zero failing files. Standalone run 643 s, full CI repeat 455 s. | | `python3 -I -m compileall -q make_game.py tools tests` | Passed | | Python CI loop over 520 nonsemantic files, using `python3 -I <file>` or `python3 -I -m pytest -q <file>` | One failing file on each tree, `tests/test_imhex_patterns.py`. The same 6 of its 9 tests failed. Zero new failing files. | | `python3 -I scripts/check_no_game_data.py` | Passed, 2,457 tracked entries | | `cmake -S runtime -B runtime/build/boot` and `cmake --build runtime/build/boot --target gta6rt -j6` | Linked the x86-64 Windows executable using the configured cross-toolchain. | On a second synthetic module, `spirv-dis` retained the location, descriptor set, binding and specialization ID after compaction, and the dead add disappeared. An optimizer failure took the existing rejection path and left zero stale modules or staging files. With `spirv-opt` absent, the default CLI succeeded and the compact CLI reported the missing tool with exit code 2. GPUs tested: none. The tests ran on the CPU. Native Windows, Wine, AMD GPU and Intel GPU runs were not performed. AI-assisted: yes ### Checklist - [x] Based on upstream main at the cut, `32950551e`. Merged cleanly in a temporary checkout of the newer `3aa975421`. The native tool paths, build flag and build destination suites ran 56 cases there, with 51 passes and five Windows-only skips. - [x] One topic in one commit. - [x] Synthetic inputs and a passing game-data check. - [x] The SPIR-V compaction contract and its confirmation are in the translator contract table in `docs/design.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:20:07 +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#1109
No description provided.