rdna2spirv: computed I/J pairs under --bary-fallback (SHADER-COMPUTED-IJ-NO-PERVERTEX) #1426

Open
github-bot wants to merge 2 commits from github-bot/gh-1426 into main AGit
Owner

@⁠Dashhhhhhhh on GitHub · 2026-11-24 23:59 UTC · original
Dashhhhhhhh:fix/computed-ij-no-pervertex → main · +370 −95 · 15 files · 2 commits · open

Claimed in the coordination issue as: SHADER-COMPUTED-IJ-NO-PERVERTEX

Fixes: #1285

What and why

A GPU without PerVertexKHR inputs was translated with only --f16-interp-fallback. Every computed I/J pixel shader was then refused (computed I/J pair under --f16-interp-fallback / --bary-fallback), and the shaders stage stopped at 26,296 of 26,503. That is the RX 5700 XT report in #1285: geometry shaders are present, VK_KHR_fragment_shader_barycentric is not.

--bary-fallback now keeps those attributes. Each one is a Flat vec4[3] at three free locations, recorded as bary_fallback_input.per_vertex. The pass-through geometry shader writes vertex k's value into element k, and the pixel shader weights them the same way as the PerVertexKHR path: P0 + I·(P1 − P0) + J·(P2 − P0). --f16-interp-fallback alone still refuses them. That is the MoltenVK case, which has no geometry stage.

make_game.py turns --bary-fallback on together with --f16-interp-fallback when per_vertex_inputs is false and geometry_shader is true. LEONIDA_BARY_FALLBACK=0 still forces the native path. A GPU with no geometry stage stays on the f16 fallback alone.

This is the translator half of draft #120 (old PR 9855), rebased onto current main because that draft no longer merges, plus the make_game selection #1285 needs. #120 by itself left the automatic f16-only path refusing the same 207 shaders.

Tested

  • python -I scripts/run_semantic_tests.py tests/semantic -p test_interp_computed_ij.py — 28 tests, 0 failed
  • python -I scripts/run_semantic_tests.py tests/semantic -p 'test_interp*.py' — 14 files, 211 tests, 0 failed
  • python -I scripts/run_semantic_tests.py tests/semantic -p 'test_bary*.py' and -p 'test_f16_interp*.py' — 0 failed
  • python -I tests/test_shader_build_fallbacks.py, tests/test_run_gpu_tests.py, tests/test_vk_subgroup_info.py, tests/test_make_game_translator_flags.py, tests/test_make_game_argparse.py, tests/test_make_game_wave64.py
  • No game files. spirv-val is not installed here, so test_geometry_shader_validates was skipped.

GPUs tested: n/a (Apple M4, MoltenVK not installed; the geometry-shader path needs a device with geometry shaders)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

Made with Cursor

**@⁠Dashhhhhhhh** on GitHub · 2026-11-24 23:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1426) `Dashhhhhhhh:fix/computed-ij-no-pervertex` → `main` · +370 −95 · 15 files · 2 commits · open Claimed in the coordination issue as: SHADER-COMPUTED-IJ-NO-PERVERTEX Fixes: #1285 ### What and why A GPU without `PerVertexKHR` inputs was translated with only `--f16-interp-fallback`. Every computed I/J pixel shader was then refused (`computed I/J pair under --f16-interp-fallback` / `--bary-fallback`), and the shaders stage stopped at 26,296 of 26,503. That is the RX 5700 XT report in #1285: geometry shaders are present, `VK_KHR_fragment_shader_barycentric` is not. `--bary-fallback` now keeps those attributes. Each one is a `Flat vec4[3]` at three free locations, recorded as `bary_fallback_input.per_vertex`. The pass-through geometry shader writes vertex k's value into element k, and the pixel shader weights them the same way as the `PerVertexKHR` path: P0 + I·(P1 − P0) + J·(P2 − P0). `--f16-interp-fallback` alone still refuses them. That is the MoltenVK case, which has no geometry stage. `make_game.py` turns `--bary-fallback` on together with `--f16-interp-fallback` when `per_vertex_inputs` is false and `geometry_shader` is true. `LEONIDA_BARY_FALLBACK=0` still forces the native path. A GPU with no geometry stage stays on the f16 fallback alone. This is the translator half of draft #120 (old PR 9855), rebased onto current `main` because that draft no longer merges, plus the `make_game` selection #1285 needs. #120 by itself left the automatic f16-only path refusing the same 207 shaders. ### Tested - `python -I scripts/run_semantic_tests.py tests/semantic -p test_interp_computed_ij.py` — 28 tests, 0 failed - `python -I scripts/run_semantic_tests.py tests/semantic -p 'test_interp*.py'` — 14 files, 211 tests, 0 failed - `python -I scripts/run_semantic_tests.py tests/semantic -p 'test_bary*.py'` and `-p 'test_f16_interp*.py'` — 0 failed - `python -I tests/test_shader_build_fallbacks.py`, `tests/test_run_gpu_tests.py`, `tests/test_vk_subgroup_info.py`, `tests/test_make_game_translator_flags.py`, `tests/test_make_game_argparse.py`, `tests/test_make_game_wave64.py` - No game files. `spirv-val` is not installed here, so `test_geometry_shader_validates` was skipped. GPUs tested: n/a (Apple M4, MoltenVK not installed; the geometry-shader path needs a device with geometry shaders) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. Made with [Cursor](https://cursor.com)
Those pixel shaders were refused under both fallbacks, so the shaders stage stopped on a geometry-capable GPU without fragmentShaderBarycentric. The barycentric fallback now supplies the three vertex values, and make_game selects it there.

