runtime/d3d12: the --bary-fallback geometry stage feeds computed I/J pairs (RT-BARY-FALLBACK-PER-VERTEX) #1930

Open
github-bot wants to merge 7 commits from github-bot/gh-1930 into main AGit
Owner

@⁠mrgenty on GitHub · 2026-11-25 16:02 UTC · original
mrgenty:rt-bary-fallback-per-vertex → main · +2879 −108 · 24 files · 7 commits · open

Claimed in the coordination issue as: RT-BARY-FALLBACK-PER-VERTEX (#1608)

Depends on: #1497, #1426

What and why

The runtime half of the computed-I/J case of #1285, which #1497 leaves out (finding, confirmed in the reviews of #1497).

With --bary-fallback, #1426 translates a pixel shader that has a computed I/J pair so that the pair's attribute is a Flat vec4[3] input, at the first of three locations the index gives as bary_fallback_input.per_vertex (attribute → first location). #1497's builder reads only bary_fallback_input.location and expects every other PS input to be a vec4, so it refuses such a PS before the draw (PS pass-through Input at Location 0 is not vec4<f32>) and the PSO is never created.

This branch is main + #1497 + #1426 + one commit. Only the last commit, 07d06992, is this pull request; the rest of the diff goes away as those two land. #1426 conflicted with main in one docs/design.md row and I took its side, which is main's text plus its additions.

The commit:

  • runtime/src/shader_library.h: parses per_vertex into ShaderEntry::bary_fallback_per_vertex. Keys and values are exact u32s; one malformed entry drops the whole map, so the builder refuses the array instead of linking part of a mapping.
  • runtime/src/spirv_bary_fallback.h: build_bary_fallback_gs takes the map. For each mapped attribute the PS declares, the geometry stage reads the VS output at the attribute's number and writes the triangle's three values to a Flat vec4[3] output at the first location (element k = vertex k, the same at each of the three vertices it emits), as tools/bary_fallback_gs.py does. The three values are loaded once. An attribute the VS does not export is zero-filled, like an ordinary pass-through input. One GS input per VS location, shared when the PS also reads that location as an ordinary input.
    Refused: a vec4[3] input the map does not name, a mapped location that is not vec4<f32>[3], a block that runs into another PS input or the barycentric location, two attributes at one first location, and a block past the last location. A mapping the PS does not declare is ignored. The six-argument signature stays as a wrapper with an empty map.
  • runtime/shims/d3d12_vulkan_device.cpp: the two call sites (create_graphics and the lazy stage_words) pass the entry's map.
  • docs/design.md: the runtime builder in the "Barycentric fallback" row, with what was checked and what was not.

Tested

Native Windows 11 (build 26300), MSVC 19.44 RelWithDebInfo, Vulkan SDK 1.4.363.0. No game files.

  • ctest -C RelWithDebInfo -R "^(shader_library|spirv_bary_fallback|d3d12_bary_fallback)$": 3/3 pass, and again with LEONIDA_VK_VALIDATION=1; d3d12_bary_fallback also with LEONIDA_LAZY_GRAPHICS=0 and =1 under validation (the test fails on any validation error).
  • spirv_bary_fallback (CPU), five new cases: the block at the attribute's first locations, a relocated block next to ordinary inputs with a shared GS input, two attributes with one zero-filled, an undeclared mapping (module identical to the one built without it), and six refusals that leave the caller's words untouched.
  • spirv-val --target-env vulkan1.2 and vulkan1.3 on all 9 modules spirv_bary_fallback_test --dump-dir writes (the 6 from #1497 and 3 new): 18/18 clean.
  • shader_library, twelve new per_vertex parsing cases (non-numeric, signed and out-of-range keys; negative, fractional, string and overflowing values; two keys for one attribute; an array instead of an object).
  • d3d12_bary_fallback (GPU), new draws 5a–5c through the Xbox-ABI proxy: a VS that gives each vertex a different value, and a PS in the shape #1426 emits that weights the three with its own I/J (0.375, 0.5, 0.125). All 256 pixels match with the block at locations 0..2 and with it relocated to 4..6 next to an ordinary input; the barycentric channel is still the perspective-correct one. The same weights on any other order of the three vertices would be at least 15 LSB away (the test asserts that margin). The same PS with no per_vertex in its index entry is refused with E_FAIL.
  • python -I scripts/check_no_game_data.py on the touched files, tests/test_bary_fallback_gs.py, tests/test_ctest_registration.py, tests/test_docs_links.py, tests/test_docs_table_rows.py, git diff --check.

Not tested:

  • The game's 207 computed-I/J pixel shaders through this builder: the tests use hand-built SPIR-V in the same shape, not translated shaders. No retail run.
  • A GPU that needs the fallback (RX 5700 XT, Pascal). The RTX 3060 has fragmentShaderBarycentric; the test drives the fallback path on it directly. A run of d3d12_bary_fallback on such a card would be welcome.
  • ps_ij_computed from #1426 translated by rdna2spirv.py and drawn through the runtime (no llvm-mc with the AMDGPU target on this machine).
  • The rest of the runtime suite: only the three tests above were built and run.
  • A computed pair together with --f16-interp-fallback relocation in one PSO.

GPUs tested: NVIDIA GeForce RTX 3060, driver 621.24, Windows 11 (10.0.26300)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase). — based on main b0f3d399 plus #1497 and #1426; it will need a rebase as those land.
  • 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. — no translator rule; the runtime behaviour is recorded in the "Barycentric fallback" row.

🤖 Generated with Claude Code

**@⁠mrgenty** on GitHub · 2026-11-25 16:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930) `mrgenty:rt-bary-fallback-per-vertex` → `main` · +2879 −108 · 24 files · 7 commits · open Claimed in the coordination issue as: RT-BARY-FALLBACK-PER-VERTEX (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) Depends on: #1497, #1426 ### What and why The runtime half of the computed-I/J case of #1285, which #1497 leaves out ([finding](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14), confirmed in the reviews of #1497). With `--bary-fallback`, #1426 translates a pixel shader that has a computed I/J pair so that the pair's attribute is a `Flat` `vec4[3]` input, at the first of three locations the index gives as `bary_fallback_input.per_vertex` (attribute → first location). #1497's builder reads only `bary_fallback_input.location` and expects every other PS input to be a `vec4`, so it refuses such a PS before the draw (`PS pass-through Input at Location 0 is not vec4<f32>`) and the PSO is never created. **This branch is `main` + #1497 + #1426 + one commit.** Only the last commit, `07d06992`, is this pull request; the rest of the diff goes away as those two land. #1426 conflicted with `main` in one `docs/design.md` row and I took its side, which is `main`'s text plus its additions. The commit: - `runtime/src/shader_library.h`: parses `per_vertex` into `ShaderEntry::bary_fallback_per_vertex`. Keys and values are exact `u32`s; one malformed entry drops the whole map, so the builder refuses the array instead of linking part of a mapping. - `runtime/src/spirv_bary_fallback.h`: `build_bary_fallback_gs` takes the map. For each mapped attribute the PS declares, the geometry stage reads the VS output at the attribute's number and writes the triangle's three values to a `Flat` `vec4[3]` output at the first location (element k = vertex k, the same at each of the three vertices it emits), as `tools/bary_fallback_gs.py` does. The three values are loaded once. An attribute the VS does not export is zero-filled, like an ordinary pass-through input. One GS input per VS location, shared when the PS also reads that location as an ordinary input. Refused: a `vec4[3]` input the map does not name, a mapped location that is not `vec4<f32>[3]`, a block that runs into another PS input or the barycentric location, two attributes at one first location, and a block past the last location. A mapping the PS does not declare is ignored. The six-argument signature stays as a wrapper with an empty map. - `runtime/shims/d3d12_vulkan_device.cpp`: the two call sites (`create_graphics` and the lazy `stage_words`) pass the entry's map. - `docs/design.md`: the runtime builder in the "Barycentric fallback" row, with what was checked and what was not. ### Tested Native Windows 11 (build 26300), MSVC 19.44 `RelWithDebInfo`, Vulkan SDK 1.4.363.0. No game files. - `ctest -C RelWithDebInfo -R "^(shader_library|spirv_bary_fallback|d3d12_bary_fallback)$"`: 3/3 pass, and again with `LEONIDA_VK_VALIDATION=1`; `d3d12_bary_fallback` also with `LEONIDA_LAZY_GRAPHICS=0` and `=1` under validation (the test fails on any validation error). - `spirv_bary_fallback` (CPU), five new cases: the block at the attribute's first locations, a relocated block next to ordinary inputs with a shared GS input, two attributes with one zero-filled, an undeclared mapping (module identical to the one built without it), and six refusals that leave the caller's words untouched. - `spirv-val --target-env vulkan1.2` and `vulkan1.3` on all 9 modules `spirv_bary_fallback_test --dump-dir` writes (the 6 from #1497 and 3 new): 18/18 clean. - `shader_library`, twelve new `per_vertex` parsing cases (non-numeric, signed and out-of-range keys; negative, fractional, string and overflowing values; two keys for one attribute; an array instead of an object). - `d3d12_bary_fallback` (GPU), new draws 5a–5c through the Xbox-ABI proxy: a VS that gives each vertex a different value, and a PS in the shape #1426 emits that weights the three with its own I/J (0.375, 0.5, 0.125). All 256 pixels match with the block at locations 0..2 and with it relocated to 4..6 next to an ordinary input; the barycentric channel is still the perspective-correct one. The same weights on any other order of the three vertices would be at least 15 LSB away (the test asserts that margin). The same PS with no `per_vertex` in its index entry is refused with `E_FAIL`. - `python -I scripts/check_no_game_data.py` on the touched files, `tests/test_bary_fallback_gs.py`, `tests/test_ctest_registration.py`, `tests/test_docs_links.py`, `tests/test_docs_table_rows.py`, `git diff --check`. **Not tested:** - The game's 207 computed-I/J pixel shaders through this builder: the tests use hand-built SPIR-V in the same shape, not translated shaders. No retail run. - A GPU that needs the fallback (RX 5700 XT, Pascal). The RTX 3060 has `fragmentShaderBarycentric`; the test drives the fallback path on it directly. A run of `d3d12_bary_fallback` on such a card would be welcome. - `ps_ij_computed` from #1426 translated by `rdna2spirv.py` and drawn through the runtime (no `llvm-mc` with the AMDGPU target on this machine). - The rest of the runtime suite: only the three tests above were built and run. - A computed pair together with `--f16-interp-fallback` relocation in one PSO. GPUs tested: NVIDIA GeForce RTX 3060, driver 621.24, Windows 11 (10.0.26300) AI-assisted: yes (Claude Code) ### Checklist - [ ] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). — based on `main` `b0f3d399` plus #1497 and #1426; it will need a rebase as those land. - [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. — no translator rule; the runtime behaviour is recorded in the "Barycentric fallback" row. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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]>
When a translated pixel shader carries `"bary_fallback_input": {"location": N}`
in `spirv/index.json` (`rdna2spirv.py --bary-fallback` for GPUs without
`VK_KHR_fragment_shader_barycentric`), `PipelineState::create_graphics` now
synthesizes the triangle pass-through Geometry SPIR-V 1.5 module in memory
(`leonida::build_bary_fallback_gs` in `runtime/src/spirv_bary_fallback.h`)
after `--f16-interp-fallback` VS/PS location linking:

