Skip to content

runtime: track RDNA2 shader compiler inputs (BUILD-1064) - #3758

Open
lumenpearson wants to merge 2 commits into
ItsNotRexed:mainfrom
lumenpearson:dev/leonida-shader-build-deps
Open

lumenpearson wants to merge 2 commits into
ItsNotRexed:mainfrom
lumenpearson:dev/leonida-shader-build-deps

Conversation

@lumenpearson

Copy link
Copy Markdown
Contributor

Fixes #3752. Claimed as BUILD-1064 in #3574.

Share the local Python and format-table dependencies across the CMake commands that build synthetic RDNA2 shaders. Each command still lists its own .asm files. A translator helper change now makes the affected SPIR-V and index outputs stale.

Verified all 10 generated rules with CMake 3.31.6 on Windows, for Ninja and Visual Studio 2022. In the generated Ninja graph the M1.5 and wave64-emulated subgroup shader outputs rebuilt after touching lane_masks.py, gfx10_formats.json or compute_fixture.py. A fixture-only change rebuilt its own target, and an unrelated script or a warm build rebuilt neither. The real Python shader build and SPIRV-Tools 2026.4 assembled and validated three modules using synthetic LLVM listings. 31 focused tests passed.

AI-assisted (Codex). No game files.

@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Second check on Windows at 39f2ca8. I used the seven changed dependency lists in compiler-free CMake/Ninja scratch projects, replacing the shader command with a stamp writer. An unchanged rebuild had no work on either revision. Updating only gfx10_formats.json queued 0 of 7 shader rules on the parent and 7 of 7 on this head. Updating only cs_m4_fill.asm still queued just the M4 rule on both. I also checked that the translator loads the formats JSON at startup. The test exercised the dependency graph with synthetic files. It did not compile shaders or use a GPU.

AI-assisted.

@kotorvr

kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 39f2ca8 on Windows 11 Home 26200, CMake 4.4.3 (VS 2022's bundled CMake) with Ninja, MSVC 19.44, RelWithDebInfo, the full runtime with llvm-mc 21.1.8 and SDL3 (all 10 translate rules present): pass. The machine's GPU (RTX 4090, 621.14) runs the tests in the last row.

Same tree, main f847748 first, then this branch. Each row is one cmake --build after the step named; "rules run" counts the Translating ... steps Ninja ran.

step main f847748 39f2ca8
first build after switching 0 9 (the new dependency list makes the old outputs stale once)
second build, nothing changed 0 0
touch tools/lane_masks.py 0 (outputs stay stale) 10: all four subgroup-size variants, M1.5, M2 textured, M2 formats, M3, M4, buffer UAV
touch tools/gfx10_formats.json 0 the same 10
touch runtime/test/shaders/ps_m2_uoff.asm 1 (M2 textured only) 1 (M2 textured only)

So the fix does what it says on Ninja: a helper change now reaches every rule, a fixture change still reaches only its own target, and a warm build runs none. I did not check the Visual Studio generator or compute_fixture.py.

After the rebuilds, ctest -R "d3d12_m2|d3d12_m3|d3d12_m4|translated_draw|buffer_uav|subgroup_size" on the branch: 8/8 (d3d12_translated_draw, d3d12_m2_textured, d3d12_m2_formats, d3d12_m3_frame, d3d12_m3_first_pass, d3d12_m4_compute, d3d12_buffer_uav, subgroup_size).

One note for the M2 formats rule: it still passes PATH=...;$ENV{PATH}, which #3210 changes; the two touch neighbouring lines of the same rule. No game files. AI-assisted check (Claude Code).

@kapitche

kapitche commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Tested on Windows 11 (MSVC 14.51, Ninja, RelWithDebInfo; head merged with main aa2988c, clean merge). This one needed a build-graph check rather than a GPU run, so I looked at whether the shader steps now follow the Python inputs:

  • Built generated/m2_shaders, m3_shaders and buffer_uav_shaders (spirv/index.json) from the head. An unchanged rebuild: 0 steps.
  • Then touched, one at a time, tools/wave64_halves.py, tools/shader_meta.py, tools/gfx10_formats.json, tools/lane_masks.py and tools/bary_fallback_gs.py (five of the newly listed inputs), and ran ninja -n after each: 3 steps each time (the three shader targets regenerate).
  • Negative control: with runtime/CMakeLists.txt reverted to main, the same five touches give 0 steps, so on main an edit to any of them leaves stale SPIR-V in the build tree.
  • d3d12_compute and d3d12_draw (built from these shaders) pass on the RTX 4080 SUPER (I did not run them on the Intel UHD 770; the change is to the build graph, not to what the shaders do).

I did not check all seven dependency lists, only these three targets and five inputs. No concerns.

@iurysf

iurysf commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Code read of c189ef14. LEONIDA_RDNA2_TEST_SHADER_DEPS is shared by the ten build.py custom commands (M1.5, M2, M2F, M3, M4, buffer UAV and the three subgroup variants). Configured runtime with Ninja (CMake 3.31, LLVM_MC set) on this head and on main, no build: in the generated build.ninja, all 10 edges list lane_masks.py, gfx10_formats.json, compute_fixture.py, wave64_halves.py, shader_ir.py and cfg_structure.py with the PR, while on main none lists the first five and four of the ten miss compute_fixture.py. Every path in the list exists, and the import closure of build.py plus rdna2spirv.py is covered except tools/spirv_asm.py and spirv_asm_tables.py, which are only imported with --assembler python (not used by these rules today). Not run: the full build, the Visual Studio generator.
AI-assisted code read (Claude).

@Etoile-Bleu

Copy link
Copy Markdown
Contributor

Tested c189ef1467ae merged into main 03b09a086592 on Windows 11 (10.0.26200), Python 3.13.13, CMake 4.2.0-rc3, Ninja 1.13.2, MSVC 19.44, llvm-mc 21.1.8, SPIRV-Tools v2026.4: pass.

  • Configured runtime/ with Ninja in a separate build directory for main and for the merged tree, and built the M1.5 index (generated/m15_shaders/spirv/index.json) and the wave64-emulated subgroup index (generated/subgroup_shaders/w64_emulated/spirv/index.json) with the real build.py (both pass spirv-val). Then touched one file and ran ninja -n on both outputs.
  • Main: touching tools/lane_masks.py or tools/gfx10_formats.json gives ninja: no work to do (stale outputs, the issue); touching runtime/test/shaders/compute_fixture.py rebuilds only the M1.5 index, not the subgroup one.
  • Merged tree: each of those three touches rebuilds both outputs (2 of 2 steps); a warm build and touching docs/design.md, tools/spirv_asm.py or tools/vk_subgroup_info.py give no work to do. gfx10_formats.json appears in all 10 generated shader rules in build.ninja (0 on main).
  • test_ci_registration.py 8 OK, test_ctest_registration.py 4 OK, test_cmake_vulkan_missing.py 5 OK, test_build_runtime_fallback.py 4 OK, test_build_runtime_batch.py 1 OK. Only the Ninja generator was tried, not Visual Studio; no GPU used.

No game files used. AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CMake reuses stale SPIR-V after a translator helper changes (BUILD-1064)

6 participants