Co-authored-by: Cursor <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:51:01 +00:00
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-25 00:15 UTC · original

I ran the computed-I/J fixture on the RTX 4090 (Windows 11, NVIDIA 616.64) at b9191a31, using vk_harness built from that head. The geometry fallback produced the same frame as native barycentric interpolation. I also checked all four channels independently against the fixture's expected RGBA at every pixel.

Mode on PR head Result for vs_ids + ps_ij_computed
Native per-vertex inputs 4,096/4,096 pixels matched bit for bit
Forced --bary-fallback, generated geometry shader bound 4,096/4,096 matched
Forced --bary-fallback --f16-interp-fallback, generated geometry shader bound 4,096/4,096 matched
--f16-interp-fallback alone Builder skipped the fixture as expected

On the PR base 9c5e7066, the fixture builder also skipped it with both fallbacks enabled. On the head, every module used for the three draws passed spirv-val --target-env vulkan1.2. Disassembling the two fallback fragment modules confirmed neither declared the fragment barycentric extension, its capability, or a per-vertex input decoration. The native fragment module declared all three.

All 28 focused CPU/translator tests passed, including test_geometry_shader_validates, with no skips. The RTX supports native barycentrics, so this verifies a forced fallback with synthetic inputs. Automatic selection and the originally reported shader set on the RX 5700 XT still need checking on that setup. AI-assisted verification.

**@⁠ecox982745** on GitHub · 2026-11-25 00:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1426#issuecomment-7148327537) I ran the computed-I/J fixture on the RTX 4090 (Windows 11, NVIDIA 616.64) at `b9191a31`, using `vk_harness` built from that head. The geometry fallback produced the same frame as native barycentric interpolation. I also checked all four channels independently against the fixture's expected RGBA at every pixel. | Mode on PR head | Result for `vs_ids` + `ps_ij_computed` | | --- | --- | | Native per-vertex inputs | 4,096/4,096 pixels matched bit for bit | | Forced `--bary-fallback`, generated geometry shader bound | 4,096/4,096 matched | | Forced `--bary-fallback --f16-interp-fallback`, generated geometry shader bound | 4,096/4,096 matched | | `--f16-interp-fallback` alone | Builder skipped the fixture as expected | On the PR base `9c5e7066`, the fixture builder also skipped it with both fallbacks enabled. On the head, every module used for the three draws passed `spirv-val --target-env vulkan1.2`. Disassembling the two fallback fragment modules confirmed neither declared the fragment barycentric extension, its capability, or a per-vertex input decoration. The native fragment module declared all three. All 28 focused CPU/translator tests passed, including `test_geometry_shader_validates`, with no skips. The RTX supports native barycentrics, so this verifies a forced fallback with synthetic inputs. Automatic selection and the originally reported shader set on the RX 5700 XT still need checking on that setup. AI-assisted verification.
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-25 00:20 UTC · original