- Parses `bary_fallback_input.location` in `ShaderLibrary::load_index` into
  `ShaderEntry::bary_fallback_location`.
- Copies `BuiltIn Position` and every `vec4<f32>` `Location` input read by the
  PS (other than `bary_location`) that the VS exports, while zero-filling any
  unexported PS `Location` input without declaring a dangling GS `Input` and
  leaving unread VS outputs unconsumed (`VUID-RuntimeSpirv-OpEntryPoint-08743`).
- Forwards a VS `BuiltIn ClipDistance` or `BuiltIn CullDistance` `float[1..8]`
  array (checking `shaderClipDistance` / `shaderCullDistance`), and emits
  `(1, 0, 0)`, `(0, 1, 0)`, `(0, 0, 1)` at `bary_location` across the 3 strip
  vertices so perspective interpolation matches `BaryCoordKHR`.
- Supports both eager and lazy graphics pipeline builds (`StageSource::bary_fallback`
  in `stage_words`), clamps `--f16-interp-fallback` `top_location` against
  `maxGeometryInputComponents` / `maxGeometryOutputComponents`, and refuses
  mesh PSOs, explicit GS or rectangle-list stages, missing `geometryShader`, or
  non-triangle topologies with clear HRESULTs (`E_NOTIMPL` / `E_INVALIDARG`).
