Translator: computed I/J pairs under --bary-fallback (per-vertex values from the geometry shader) #120

Closed
Andretuta wants to merge 2 commits from upstream-pr/120 into main
Andretuta commented 2026-11-24 02:22:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:22:55Z.


Carried over from old PR 9855 by Jess-Doit in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9855, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
Jess-Doit: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Resubmission of #3898, which was closed in the move to ProjectLeonida with no change requested. Same branch, same change, now on main 867d922f; it merges onto current main with no conflicts. The test reports and discussion are on #3898.

Item: SHADER-415 (claim). Overlaps #3332 (SHADER-574, also closed in the move); see the comparison on #3898. AI-assisted (Claude Code).

What changed

Under --bary-fallback, the translator refused every PS with a computed I/J pair (SHADER-177): "computed I/J pair under --bary-fallback: no PerVertexKHR inputs".

  • New behaviour: such an attribute becomes a Flat vec4[3] at the lowest three consecutive free locations, recorded in the index as bary_fallback_input.per_vertex (attribute → first location). inputs keeps the attribute's own number, which is the producer's location.
  • Geometry shader: tools/bary_fallback_gs.py writes vertex k's value into element k at each of the three vertices it emits. The PS weights the three values exactly as on the PerVertexKHR path: P0 + I·(P1 − P0) + J·(P2 − P0).
  • Both fallbacks: with --f16-interp-fallback as well (NVIDIA Pascal gets both by default), a computed attribute's 16-bit reads decode the array's raw words and leave f16_halves. The f16 fallback alone still refuses; that's the Mac/MoltenVK case, with no geometry stage, noted in docs/testing.md's Known problems.
  • v_interp_mov_f32: p0 reads element 0 of the array. p10/p20 (vertex_delta) read the array's deltas. A mixed flat/smooth attribute that isn't a computed pair is still refused.
  • Test scripts: build.py, check.py and run_gpu_tests.py skip ps_ij_computed only under the f16 fallback without the barycentric fallback, using barycentric_fallback() / BARY_FALLBACK, Mesa ANV probe included.
  • Docs and tests: docs/design.md and docs/testing.md are updated. ComputedIJBaryFallback in tests/semantic/test_interp_computed_ij.py checks:

Why it matters on old GPUs: on a GPU without VK_KHR_fragment_shader_barycentric, make_game.py picks --bary-fallback. main then refuses these 207 shaders, and the shaders stage stops on its count check ("the translation index holds 26296 of the 26503 carved shaders"). So the build can't finish on such a GPU without this fix. I reproduced that today on my GTX 1060, and @Davidutz19 hit the same on theirs (#3898).

Tested

  • Mine, GTX 1060 6GB (Pascal, driver 560.94, Windows 10), at b52b7296:
  • Corpus, game's 10,277 v_interp PS, main vs this change:
  • Independent runs on #3898, about 17:

No game data.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464878995 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/120). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:22:55Z. --- > Carried over from **old PR 9855** by `Jess-Doit` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9855`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `Jess-Doit`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Resubmission of `#3898`, which was closed in the move to ProjectLeonida with no change requested. Same branch, same change, now on `main` `867d922f`; it merges onto current `main` with no conflicts. The test reports and discussion are on `#3898`. Item: SHADER-415 ([claim](https://github.com/ProjectLeonida/Leonida/issues/1745#issuecomment-7082218877)). Overlaps `#3332` (SHADER-574, also closed in the move); see the comparison on `#3898`. AI-assisted (Claude Code). **What changed** Under `--bary-fallback`, the translator refused every PS with a computed I/J pair (SHADER-177): "computed I/J pair under --bary-fallback: no PerVertexKHR inputs". - **New behaviour:** such an attribute becomes a `Flat vec4[3]` at the lowest three consecutive free locations, recorded in the index as `bary_fallback_input.per_vertex` (attribute → first location). `inputs` keeps the attribute's own number, which is the producer's location. - **Geometry shader:** `tools/bary_fallback_gs.py` writes vertex k's value into element k at each of the three vertices it emits. The PS weights the three values exactly as on the `PerVertexKHR` path: P0 + I·(P1 − P0) + J·(P2 − P0). - **Both fallbacks:** with `--f16-interp-fallback` as well (NVIDIA Pascal gets both by default), a computed attribute's 16-bit reads decode the array's raw words and leave `f16_halves`. The f16 fallback alone still refuses; that's the Mac/MoltenVK case, with no geometry stage, noted in `docs/testing.md`'s Known problems. - **`v_interp_mov_f32`:** `p0` reads element 0 of the array. `p10`/`p20` (`vertex_delta`) read the array's deltas. A mixed flat/smooth attribute that isn't a computed pair is still refused. - **Test scripts:** `build.py`, `check.py` and `run_gpu_tests.py` skip `ps_ij_computed` only under the f16 fallback without the barycentric fallback, using `barycentric_fallback()` / `BARY_FALLBACK`, Mesa ANV probe included. - **Docs and tests:** `docs/design.md` and `docs/testing.md` are updated. `ComputedIJBaryFallback` in `tests/semantic/test_interp_computed_ij.py` checks: **Why it matters on old GPUs:** on a GPU without `VK_KHR_fragment_shader_barycentric`, `make_game.py` picks `--bary-fallback`. `main` then refuses these 207 shaders, and the shaders stage stops on its count check ("the translation index holds 26296 of the 26503 carved shaders"). So **the build can't finish on such a GPU without this fix.** I reproduced that today on my GTX 1060, and `@Davidutz19` hit the same on theirs (`#3898`). **Tested** - **Mine,** GTX 1060 6GB (Pascal, driver 560.94, Windows 10), at `b52b7296`: - **Corpus, game's 10,277 `v_interp` PS,** `main` vs this change: - **Independent runs on `#3898`,** about 17: No game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
GGandCo commented 2026-11-24 21:27:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by GGandCo on 2026-11-24T21:27:25Z.