Tested b9191a318 on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 364ab4eab (translator/tooling PR; GPU binaries from the build at 66d4f5aa3):

  • tests/semantic/test_interp_computed_ij.py (run from tests/semantic): 28/28 OK at this head; the same file on main errors 12 of 28, so the computed-I/J and bary-fallback cases are new coverage.
  • tests/test_make_game_translator_flags.py, tests/test_run_gpu_tests.py, tests/test_shader_build_fallbacks.py, tests/test_vk_subgroup_info.py: all OK (unittest).
  • GPU: --filter ps_ij_computed still SKIPs by default ("computed I/J pairs need per-vertex inputs: --f16-interp-fallback without --bary-fallback"). Forced with LEONIDA_BARY_FALLBACK=1, the translator emits ps_ij_computed.bary_gs.spv and it passes spirv-val, but the run then SKIPs with unsupported: no geometryShader — Apple's Vulkan drivers have no geometry stage, so this path cannot be executed here (same limitation as #9855).
  • What this does not show: the fallback rendering itself on a GPU with geometry shaders.

AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-25 00:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1426#issuecomment-7148415827) Tested `b9191a318` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `364ab4eab` (translator/tooling PR; GPU binaries from the build at `66d4f5aa3`): - `tests/semantic/test_interp_computed_ij.py` (run from `tests/semantic`): **28/28 OK** at this head; the same file on `main` errors 12 of 28, so the computed-I/J and bary-fallback cases are new coverage. - `tests/test_make_game_translator_flags.py`, `tests/test_run_gpu_tests.py`, `tests/test_shader_build_fallbacks.py`, `tests/test_vk_subgroup_info.py`: all OK (unittest). - GPU: `--filter ps_ij_computed` still SKIPs by default ("computed I/J pairs need per-vertex inputs: --f16-interp-fallback without --bary-fallback"). Forced with `LEONIDA_BARY_FALLBACK=1`, the translator emits `ps_ij_computed.bary_gs.spv` and it passes `spirv-val`, but the run then SKIPs with `unsupported: no geometryShader` — Apple's Vulkan drivers have no geometry stage, so this path cannot be executed here (same limitation as #9855). - What this does not show: the fallback rendering itself on a GPU with geometry shaders. AI-assisted; synthetic fixtures only, no game data.
Author
Owner

@⁠mrgenty on GitHub · 2026-11-26 21:00 UTC · original

This conflicts with main now. I resolved it in #1930's base (merge commit 52d6df8b), in case it saves you time:

  • tools/vk_subgroup_info.py: main added the check that per_vertex counts only when VK_KHR_fragment_shader_barycentric is in the device's extension list (RADV sets the feature on gfx90c without it). I kept that check after your unpack with geometry_shader, and merged the two docstring paragraphs.
  • docs/design.md: in each conflicting row only one side had changed. I took main's "Mixed flat and smooth f32 reads" row and its new "Wave64 emulation: cross-lane reads of missing lanes" row, and your "Computed I/J barycentrics" and "Barycentric fallback" rows.

On that tree (main 73516a29 + #1497 + this PR), on an RTX 3060: test_vk_subgroup_info.py, test_make_game_translator_flags.py and test_interp_computed_ij.py pass, and so does run_semantic_tests.py (498 files, 6,357 tests, 0 failed).

**@⁠mrgenty** on GitHub · 2026-11-26 21:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1426#issuecomment-7203295324) This conflicts with `main` now. I resolved it in #1930's base (merge commit [`52d6df8b`](https://github.com/mrgenty/leonida/commit/52d6df8bd9151ce13f4978aafb03716bb7dcf5ba)), in case it saves you time: - `tools/vk_subgroup_info.py`: `main` added the check that `per_vertex` counts only when `VK_KHR_fragment_shader_barycentric` is in the device's extension list (RADV sets the feature on gfx90c without it). I kept that check after your unpack with `geometry_shader`, and merged the two docstring paragraphs. - `docs/design.md`: in each conflicting row only one side had changed. I took `main`'s "Mixed flat and smooth f32 reads" row and its new "Wave64 emulation: cross-lane reads of missing lanes" row, and your "Computed I/J barycentrics" and "Barycentric fallback" rows. On that tree (`main` `73516a29` + #1497 + this PR), on an RTX 3060: `test_vk_subgroup_info.py`, `test_make_game_translator_flags.py` and `test_interp_computed_ij.py` pass, and so does `run_semantic_tests.py` (498 files, 6,357 tests, 0 failed).
This pull request has changes conflicting with the target branch.
  • docs/design.md
  • tools/vk_subgroup_info.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1426/head:github-bot/gh-1426'
git switch 'github-bot/gh-1426'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1426'
git switch 'github-bot/gh-1426'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1426'
git switch 'github-bot/gh-1426'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1426'
git switch 'main'
git merge --squash 'github-bot/gh-1426'
git switch 'main'
git merge --ff-only 'github-bot/gh-1426'
git switch 'main'
git merge 'github-bot/gh-1426'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.