- Adds `spirv_bary_fallback` (portable CPU test) and `d3d12_bary_fallback`
  (end-to-end Vulkan GPU D3D12 PSO test).

Claim: RT-BARY-FALLBACK-PSO
AI-assisted: yes (Antigravity)
# Conflicts:
#	docs/design.md
A pixel shader with a computed I/J pair, translated with --bary-fallback, reads the pair's attribute as a Flat
vec4[3] at the first of three locations its index entry gives under bary_fallback_input.per_vertex. The runtime's
geometry-stage builder read only bary_fallback_input.location and refused that input ("PS pass-through Input at
Location 0 is not vec4<f32>"), so such a PSO was never created.

- shader_library.h: parse per_vertex (attribute -> first location) into ShaderEntry::bary_fallback_per_vertex; one
  malformed entry drops the whole map.
- spirv_bary_fallback.h: build_bary_fallback_gs takes the map and writes the triangle's three values of each mapped
  VS output to the PS's Flat vec4[3] (element k = vertex k, the same at every emitted vertex), as
  tools/bary_fallback_gs.py does. An attribute the VS does not export is zero-filled. A vec4[3] the map does not
  name, a block that runs into another input or the barycentric location, and two attributes at one first location
  are refused. The old signature stays as a wrapper with an empty map.
- d3d12_vulkan_device.cpp: both call sites (eager and lazy) pass the entry's map.
- Tests: spirv_bary_fallback (five per-vertex cases), shader_library (twelve per_vertex parsing cases),
  d3d12_bary_fallback (two draws of a synthetic computed-I/J PS and one refusal).
- docs/design.md: the runtime builder in the "Barycentric fallback" row, with what was and was not checked.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:11:38 +00:00
Author
Owner

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

I found one remaining coverage gap in the fallback GS builder: spirv_bary_fallback.h records both VS ClipDistance and CullDistance, then rejects the shader when both arrays are present (clip_count && cull_count, around line 188). Vulkan permits both in one stage, subject to maxCombinedClipAndCullDistances; the GS would need to forward two independent built-ins/capabilities rather than choosing one dist_builtin. This is a safe refusal today, but it leaves valid pipelines unavailable on the fallback path. Could this be tracked as a follow-up, or is mixed clip/cull intentionally outside the fallback contract? Spec: https://docs.vulkan.org/spec/latest/chapters/vertexpostproc.html#vertexpostproc-clipping

**@⁠ZroIsHere** on GitHub · 2026-11-26 00:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7178501421) I found one remaining coverage gap in the fallback GS builder: `spirv_bary_fallback.h` records both VS `ClipDistance` and `CullDistance`, then rejects the shader when both arrays are present (`clip_count && cull_count`, around line 188). Vulkan permits both in one stage, subject to `maxCombinedClipAndCullDistances`; the GS would need to forward two independent built-ins/capabilities rather than choosing one `dist_builtin`. This is a safe refusal today, but it leaves valid pipelines unavailable on the fallback path. Could this be tracked as a follow-up, or is mixed clip/cull intentionally outside the fallback contract? Spec: https://docs.vulkan.org/spec/latest/chapters/vertexpostproc.html#vertexpostproc-clipping
Author
Owner

@⁠ZroIsHere on GitHub · 2026-11-26 00:18 UTC · original

I implemented this follow-up in a stacked PR against your integration branch: https://github.com/mrgenty/leonida/pull/1. It forwards ClipDistance and CullDistance independently and updates the generator coverage. Local tests were not run; the PR checks should validate it.

**@⁠ZroIsHere** on GitHub · 2026-11-26 00:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7178618431) I implemented this follow-up in a stacked PR against your integration branch: https://github.com/mrgenty/leonida/pull/1. It forwards ClipDistance and CullDistance independently and updates the generator coverage. Local tests were not run; the PR checks should validate it.
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 01:49 UTC · original

I checked the two open test cases in the PR description on 07d069924bffc3d103a7fcd4a4eef341d4517dd7. The translated ps_ij_computed fixture and a second shader combining computed I/J with f16 location relocation both rendered through the Xbox D3D12 proxy on an RTX 4090 (Windows 11, NVIDIA 616.64).

Translated synthetic inputs Check GPU readback
vs_ids + ps_ij_computed, --bary-fallback Computed I/J from attribute 0 4,096/4,096 pixels
Same sources, both fallback flags Same reference with f16 fallback enabled 4,096/4,096 pixels
Computed I/J on attribute 0 plus low/high f16 interpolation on attribute 7 VS exports raw locations 14 and 15, which the PS requests for attribute 7's halves. The linker must relocate the pair. 4,096/4,096 pixels