Independent targeted check of the c99ad0182 change on a private copy of current PR984 translator/tools (the four translator/helper/semantic files apply cleanly), native Windows, Intel UHD Graphics / i5-1334U, Intel 101.6314, subgroup 8..32:

  • tests/semantic/test_interp_computed_ij.py: 28 tests pass.
  • Built synthetic vs_ids + ps_ij_computed with LEONIDA_BARY_FALLBACK=1 and LEONIDA_F16_INTERP_FALLBACK=1, using the new geometry helper. Both modules pass spirv-val.
  • Actual Vulkan readback through vk_harness: all 4096 pixels match ij_computed_problem, including snapped, zeroed, modified and control weights.

Not a full-corpus recount or retail-rendering confirmation. An independently captured missing PS now translates and validates, but remains wave64 graphics tier C (tainted-exec), a separate limitation on this <=32-wide GPU; I have not installed that module as a claimed rendering fix. No game data included. The long Windows path failed in spirv-as while building the helper; a short private output directory works. AI-assisted verification, no competing implementation/PR.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7144953518 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/120#issuecomment-7144953518). Originally posted by [GGandCo](https://github.com/GGandCo) on 2026-11-24T21:27:25Z. --- Independent targeted check of the c99ad0182 change on a private copy of current PR984 translator/tools (the four translator/helper/semantic files apply cleanly), native Windows, Intel UHD Graphics / i5-1334U, Intel 101.6314, subgroup 8..32: - tests/semantic/test_interp_computed_ij.py: 28 tests pass. - Built synthetic vs_ids + ps_ij_computed with LEONIDA_BARY_FALLBACK=1 and LEONIDA_F16_INTERP_FALLBACK=1, using the new geometry helper. Both modules pass spirv-val. - Actual Vulkan readback through vk_harness: all 4096 pixels match ij_computed_problem, including snapped, zeroed, modified and control weights. Not a full-corpus recount or retail-rendering confirmation. An independently captured missing PS now translates and validates, but remains wave64 graphics tier C (tainted-exec), a separate limitation on this <=32-wide GPU; I have not installed that module as a claimed rendering fix. No game data included. The long Windows path failed in spirv-as while building the helper; a short private output directory works. AI-assisted verification, no competing implementation/PR.
MoonEyes commented 2026-11-30 13:59:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T13:59:04Z.


Closing this draft as superseded by #1426 (open, by Dashhhhhhhh): compared line by line, 1 of the 274 lines this head (6cfe5ef1b) adds are missing there, in the same files. Nothing here is judged wrong, and a conflict is not the reason. Please reopen it if #1426 does not land or leaves something out.

AI-assisted (Claude Code). Closed at the owner's request (MoonEyes), superseded pull requests being fine to close (aslan2142).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7280657717 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/120#issuecomment-7280657717). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-30T13:59:04Z. --- Closing this draft as superseded by #1426 (open, by Dashhhhhhhh): compared line by line, 1 of the 274 lines this head (`6cfe5ef1b`) adds are missing there, in the same files. Nothing here is judged wrong, and a conflict is not the reason. Please reopen it if #1426 does not land or leaves something out. AI-assisted (Claude Code). Closed at the owner's request (MoonEyes), superseded pull requests being fine to close (aslan2142).

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!120
No description provided.