All four RGBA32F channels matched bit for bit. On the mixed case the low/high channels were exactly 0.25 and 0.75, the computed channel varied by row, and the control was 0.5. Each draw passed with Khronos validation on and off. Removing only bary_fallback_input.per_vertex from the index made the same pipeline fail creation as expected. The stock CPU tests spirv_bary_fallback and shader_library also passed.

For reproduction, I built the assembly with this head's runtime/test/shaders/build.py. The draw fixture supplied just the resulting VS, PS and index, with synthetic lookup hashes for its two test containers. It did not supply an offline geometry shader. For the mixed case I added a packed 0x3a003400 at VS param7.x, raw exports at 14 and 15, and low/high v_interp_p1ll_f16 + v_interp_p2_f16 on attr7.x before the existing computed-I/J operations.

@⁠zmasi, for the 207 refusals in your Vega report, this head includes #1426 and its runtime dependencies. If your Vulkan backend reports geometryShader=true, a before/after count with both fallback flags would test whether this covers the same class in your corpus. The geometry fallback requires that feature for drawing. My counts above cover synthetic shaders on NVIDIA.

AI-assisted with OpenAI Codex (gpt-6.2-astra).

**@⁠ecox982745** on GitHub · 2026-11-26 01:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7180168263) I checked the two open test cases in the PR description on `07d069924bffc3d103a7fcd4a4eef341d4517dd7`. The translated `ps_ij_computed` fixture and a second shader combining computed I/J with f16 location relocation both rendered through the Xbox D3D12 proxy on an RTX 4090 (Windows 11, NVIDIA 616.64). | Translated synthetic inputs | Check | GPU readback | |---|---|---| | `vs_ids` + `ps_ij_computed`, `--bary-fallback` | Computed I/J from attribute 0 | 4,096/4,096 pixels | | Same sources, both fallback flags | Same reference with f16 fallback enabled | 4,096/4,096 pixels | | Computed I/J on attribute 0 plus low/high f16 interpolation on attribute 7 | VS exports raw locations 14 and 15, which the PS requests for attribute 7's halves. The linker must relocate the pair. | 4,096/4,096 pixels | All four RGBA32F channels matched bit for bit. On the mixed case the low/high channels were exactly 0.25 and 0.75, the computed channel varied by row, and the control was 0.5. Each draw passed with Khronos validation on and off. Removing only `bary_fallback_input.per_vertex` from the index made the same pipeline fail creation as expected. The stock CPU tests `spirv_bary_fallback` and `shader_library` also passed. For reproduction, I built the assembly with this head's `runtime/test/shaders/build.py`. The draw fixture supplied just the resulting VS, PS and index, with synthetic lookup hashes for its two test containers. It did not supply an offline geometry shader. For the mixed case I added a packed `0x3a003400` at VS `param7.x`, raw exports at 14 and 15, and low/high `v_interp_p1ll_f16` + `v_interp_p2_f16` on `attr7.x` before the existing computed-I/J operations. @⁠zmasi, for the 207 refusals in your [Vega report](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608), this head includes #1426 and its runtime dependencies. If your Vulkan backend reports `geometryShader=true`, a before/after count with both fallback flags would test whether this covers the same class in your corpus. The geometry fallback requires that feature for drawing. My counts above cover synthetic shaders on NVIDIA. AI-assisted with OpenAI Codex (`gpt-6.2-astra`).
Author
Owner

@⁠zmasi on GitHub · 2026-11-26 11:02 UTC · original · edited 2026-11-26 11:05 UTC

@⁠ecox982745 — yes. The earlier Vega report and this rerun are missing exactly the same 207 pixel shaders before the change. On 07d069924bffc3d103a7fcd4a4eef341d4517dd7, all 207 are recovered.

AMD Radeon Pro Vega II (Vega 20 / gfx906), Mesa RADV 26.0.8, Ubuntu 26.04, Vulkan 1.4.335. geometryShader=true; subgroup range 64..64. Fresh output directories, the same 26,503 inputs, --f16-interp-fallback --bary-fallback on both revisions, no --wave64-emulate.

Revision Translated Passed spirv-val Refused
b0f3d399 (base before the stack) 26,296 26,296 207
07d06992 (PR head, includes #1426) 26,503 26,503 0

I compared the index entries locally: 0 previously accepted shaders lost; all 26,296 common SPIR-V modules were byte-identical. All 207 additions are pixel shaders with bary_fallback_input.per_vertex. A separate vk_pipeline_check over exactly those additions on RADV created 207/207 PS pipelines: 0 failed, 0 skipped.

That last check uses partner stubs; it is not a claim that 207 retail draws rendered correctly. Separately, a synthetic ps_ij_computed draw using the C++ builder test's matching per-vertex geometry shader passed the repository's 4,096-pixel readback check on Vega.

The full-corpus before/after RADV pipeline scan is still running. I’ll follow up here with its complete creation, failure and skip counts. Aggregate corpus results only. AI-assisted.

**@⁠zmasi** on GitHub · 2026-11-26 11:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7190186667) · edited 2026-11-26 11:05 UTC @⁠ecox982745 — yes. The [earlier Vega report](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) and this rerun are missing **exactly the same 207 pixel shaders** before the change. On `07d069924bffc3d103a7fcd4a4eef341d4517dd7`, all 207 are recovered. AMD Radeon Pro Vega II (Vega 20 / gfx906), Mesa RADV 26.0.8, Ubuntu 26.04, Vulkan 1.4.335. `geometryShader=true`; subgroup range 64..64. Fresh output directories, the same 26,503 inputs, `--f16-interp-fallback --bary-fallback` on both revisions, no `--wave64-emulate`. | Revision | Translated | Passed `spirv-val` | Refused | |---|---:|---:|---:| | `b0f3d399` (base before the stack) | 26,296 | 26,296 | 207 | | `07d06992` (PR head, includes #1426) | 26,503 | 26,503 | 0 | I compared the index entries locally: **0 previously accepted shaders lost**; all 26,296 common SPIR-V modules were byte-identical. All 207 additions are pixel shaders with `bary_fallback_input.per_vertex`. A separate `vk_pipeline_check` over exactly those additions on RADV created **207/207 PS pipelines: 0 failed, 0 skipped**. That last check uses partner stubs; it is not a claim that 207 retail draws rendered correctly. Separately, a synthetic `ps_ij_computed` draw using the C++ builder test's matching per-vertex geometry shader passed the repository's 4,096-pixel readback check on Vega. The full-corpus before/after RADV pipeline scan is still running. I’ll follow up here with its complete creation, failure and skip counts. Aggregate corpus results only. AI-assisted.
Author
Owner

@⁠zmasi on GitHub · 2026-11-26 11:30 UTC · original

@⁠ecox982745 — the full-corpus Vega 20 scan has finished. Both unfiltered vk_pipeline_check runs exited 0 on the same Radeon Pro Vega II (gfx906, Mesa RADV 26.0.8, fixed subgroup 64), with --f16-interp-fallback --bary-fallback used for both translations.

Revision Shader modules created Pipelines created Pipeline failures Pipelines skipped
b0f3d399 (before the stack) 26,296 17,014 0 9,282
07d06992 (tested PR head) 26,503 17,221 0 9,282

All 207 additional pipelines were pixel pipelines: 11,894 before, 12,101 after. Compute (2,689), vertex (2,236) and geometry (195) counts were unchanged. Neither run had a shader-module failure. All 9,282 skips in each run were mesh pipelines: RADV created their shader modules, but this GPU does not expose VK_EXT_mesh_shader.

This confirms driver pipeline creation for the same 207 recovered pixel shaders. The checker uses partner stubs for graphics; these counts are not a retail draw or pixel-correctness result.

AI-assisted.

**@⁠zmasi** on GitHub · 2026-11-26 11:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7190822889) @⁠ecox982745 — the full-corpus Vega 20 scan has finished. Both unfiltered `vk_pipeline_check` runs exited 0 on the same Radeon Pro Vega II (gfx906, Mesa RADV 26.0.8, fixed subgroup 64), with `--f16-interp-fallback --bary-fallback` used for both translations. | Revision | Shader modules created | Pipelines created | Pipeline failures | Pipelines skipped | |---|---:|---:|---:|---:| | `b0f3d399` (before the stack) | 26,296 | 17,014 | 0 | 9,282 | | `07d06992` (tested PR head) | 26,503 | 17,221 | 0 | 9,282 | **All 207 additional pipelines were pixel pipelines:** 11,894 before, 12,101 after. Compute (2,689), vertex (2,236) and geometry (195) counts were unchanged. Neither run had a shader-module failure. All 9,282 skips in each run were mesh pipelines: RADV created their shader modules, but this GPU does not expose `VK_EXT_mesh_shader`. This confirms driver pipeline creation for the [same 207 recovered pixel shaders](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/1930). The checker uses partner stubs for graphics; these counts are not a retail draw or pixel-correctness result. AI-assisted.
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 11:50 UTC · original

I tested the stacked mixed clip/cull change linked above. On an RTX 4090 (Windows 11, NVIDIA 616.64), the generated fallback geometry shader produced byte-identical RGBA32F readback to the direct vertex-to-fragment path in all 22 comparisons. This covers 90,112 pixel comparisons across 44 draws.

I used the generator at 096a26220f15 with synthetic vertex and fragment stages. The four clip/cull array-length pairs were (1,1), (2,1), (1,2), and (4,4). The generator at its parent, 07d069924bff (this PR), refused all four pairs before pipeline creation. On the stacked head the stock CPU test passed, all ten modules it dumped passed spirv-val --target-env vulkan1.2, and every generated stage in the draw matrix passed the same validator.

64×64 draw Expected and observed pixels painted per path
All distances positive 4,096
Last clip distance cuts the triangle in half 2,048
Last cull distance negative at every vertex, including with an active clip plane 0
Last cull distance negative at only one vertex 4,096
Two perpendicular clip planes plus a negative cull distance at one vertex 1,024

The fragment shader wrote both interpolated UV and barycentric values. The largest absolute channel error against the pixel-center formula was 5.96e−8, and the Khronos validation layer reported no errors. This check exercises simultaneous clipping and primitive culling on synthetic draws. The stacked change is still separate from the head of #1930.

**@⁠ecox982745** on GitHub · 2026-11-26 11:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7191224557) I tested the [stacked mixed clip/cull change](https://github.com/mrgenty/leonida/pull/1) linked above. On an RTX 4090 (Windows 11, NVIDIA 616.64), the generated fallback geometry shader produced **byte-identical RGBA32F readback to the direct vertex-to-fragment path in all 22 comparisons**. This covers 90,112 pixel comparisons across 44 draws. I used the generator at `096a26220f15` with synthetic vertex and fragment stages. The four clip/cull array-length pairs were (1,1), (2,1), (1,2), and (4,4). The generator at its parent, `07d069924bff` (this PR), refused all four pairs before pipeline creation. On the stacked head the stock CPU test passed, all ten modules it dumped passed `spirv-val --target-env vulkan1.2`, and every generated stage in the draw matrix passed the same validator. | 64×64 draw | Expected and observed pixels painted per path | | --- | ---: | | All distances positive | 4,096 | | Last clip distance cuts the triangle in half | 2,048 | | Last cull distance negative at every vertex, including with an active clip plane | 0 | | Last cull distance negative at only one vertex | 4,096 | | Two perpendicular clip planes plus a negative cull distance at one vertex | 1,024 | The fragment shader wrote both interpolated UV and barycentric values. The largest absolute channel error against the pixel-center formula was 5.96e−8, and the Khronos validation layer reported no errors. This check exercises simultaneous clipping and primitive culling on synthetic draws. The stacked change is still separate from the head of #1930.
Author
Owner

@⁠mrgenty on GitHub · 2026-11-26 13:06 UTC · original

Thanks @⁠zmasi and @⁠ecox982745 for the runs. The Vega 20 corpus numbers are the measurement this PR was missing: 207 refusals to 0, no accepted shader lost, the 26,296 common modules byte-identical and 207/207 pixel pipelines created on RADV. The 4090 draws cover the computed I/J path together with the f16 relocation, which I had only tested separately. I'm noting your caveat that this is pipeline creation, not a retail draw.

@⁠ZroIsHere: right, the builder refuses a VS that writes both ClipDistance and CullDistance. That refusal predates this PR, so it stays out of this one. @⁠ecox982745 already implemented it in mrgenty/leonida#1 and tested it (22/22 byte-identical on the 4090). Thanks for that. To keep one topic per PR I won't merge it into this branch. Could you open it against ubiquitarianism/leonida as its own PR, with Depends on: #1930? I'll close the one on my fork once it's up.

This branch needs a rebase on current main. I'll push it and rerun shader_library, spirv_bary_fallback and d3d12_bary_fallback on the RTX 3060.

**@⁠mrgenty** on GitHub · 2026-11-26 13:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7192884641) Thanks @⁠zmasi and @⁠ecox982745 for the runs. The Vega 20 corpus numbers are the measurement this PR was missing: 207 refusals to 0, no accepted shader lost, the 26,296 common modules byte-identical and 207/207 pixel pipelines created on RADV. The 4090 draws cover the computed I/J path together with the f16 relocation, which I had only tested separately. I'm noting your caveat that this is pipeline creation, not a retail draw. @⁠ZroIsHere: right, the builder refuses a VS that writes both ClipDistance and CullDistance. That refusal predates this PR, so it stays out of this one. @⁠ecox982745 already implemented it in [mrgenty/leonida#1](https://github.com/mrgenty/leonida/issues/1) and tested it (22/22 byte-identical on the 4090). Thanks for that. To keep one topic per PR I won't merge it into this branch. Could you open it against ubiquitarianism/leonida as its own PR, with Depends on: #1930? I'll close the one on my fork once it's up. This branch needs a rebase on current main. I'll push it and rerun shader_library, spirv_bary_fallback and d3d12_bary_fallback on the RTX 3060.
github-bot force-pushed github-bot/gh-1930 from 07d069924b to 682de28946 2026-11-26 13:20:41 +00:00 Compare
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 13:17 UTC · original

Opened #2304 against upstream main as a draft with Depends on: #1930. ZroIsHere wrote the implementation and generator test. My contribution was the RTX 4090 verification and upstream submission. The new PR preserves the original commit 096a26220 and links the 22 draw comparisons. I'll track the rebase there when #1930 updates.

**@⁠ecox982745** on GitHub · 2026-11-26 13:17 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7193147064) Opened #2304 against upstream main as a draft with `Depends on: #1930`. ZroIsHere wrote the implementation and generator test. My contribution was the RTX 4090 verification and upstream submission. The new PR preserves the original commit `096a26220` and links the 22 draw comparisons. I'll track the rebase there when #1930 updates.
Author
Owner

@⁠mrgenty on GitHub · 2026-11-26 14:13 UTC · original

Rebased on main 73516a29 (head now 682de289), with #1497 at its current head 53df7d1a and #1426 unchanged. The conflicts were in #1426's tools/vk_subgroup_info.py and docs/design.md, where both sides are kept; this PR's code applied unchanged. On the RTX 3060 (NVIDIA 621.24, validation on), shader_library, spirv_bary_fallback and d3d12_bary_fallback pass, and run_semantic_tests.py passes: 498 files, 6,357 tests, 0 failed.

@⁠ecox982745 the stack is updated, so #2304 can be rebased on it. Thanks for opening it, and @⁠ZroIsHere for the implementation. I credited ecox982745 for the code above; that was my mistake. I'm closing mrgenty/leonida#1 in favour of #2304.

**@⁠mrgenty** on GitHub · 2026-11-26 14:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7194445250) Rebased on `main` `73516a29` (head now `682de289`), with #1497 at its current head `53df7d1a` and #1426 unchanged. The conflicts were in #1426's `tools/vk_subgroup_info.py` and `docs/design.md`, where both sides are kept; this PR's code applied unchanged. On the RTX 3060 (NVIDIA 621.24, validation on), `shader_library`, `spirv_bary_fallback` and `d3d12_bary_fallback` pass, and `run_semantic_tests.py` passes: 498 files, 6,357 tests, 0 failed. @⁠ecox982745 the stack is updated, so #2304 can be rebased on it. Thanks for opening it, and @⁠ZroIsHere for the implementation. I credited ecox982745 for the code above; that was my mistake. I'm closing mrgenty/leonida#1 in favour of #2304.
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 14:15 UTC · original

Thanks for updating the stack and the attribution. I rebased #2304 locally on your exact head 682de2894. The two-file diff matches ZroIsHere’s original patch byte for byte. All 22 pairs of RTX 4090 draws matched across 90,112 pixels, and all ten generated shaders passed SPIR-V validation.

The remaining step is publishing that rebase. GitHub rejected the branch update because it carries upstream workflow changes and the connected OAuth credential lacks the required permission. The public draft still points to 096a26220. Anyone reviewing the combined tree can reproduce it by cherry-picking that commit onto 682de2894. Results and integration status.

**@⁠ecox982745** on GitHub · 2026-11-26 14:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7194505184) Thanks for updating the stack and the attribution. I rebased #2304 locally on your exact head `682de2894`. The two-file diff matches ZroIsHere’s original patch byte for byte. All 22 pairs of RTX 4090 draws matched across 90,112 pixels, and all ten generated shaders passed SPIR-V validation. The remaining step is publishing that rebase. GitHub rejected the branch update because it carries upstream workflow changes and the connected OAuth credential lacks the required permission. The public draft still points to `096a26220`. Anyone reviewing the combined tree can reproduce it by cherry-picking that commit onto `682de2894`. [Results and integration status](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/2304).
With both --bary-fallback and --f16-interp-fallback, create_graphics (and the lazy stage_words) links the f16
halves into the VS before the geometry stage is built. Linking may place a decoded half on a Location no raw VS
output used; when that Location is a computed-I/J attribute the VS does not export, build_bary_fallback_gs read the
half as that attribute and forwarded it instead of zero-filling the array.

- link_f16_halves can return the Locations of the VS's raw outputs as they were before linking, and
  build_bary_fallback_gs forwards a computed-I/J attribute only from one of them. Both call sites pass the set when
  the halves were linked.
- link_f16_halves also keeps halves off the second and third Locations of a per_vertex vec4[3] block, which has a
  Location decoration on its first only.

spirv_bary_fallback_test 7f-7h: a relocated half and a static half on a missing attribute's Location (zero-filled;
without the set the half is forwarded), and a block whose third Location linking would otherwise choose (the
builder refused it).

Reported, with a GPU reproduction, by @marcelofrayha in mrgenty/leonida#2; the fix follows his commit 7f63a4876,
and the block reservation his bdff821c1, adapted to this branch without the geometry-input packing.

Co-authored-by: Marcelo Frayha <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠mrgenty on GitHub · 2026-11-26 23:02 UTC · original

Pushed 0b753295 with a fix @⁠marcelofrayha found and reproduced on a GPU (mrgenty/leonida#2): with both fallbacks on, f16 linking can put a decoded half on the Location of a computed-I/J attribute the VS does not export, and the geometry stage then forwarded that half instead of zero-filling the array. link_f16_halves now returns the VS's raw output Locations from before linking, and the builder forwards an attribute only from one of them. Linking also keeps halves off all three Locations of a vec4[3] block, not just the first. The commit follows his 7f63a4876 and the block-reservation part of bdff821c1, with him as co-author.

Tested on the RTX 3060 (validation on): shader_library, spirv_f16_halves, spirv_bary_fallback (new cases 7f–7h; 7f also checks that the half is forwarded without the fix, and 7h fails if the block reservation is removed), d3d12_f16_halves and d3d12_bary_fallback pass, and the 12 dumped modules pass spirv-val for Vulkan 1.2 and 1.3.

**@⁠mrgenty** on GitHub · 2026-11-26 23:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7205199885) Pushed `0b753295` with a fix @⁠marcelofrayha found and reproduced on a GPU (mrgenty/leonida#2): with both fallbacks on, f16 linking can put a decoded half on the Location of a computed-I/J attribute the VS does not export, and the geometry stage then forwarded that half instead of zero-filling the array. `link_f16_halves` now returns the VS's raw output Locations from before linking, and the builder forwards an attribute only from one of them. Linking also keeps halves off all three Locations of a `vec4[3]` block, not just the first. The commit follows his `7f63a4876` and the block-reservation part of `bdff821c1`, with him as co-author. Tested on the RTX 3060 (validation on): `shader_library`, `spirv_f16_halves`, `spirv_bary_fallback` (new cases 7f–7h; 7f also checks that the half is forwarded without the fix, and 7h fails if the block reservation is removed), `d3d12_f16_halves` and `d3d12_bary_fallback` pass, and the 12 dumped modules pass `spirv-val` for Vulkan 1.2 and 1.3.
Author
Owner

@⁠zmasi on GitHub · 2026-11-26 23:59 UTC · original

@⁠mrgenty — verified 0b753295 against its immediate parent 682de289 on Radeon Pro Vega II (gfx906, Mesa RADV 26.0.8) with both fallbacks. At Vega’s geometry-stage half-location ceiling of 14, one more synthetic pipeline drew, and three previously wrong draws became correct.

Synthetic collision cases (64×64) 682de289 0b753295
Relocated high half, relocated low half, static VS half (7f/7g) 3 pipelines drew; 0/12,288 pixels matched 3 drew; 12,288/12,288 matched
Three-location per-vertex block (7h) C++ builder refused it; no driver call Pipeline drew; 4,096/4,096 matched

These were native Vulkan readbacks using the revision’s C++ f16 linker and fallback GS builder, not the Windows D3D12 proxy. Separately, the original 207 recovered pixel shaders still translated, passed spirv-val, and created 207/207 RADV pipelines (0 failed, 0 skipped). That was the targeted cohort, not a new full-corpus scan.

AI-assisted.

**@⁠zmasi** on GitHub · 2026-11-26 23:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7206068423) @⁠mrgenty — verified `0b753295` against its immediate parent `682de289` on Radeon Pro Vega II (gfx906, Mesa RADV 26.0.8) with both fallbacks. At Vega’s geometry-stage half-location ceiling of 14, **one more synthetic pipeline drew, and three previously wrong draws became correct**. | Synthetic collision cases (64×64) | `682de289` | `0b753295` | |---|---:|---:| | Relocated high half, relocated low half, static VS half (7f/7g) | 3 pipelines drew; 0/12,288 pixels matched | 3 drew; 12,288/12,288 matched | | Three-location per-vertex block (7h) | C++ builder refused it; no driver call | Pipeline drew; 4,096/4,096 matched | These were native Vulkan readbacks using the revision’s C++ f16 linker and fallback GS builder, not the Windows D3D12 proxy. Separately, the original 207 recovered pixel shaders still translated, passed `spirv-val`, and created **207/207** RADV pipelines (0 failed, 0 skipped). That was the targeted cohort, not a new full-corpus scan. AI-assisted.
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-27 00:47 UTC · original

When bringing the new geometry-limit checks from #1497 into #1930, the per-vertex arrays need to count towards those limits. I tested #1497 at 961d719d54 combined with #1930 at 0b7532951f. Git merges spirv_bary_fallback.h cleanly (blob 6bf9da14bb), but the resulting builder reports a footprint smaller than the geometry shader it emits.

CPU check. With the barycentric vector at location 3, a VS attribute at 16, and its computed-I/J vec4[3] block starting at 14, the builder reported input/output location bounds of 0/15 components. The emitted SPIR-V requires 68/68: the input occupies location 16 and the output spans locations 14–16. A 64-component profile would therefore pass the new precheck. Moving the attribute to 15 and the block to 13 gives a legitimate 64/64 boundary case.

Counting inputs from the final id_in_loc map includes attributes used only by computed I/J and counts a shared ordinary input once. On output, each emitted id_out_pv array adds 12 scalar components per vertex and occupies locations base through base + 2, even when zero-filled. A local adjustment to those counts matched independent SPIR-V reflection in five fixtures and kept all five generated shaders byte-identical.

RTX 4090 check. This card reports limits of 128 input and 128 output components. All five synthetic fixtures rendered the expected values across 20,480 pixels with Vulkan validation enabled. The 64-component comparison was CPU-only. The emitted modules also passed spirv-val for Vulkan 1.2 and 1.3.

I tested the merged builder in isolation. The full merge still has conflicts in the runtime and two test files. In the D3D12 test, several fixture program IDs overlap across the two branches (for example, vs_10p_prog and vs_ij_prog have identical input bytes); giving those distinct IDs will keep both cases independently testable. AI-assisted verification.

**@⁠ecox982745** on GitHub · 2026-11-27 00:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7206759180) When bringing [the new geometry-limit checks from #1497](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/1497) into #1930, the per-vertex arrays need to count towards those limits. I tested #1497 at `961d719d54` combined with #1930 at `0b7532951f`. Git merges `spirv_bary_fallback.h` cleanly (blob `6bf9da14bb`), but the resulting builder reports a footprint smaller than the geometry shader it emits. **CPU check.** With the barycentric vector at location 3, a VS attribute at 16, and its computed-I/J `vec4[3]` block starting at 14, the builder reported input/output location bounds of **0/15** components. The emitted SPIR-V requires **68/68**: the input occupies location 16 and the output spans locations 14–16. A 64-component profile would therefore pass the new precheck. Moving the attribute to 15 and the block to 13 gives a legitimate **64/64** boundary case. Counting inputs from the final `id_in_loc` map includes attributes used only by computed I/J and counts a shared ordinary input once. On output, each emitted `id_out_pv` array adds 12 scalar components per vertex and occupies locations `base` through `base + 2`, even when zero-filled. A local adjustment to those counts matched independent SPIR-V reflection in five fixtures and kept all five generated shaders byte-identical. **RTX 4090 check.** This card reports limits of 128 input and 128 output components. All five synthetic fixtures rendered the expected values across 20,480 pixels with Vulkan validation enabled. The 64-component comparison was CPU-only. The emitted modules also passed `spirv-val` for Vulkan 1.2 and 1.3. I tested the merged builder in isolation. The full merge still has conflicts in the runtime and two test files. In the D3D12 test, several fixture program IDs overlap across the two branches (for example, `vs_10p_prog` and `vs_ij_prog` have identical input bytes); giving those distinct IDs will keep both cases independently testable. AI-assisted verification.
Author
Owner

@⁠zmasi on GitHub · 2026-11-27 01:42 UTC · original

@⁠ecox982745 — confirmed the merged-builder limit issue on a real 64-input-component device. Vega 20 reports geometry limits of 64 input, 128 output, 1,024 total output components (RADV Mesa 26.0.8).

For the merged header 6bf9da14bb (#1497 961d719d + #1930 0b753295), attribute 16 with the block at 14 reported location bounds 0/15; independent reflection of the emitted GS gave 68/68. The merged precheck would admit it. That case was CPU-only: no over-limit module went to the driver. At the legal edge (attribute 15, block 13–15), reflection gave 64/64, the pipeline was created, and 4,096/4,096 pixels matched. Counting the final input map and all three locations of each emitted block matched reflection in all five fixtures.

This is an integration issue in the combined header, not a new failure of either standalone head.

AI-assisted.

**@⁠zmasi** on GitHub · 2026-11-27 01:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1930#issuecomment-7207507238) @⁠ecox982745 — confirmed the [merged-builder limit issue](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/1930) on a real 64-input-component device. Vega 20 reports geometry limits of **64 input, 128 output, 1,024 total output** components (RADV Mesa 26.0.8). For the merged header `6bf9da14bb` (#1497 `961d719d` + #1930 `0b753295`), attribute 16 with the block at 14 reported location bounds **0/15**; independent reflection of the emitted GS gave **68/68**. The merged precheck would admit it. That case was CPU-only: no over-limit module went to the driver. At the legal edge (attribute 15, block 13–15), reflection gave **64/64**, the pipeline was created, and **4,096/4,096 pixels matched**. Counting the final input map and all three locations of each emitted block matched reflection in all five fixtures. This is an integration issue in the combined header, not a new failure of either standalone head. AI-assisted.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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