runtime/d3d12: synthesize --bary-fallback geometry shader in graphics PSOs #1497

Open
github-bot wants to merge 3 commits from github-bot/gh-1497 into main AGit
Owner

@⁠robot00f on GitHub · 2026-11-25 02:14 UTC · original
robot00f:feat/rt-bary-fallback-pso → main · +2206 −10 · 9 files · 3 commits · open

Claimed in the coordination issue as: RT-BARY-FALLBACK-PSO (#14)

What and why

On GPUs without VK_KHR_fragment_shader_barycentric (for example NVIDIA Pascal), rdna2spirv.py --bary-fallback emits a pixel shader's raw barycentrics as an ordinary perspective-interpolated vec3<f32> Input and records "bary_fallback_input": {"location": N} in spirv/index.json. Offline tools/bary_fallback_gs.py already specified the triangle pass-through geometry shader shape, and PipelineState::create_graphics already supported explicit geometry stages (#2109), rectangle-list geometry stages (#984) and per-pipeline --f16-interp-fallback linking (spirv_f16_halves.h), but ShaderLibrary did not read bary_fallback_input and create_graphics did not insert the pass-through geometry stage — leaving any graphics PSO with a --bary-fallback PS without a stage writing bary_location.

This PR wires --bary-fallback pixel shaders end to end into D3D12→Vulkan graphics PSO creation:

  1. runtime/src/shader_library.h: parses "bary_fallback_input": {"location": N} (exact non-negative uint32_t) into ShaderEntry::bary_fallback_location.
  2. runtime/src/spirv_bary_fallback.h: pure C++20 leonida::build_bary_fallback_gs(vs_words, ps_words, bary_location, gs_words, &info, &error) synthesizing a SPIR-V 1.5 Geometry module (Triangles in, Invocations 1, OutputTriangleStrip, OutputVertices 3) for the (VS, PS) pair:
    • copies BuiltIn Position across the three triangle vertices and writes (1, 0, 0), (0, 1, 0), (0, 0, 1) to Output vec3<f32> at bary_location;
    • forwards every vec4<f32> Location input the PS declares (other than bary_location) that the VS exports, leaves unread VS outputs unconsumed on VS -> GS (even if the VS exports an unread output at bary_location), and zero-fills any unexported PS Location input via OpConstantNull without declaring a dangling GS Input (VUID-RuntimeSpirv-OpEntryPoint-08743);
    • inspects the VS for BuiltIn ClipDistance or BuiltIn CullDistance (float[1..8]) and forwards it with the matching capability, rejecting mixed ClipDistance + CullDistance and ShaderLayer / ShaderViewportIndex.
  3. runtime/shims/d3d12_vulkan_device.cpp: in PipelineState::create_graphics and stage_words (StageSource::bary_fallback for lazy graphics pipeline builds), runs build_bary_fallback_gs after link_f16_halves on the post-link (vs, ps) words (clamping top_location against maxGeometryInputComponents / maxGeometryOutputComponents) so relocated/synthesized f16_halves locations are forwarded automatically through the GS. Refuses mesh PSOs, explicit desc.GS, rectangle-list PSOs, disabled geometryShader / shaderClipDistance / shaderCullDistance (E_NOTIMPL via stream_unsupported), and non-triangle PrimitiveTopologyType (E_INVALIDARG).
  4. Tests (runtime/CMakeLists.txt, runtime/test/vk_test_device.h, runtime/test/*):
    • extends shader_library_test with bary_fallback_input index parsing checks;
    • adds spirv_bary_fallback (spirv_bary_fallback_test.cpp), a portable pure-CPU test covering pass-through locations, unread VS locations, unexported PS Flat zero-fill, ClipDistance[2], CullDistance[3], combined link_f16_halves + build_bary_fallback_gs, and clean refusals;
    • enables shaderClipDistance and shaderCullDistance where available in vktest::Device and adds d3d12_bary_fallback (d3d12_bary_fallback_test.cpp), exercising real Vulkan GPU draws through the Xbox-ABI proxy.

Tested

  • 3 consecutive runs + eager & lazy graphics pipeline modes (ctest --output-on-failure -R "^(shader_library|spirv_bary_fallback|d3d12_bary_fallback)$", plus LEONIDA_LAZY_GRAPHICS=0 and LEONIDA_LAZY_GRAPHICS=1): 3/3 passed on all runs:
    • d3d12_bary_fallback verified all 256 pixels of: (1) a non-uniform-W (w = 1, 2, 4) triangle checking perspective-correct (b0, b1, b2) + pass-through Location 0 (center=(184,49,22,191) vs affine (128,64,64,191)), (2) ClipDistance[1] clipping ndc_x < 0 while preserving barycentrics on ndc_x > 0, (3) a 16-param VS + colliding f16_halves + bary_fallback_input PSO combining link_f16_halves relocation/synthesis with build_bary_fallback_gs, plus E_INVALIDARG / E_NOTIMPL refusal checks.
  • SPIR-V validation: dumped all 6 synthesized GS variants from spirv_bary_fallback_test --dump-dir (gs_basic, gs_unread_vs, gs_zero_fill, gs_clip2, gs_cull3, gs_f16_linked) and validated each with spirv-val --target-env vulkan1.2 and spirv-val --target-env vulkan1.3 (0 errors).
  • Neighbor tests: spirv_f16_halves, d3d12_f16_halves, d3d12_geometry, d3d12_translated_draw (4/4 passed).
  • Repo / policy checks: python -I scripts/check_no_game_data.py on all touched files, tests/test_bary_fallback_gs.py (29), tests/test_ctest_registration.py (5), tests/test_docs_links.py (16), tests/test_docs_table_rows.py (2), git diff --check.
  • Not tested: VK_LAYER_KHRONOS_validation is not installed on this Windows 10 host; no game shaders or executable were run.

GPUs tested: NVIDIA GeForce GTX 1050 Ti (Pascal, 4 GB), driver 582.28, Vulkan 1.4.312, Windows 10 Pro 10.0.19045

AI-assisted: yes (Antigravity)

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.
**@⁠robot00f** on GitHub · 2026-11-25 02:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1497) `robot00f:feat/rt-bary-fallback-pso` → `main` · +2206 −10 · 9 files · 3 commits · open Claimed in the coordination issue as: RT-BARY-FALLBACK-PSO (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why On GPUs without `VK_KHR_fragment_shader_barycentric` (for example NVIDIA Pascal), `rdna2spirv.py --bary-fallback` emits a pixel shader's raw barycentrics as an ordinary perspective-interpolated `vec3<f32>` `Input` and records `"bary_fallback_input": {"location": N}` in `spirv/index.json`. Offline `tools/bary_fallback_gs.py` already specified the triangle pass-through geometry shader shape, and `PipelineState::create_graphics` already supported explicit geometry stages (#2109), rectangle-list geometry stages (#984) and per-pipeline `--f16-interp-fallback` linking (`spirv_f16_halves.h`), but `ShaderLibrary` did not read `bary_fallback_input` and `create_graphics` did not insert the pass-through geometry stage — leaving any graphics PSO with a `--bary-fallback` PS without a stage writing `bary_location`. This PR wires `--bary-fallback` pixel shaders end to end into D3D12→Vulkan graphics PSO creation: 1. **`runtime/src/shader_library.h`**: parses `"bary_fallback_input": {"location": N}` (exact non-negative `uint32_t`) into `ShaderEntry::bary_fallback_location`. 2. **`runtime/src/spirv_bary_fallback.h`**: pure C++20 `leonida::build_bary_fallback_gs(vs_words, ps_words, bary_location, gs_words, &info, &error)` synthesizing a SPIR-V 1.5 `Geometry` module (`Triangles` in, `Invocations 1`, `OutputTriangleStrip`, `OutputVertices 3`) for the `(VS, PS)` pair: - copies `BuiltIn Position` across the three triangle vertices and writes `(1, 0, 0)`, `(0, 1, 0)`, `(0, 0, 1)` to `Output vec3<f32>` at `bary_location`; - forwards every `vec4<f32>` `Location` input the PS declares (other than `bary_location`) that the VS exports, leaves unread VS outputs unconsumed on `VS -> GS` (even if the VS exports an unread output at `bary_location`), and zero-fills any unexported PS `Location` input via `OpConstantNull` without declaring a dangling GS `Input` (`VUID-RuntimeSpirv-OpEntryPoint-08743`); - inspects the VS for `BuiltIn ClipDistance` or `BuiltIn CullDistance` (`float[1..8]`) and forwards it with the matching capability, rejecting mixed `ClipDistance` + `CullDistance` and `ShaderLayer` / `ShaderViewportIndex`. 3. **`runtime/shims/d3d12_vulkan_device.cpp`**: in `PipelineState::create_graphics` and `stage_words` (`StageSource::bary_fallback` for lazy graphics pipeline builds), runs `build_bary_fallback_gs` after `link_f16_halves` on the post-link `(vs, ps)` words (clamping `top_location` against `maxGeometryInputComponents` / `maxGeometryOutputComponents`) so relocated/synthesized `f16_halves` locations are forwarded automatically through the GS. Refuses mesh PSOs, explicit `desc.GS`, rectangle-list PSOs, disabled `geometryShader` / `shaderClipDistance` / `shaderCullDistance` (`E_NOTIMPL` via `stream_unsupported`), and non-triangle `PrimitiveTopologyType` (`E_INVALIDARG`). 4. **Tests (`runtime/CMakeLists.txt`, `runtime/test/vk_test_device.h`, `runtime/test/*`)**: - extends `shader_library_test` with `bary_fallback_input` index parsing checks; - adds `spirv_bary_fallback` (`spirv_bary_fallback_test.cpp`), a portable pure-CPU test covering pass-through locations, unread VS locations, unexported PS `Flat` zero-fill, `ClipDistance[2]`, `CullDistance[3]`, combined `link_f16_halves` + `build_bary_fallback_gs`, and clean refusals; - enables `shaderClipDistance` and `shaderCullDistance` where available in `vktest::Device` and adds `d3d12_bary_fallback` (`d3d12_bary_fallback_test.cpp`), exercising real Vulkan GPU draws through the Xbox-ABI proxy. ### Tested - **3 consecutive runs + eager & lazy graphics pipeline modes** (`ctest --output-on-failure -R "^(shader_library|spirv_bary_fallback|d3d12_bary_fallback)$"`, plus `LEONIDA_LAZY_GRAPHICS=0` and `LEONIDA_LAZY_GRAPHICS=1`): 3/3 passed on all runs: - `d3d12_bary_fallback` verified all 256 pixels of: (1) a non-uniform-W (`w = 1, 2, 4`) triangle checking perspective-correct `(b0, b1, b2)` + pass-through `Location 0` (`center=(184,49,22,191)` vs affine `(128,64,64,191)`), (2) `ClipDistance[1]` clipping `ndc_x < 0` while preserving barycentrics on `ndc_x > 0`, (3) a 16-param VS + colliding `f16_halves` + `bary_fallback_input` PSO combining `link_f16_halves` relocation/synthesis with `build_bary_fallback_gs`, plus `E_INVALIDARG` / `E_NOTIMPL` refusal checks. - **SPIR-V validation**: dumped all 6 synthesized GS variants from `spirv_bary_fallback_test --dump-dir` (`gs_basic`, `gs_unread_vs`, `gs_zero_fill`, `gs_clip2`, `gs_cull3`, `gs_f16_linked`) and validated each with `spirv-val --target-env vulkan1.2` and `spirv-val --target-env vulkan1.3` (0 errors). - **Neighbor tests**: `spirv_f16_halves`, `d3d12_f16_halves`, `d3d12_geometry`, `d3d12_translated_draw` (4/4 passed). - **Repo / policy checks**: `python -I scripts/check_no_game_data.py` on all touched files, `tests/test_bary_fallback_gs.py` (29), `tests/test_ctest_registration.py` (5), `tests/test_docs_links.py` (16), `tests/test_docs_table_rows.py` (2), `git diff --check`. - **Not tested**: `VK_LAYER_KHRONOS_validation` is not installed on this Windows 10 host; no game shaders or executable were run. GPUs tested: NVIDIA GeForce GTX 1050 Ti (Pascal, 4 GB), driver 582.28, Vulkan 1.4.312, Windows 10 Pro 10.0.19045 AI-assisted: yes (Antigravity) ### 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.
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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:54:15 +00:00
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-25 02:45 UTC · original

I checked how this runtime builder handles the two kinds of fallback shader produced by #1426 (b9191a31). The ordinary barycentric case works on my RTX 4090. The computed-I/J case needs an additional runtime change before these PRs together cover the RX 5700 XT report in #1285.

I built vs_ids, ps_bary and ps_ij_computed at the translator head with both fallbacks enabled. I passed the resulting VS/PS modules and the location in their index directly to build_bary_fallback_gs from this PR's head, bff50180. Neither PS had f16-halves relocation metadata.

Synthetic fixture Runtime builder on this head RTX 4090 readback
ps_bary, location 1 Produced a valid GS Runtime and offline GS frames were byte-identical. All 4,096 pixels matched the expected RGBA.
ps_ij_computed, location 3 with per_vertex: {"0": 0} Refused before drawing: PS pass-through Input at Location 0 is not vec4<f32> With the offline GS from #1426, all 4,096 pixels matched the expected RGBA.

The computed input at location 0 is a flat array of three vec4s. The runtime currently reads only bary_fallback_input.location and expects the other inputs to be ordinary vec4s. The integration needs to carry the per_vertex mapping into GS generation and fill each array element from the corresponding vertex, as #1426's offline builder does. The existing ps_ij_computed fixture would make a regression test for that link.

The GPU draws used this PR's vk_harness on Windows 11, NVIDIA 616.64. I tested the runtime builder directly; the computed-case refusal occurred on CPU before a Vulkan pipeline was created. AI-assisted verification.

**@⁠ecox982745** on GitHub · 2026-11-25 02:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1497#issuecomment-7151152121) I checked how this runtime builder handles the two kinds of fallback shader produced by #1426 (`b9191a31`). The ordinary barycentric case works on my RTX 4090. The computed-I/J case needs an additional runtime change before these PRs together cover the RX 5700 XT report in #1285. I built `vs_ids`, `ps_bary` and `ps_ij_computed` at the translator head with both fallbacks enabled. I passed the resulting VS/PS modules and the location in their index directly to `build_bary_fallback_gs` from this PR's head, `bff50180`. Neither PS had f16-halves relocation metadata. | Synthetic fixture | Runtime builder on this head | RTX 4090 readback | | --- | --- | --- | | `ps_bary`, location 1 | Produced a valid GS | Runtime and offline GS frames were byte-identical. All 4,096 pixels matched the expected RGBA. | | `ps_ij_computed`, location 3 with `per_vertex: {"0": 0}` | Refused before drawing: `PS pass-through Input at Location 0 is not vec4<f32>` | With the offline GS from #1426, all 4,096 pixels matched the expected RGBA. | The computed input at location 0 is a flat array of three vec4s. The runtime currently reads only `bary_fallback_input.location` and expects the other inputs to be ordinary vec4s. The integration needs to carry the `per_vertex` mapping into GS generation and fill each array element from the corresponding vertex, as #1426's offline builder does. The existing `ps_ij_computed` fixture would make a regression test for that link. The GPU draws used this PR's `vk_harness` on Windows 11, NVIDIA 616.64. I tested the runtime builder directly; the computed-case refusal occurred on CPU before a Vulkan pipeline was created. AI-assisted verification.
Author
Owner

@⁠ytsodacan on GitHub · 2026-11-25 03:36 UTC · original · edited 2026-11-25 03:43 UTC

[KEEP]

  • CI is still pending on head 31ff7194: change-scope, no-game-data, windows, linux-gpu-tools and macos are all queued.
  • An existing review comment reports that the computed I/J fallback case (ps_ij_computed) is refused by the runtime builder (PS pass-through Input at Location 0 is not vec4<f32>), because per_vertex is not carried into GS generation. The ordinary barycentric case works. The PR does not yet cover the RX 5700 XT report in #1285 for that case.
  • Large change (about 1.9k lines: runtime/src/spirv_bary_fallback.h, runtime/shims/d3d12_vulkan_device.cpp and tests). It sits alongside open #1426, #120, #1440 and #875 on the same fallback feature, so ordering needs a maintainer decision.
  • Needs the per_vertex handling (with an ps_ij_computed regression test) and green CI.
**@⁠ytsodacan** on GitHub · 2026-11-25 03:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1497#issuecomment-7152075074) · edited 2026-11-25 03:43 UTC **[KEEP]** - CI is still pending on head `31ff7194`: `change-scope`, `no-game-data`, `windows`, `linux-gpu-tools` and `macos` are all queued. - An existing review comment reports that the computed I/J fallback case (`ps_ij_computed`) is refused by the runtime builder (`PS pass-through Input at Location 0 is not vec4<f32>`), because `per_vertex` is not carried into GS generation. The ordinary barycentric case works. The PR does not yet cover the RX 5700 XT report in #1285 for that case. - Large change (about 1.9k lines: `runtime/src/spirv_bary_fallback.h`, `runtime/shims/d3d12_vulkan_device.cpp` and tests). It sits alongside open #1426, #120, #1440 and #875 on the same fallback feature, so ordering needs a maintainer decision. - Needs the per_vertex handling (with an `ps_ij_computed` regression test) and green CI.
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 07:53 UTC · original

Independent verification (native Windows 11, validation on):

  • CPU: spirv_bary_fallback + shader_library pass; all 6 dumped GS SPIR-V modules pass spirv-val under both vulkan1.2 and vulkan1.3 targets (12/12 clean).
  • NVIDIA RTX 4070 SUPER: 4/4 pass — d3d12_bary_fallback, d3d12_f16_halves, d3d12_geometry, spirv_f16_halves; also d3d12_bary_fallback passes with LEONIDA_LAZY_GRAPHICS=1.
  • AMD Radeon iGPU: the d3d12 graphics tests fail at PSO creation with the known 144>128 push-constant limit — identical on the untouched baseline, environmental not a regression.
  • Code review: the diff refuses mesh/explicit-GS/rect-list PSOs, clamps f16-half top location vs geometry limits, zero-fills unexported PS inputs, forwards Clip/CullDistance with feature checks, and the lazy StageSource::bary_fallback rebuild path is included. Looks careful.

One scope note confirmed independently: this PR does not include #1426's per-vertex attribute mapping (git merge-base --is-ancestor negative), so the computed-I/J per_vertex case from the original report still needs that carry-over — matching @⁠ecox982745's comment. #1426 is itself currently conflicting vs main.

AI-assisted verification.

**@⁠whoalin1** on GitHub · 2026-11-25 07:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1497#issuecomment-7156360678) Independent verification (native Windows 11, validation on): - CPU: `spirv_bary_fallback` + `shader_library` pass; all 6 dumped GS SPIR-V modules pass `spirv-val` under both `vulkan1.2` and `vulkan1.3` targets (12/12 clean). - **NVIDIA RTX 4070 SUPER**: 4/4 pass — `d3d12_bary_fallback`, `d3d12_f16_halves`, `d3d12_geometry`, `spirv_f16_halves`; also `d3d12_bary_fallback` passes with `LEONIDA_LAZY_GRAPHICS=1`. - **AMD Radeon iGPU**: the d3d12 graphics tests fail at PSO creation with the known 144>128 push-constant limit — identical on the untouched baseline, environmental not a regression. - Code review: the diff refuses mesh/explicit-GS/rect-list PSOs, clamps f16-half top location vs geometry limits, zero-fills unexported PS inputs, forwards Clip/CullDistance with feature checks, and the lazy `StageSource::bary_fallback` rebuild path is included. Looks careful. One scope note confirmed independently: this PR does **not** include #1426's per-vertex attribute mapping (`git merge-base --is-ancestor` negative), so the computed-I/J `per_vertex` case from the original report still needs that carry-over — matching @⁠ecox982745's comment. #1426 is itself currently conflicting vs main. AI-assisted verification.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 19:30 UTC · original

Tested 483f0128e merged onto main, Windows build under Wine, on Mesa lavapipe and RADV (gfx1036 iGPU):

  • spirv_bary_fallback passes on both.
  • d3d12_bary_fallback passes on lavapipe but fails on RADV, 3 of 3 runs, at d3d12_bary_fallback_test.cpp:623: CreateGraphicsPipelineState fails for case 3 (vs_16p + ps_bary_f16). Cases 1 and 2 pass.
  • Nothing is logged for the failure.
  • Likely cause (not confirmed): the synthesized geometry shader takes every VS output, 30 locations, but RADV reports maxGeometryInputComponents = 64. Lavapipe reports 128.

Could the runtime either forward only the locations the pixel shader reads, or refuse with a logged reason when the inputs exceed the limit? The test should then skip case 3 on such devices rather than fail.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 19:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1497#issuecomment-7172391826) Tested `483f0128e` merged onto `main`, Windows build under Wine, on Mesa lavapipe and RADV (gfx1036 iGPU): - `spirv_bary_fallback` passes on both. - `d3d12_bary_fallback` passes on lavapipe but fails on RADV, 3 of 3 runs, at `d3d12_bary_fallback_test.cpp:623`: `CreateGraphicsPipelineState` fails for case 3 (`vs_16p` + `ps_bary_f16`). Cases 1 and 2 pass. - Nothing is logged for the failure. - Likely cause (not confirmed): the synthesized geometry shader takes every VS output, 30 locations, but RADV reports `maxGeometryInputComponents = 64`. Lavapipe reports 128. Could the runtime either forward only the locations the pixel shader reads, or refuse with a logged reason when the inputs exceed the limit? The test should then skip case 3 on such devices rather than fail. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

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

I opened a focused stacked follow-up for the low maxGeometryInputComponents case: https://github.com/robot00f/leonida/pull/1. It preserves the PS interface outputs while zero-filling declared inputs the PS never loads, so the synthesized GS only reads needed values from the VS.

**@⁠ZroIsHere** on GitHub · 2026-11-26 00:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1497#issuecomment-7179312894) I opened a focused stacked follow-up for the low `maxGeometryInputComponents` case: https://github.com/robot00f/leonida/pull/1. It preserves the PS interface outputs while zero-filling declared inputs the PS never loads, so the synthesized GS only reads needed values from the VS.
Author
Owner

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

Tested at your current head 53df7d1a, merged onto main 73516a29 together with #1426: this is the base of #1930, which builds on both. On an RTX 3060 (NVIDIA 621.24, Windows 11, MSVC 19.44, Vulkan validation on), shader_library, spirv_bary_fallback and d3d12_bary_fallback pass with no validation message, and run_semantic_tests.py passes: 498 files, 6,357 tests, 0 failed. The merge onto main had no conflict in this PR's files. The run includes #1930's commit on top, so these are this PR's tests on the combined tree, not this head alone.

**@⁠mrgenty** on GitHub · 2026-11-26 21:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1497#issuecomment-7203294996) Tested at your current head `53df7d1a`, merged onto `main` `73516a29` together with #1426: this is the base of #1930, which builds on both. On an RTX 3060 (NVIDIA 621.24, Windows 11, MSVC 19.44, Vulkan validation on), `shader_library`, `spirv_bary_fallback` and `d3d12_bary_fallback` pass with no validation message, and `run_semantic_tests.py` passes: 498 files, 6,357 tests, 0 failed. The merge onto `main` had no conflict in this PR's files. The run includes #1930's commit on top, so these are this PR's tests on the combined tree, not this head alone.
- Prune declared-but-unread PS Input variables on the VS -> GS interface in
  build_bary_fallback_gs (tracking pointer aliases through OpAccessChain,
  OpCopyObject, OpSelect, and OpPhi into OpLoad, GLSL.std.450 InterpolateAt*,
  OpFunctionCall, and OpCopyMemory*), zero-filling unread FSSM table inputs in
  the synthesized GS instead of reading them from the VS.
- Record per-vertex input/output scalar component totals and highest
  4 * Location + components bounds (VUID-RuntimeSpirv-Location-06272) in
  BaryFallbackGsInfo, and check them against maxGeometryInputComponents,
  maxGeometryOutputComponents, and maxGeometryTotalOutputComponents in
  create_graphics with explicit [rt] d3d12: refusal diagnostics.
- Extend spirv_bary_fallback_test and d3d12_bary_fallback_test to cover
  unused-input pruning, 10-param f16 relocation within 64 geometry input
  components, simulated maxGeometryInputComponents=64 acceptance/refusal on any
  GPU, and clean refusal + draw skip on <120-component devices (such as RADV
  gfx1036) for the 16-param relocated f16 case.

Co-authored-by: ZroFreaks <[email protected]>
Author
Owner

@⁠robot00f on GitHub · 2026-11-27 00:42 UTC · original

Thanks for testing on RADV gfx1036 and catching both the silent failure and VUID-RuntimeSpirv-Location-06272, @⁠aslan2142 (and thanks @⁠ZroIsHere for robot00f/leonida#1)!

Updated in 961d719d (merged current main with no rebase/force-push):

  1. Merged main to clear the unrelated baseline CI failures (vk_null_descriptor_test.cpp and cs_dpp_cmp.asm).
  2. Pruned unread PS Inputs on VS -> GS (runtime/src/spirv_bary_fallback.h, co-authored with @⁠ZroIsHere): build_bary_fallback_gs now tracks pointer aliases rooted at PS Input variables (through OpAccessChain/OpPtrAccessChain, OpCopyObject, OpSelect, and OpPhi into OpLoad, GLSL.std.450 InterpolateAt*, OpFunctionCall, and OpCopyMemory*) and zero-fills unread FSSM table declarations in the synthesized GS without declaring GS Inputs from the VS.
  3. Checked geometry stage component & location limits up front with [rt] d3d12: diagnostics (runtime/shims/d3d12_vulkan_device.cpp):
    • Recorded maxGeometryInputComponents, maxGeometryOutputComponents, and maxGeometryTotalOutputComponents from VkPhysicalDeviceProperties::limits.
    • BaryFallbackGsInfo now reports both per-vertex scalar component totals and highest 4 * Location + components bounds (VUID-RuntimeSpirv-Location-06272), and create_graphics refuses pipelines that exceed device geometry limits before vkCreateShaderModule / vkCreateGraphicsPipelines while logging the shader names, location/component count, and device limit (including when --bary-fallback caps f16_halves top_location).
  4. Updated spirv_bary_fallback_test & d3d12_bary_fallback_test for maxGeometryInputComponents = 64 GPUs:
    • Added ps_bary_pruned (16-param VS + 25 unread PS inputs pruned so live inputs stay < 16) and ps_bary_f16_low (10-param VS + f16_halves relocated into 0..14), both running within 64 geometry input components.
    • For the 16-param vs_16p + ps_bary_f16 case (where raw VS outputs occupy 0..15, so relocated f16_halves sit at [28, 29] and genuinely require >= 120 geometry components), devices with maxGeometryInputComponents < 120 or maxGeometryOutputComponents < 120 now assert clean refusal and SKIP that draw check instead of failing.
    • Added a max_geometry_input_components = 64 test block exercising both the pruned/10-param passes and the Location 16 (4 * 16 + 4 = 68 > 64) / 16-param refusals on all GPUs.

Validated locally on NVIDIA GeForce GTX 1050 Ti (driver 582.28, Windows 10 19045) with spirv_bary_fallback, d3d12_bary_fallback (eager + lazy), d3d12_f16_halves, d3d12_geometry, spirv_f16_halves, shader_library, spirv-val (vulkan1.2 + vulkan1.3 on all 7 synthesized GS binaries), and the Python/semantic test suites.

AI-assisted: yes

**@⁠robot00f** on GitHub · 2026-11-27 00:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1497#issuecomment-7206687933) Thanks for testing on RADV `gfx1036` and catching both the silent failure and `VUID-RuntimeSpirv-Location-06272`, @⁠aslan2142 (and thanks @⁠ZroIsHere for `robot00f/leonida#1`)! Updated in `961d719d` (merged current `main` with no rebase/force-push): 1. **Merged `main`** to clear the unrelated baseline CI failures (`vk_null_descriptor_test.cpp` and `cs_dpp_cmp.asm`). 2. **Pruned unread PS `Input`s on `VS -> GS`** (`runtime/src/spirv_bary_fallback.h`, co-authored with @⁠ZroIsHere): `build_bary_fallback_gs` now tracks pointer aliases rooted at PS `Input` variables (through `OpAccessChain`/`OpPtrAccessChain`, `OpCopyObject`, `OpSelect`, and `OpPhi` into `OpLoad`, `GLSL.std.450` `InterpolateAt*`, `OpFunctionCall`, and `OpCopyMemory*`) and zero-fills unread FSSM table declarations in the synthesized GS without declaring GS `Input`s from the VS. 3. **Checked geometry stage component & location limits up front with `[rt] d3d12:` diagnostics** (`runtime/shims/d3d12_vulkan_device.cpp`): - Recorded `maxGeometryInputComponents`, `maxGeometryOutputComponents`, and `maxGeometryTotalOutputComponents` from `VkPhysicalDeviceProperties::limits`. - `BaryFallbackGsInfo` now reports both per-vertex scalar component totals and highest `4 * Location + components` bounds (`VUID-RuntimeSpirv-Location-06272`), and `create_graphics` refuses pipelines that exceed device geometry limits before `vkCreateShaderModule` / `vkCreateGraphicsPipelines` while logging the shader names, location/component count, and device limit (including when `--bary-fallback` caps `f16_halves` `top_location`). 4. **Updated `spirv_bary_fallback_test` & `d3d12_bary_fallback_test` for `maxGeometryInputComponents = 64` GPUs**: - Added `ps_bary_pruned` (16-param VS + 25 unread PS inputs pruned so live inputs stay `< 16`) and `ps_bary_f16_low` (10-param VS + `f16_halves` relocated into `0..14`), both running within 64 geometry input components. - For the 16-param `vs_16p + ps_bary_f16` case (where raw VS outputs occupy `0..15`, so relocated `f16_halves` sit at `[28, 29]` and genuinely require `>= 120` geometry components), devices with `maxGeometryInputComponents < 120` or `maxGeometryOutputComponents < 120` now assert clean refusal and `SKIP` that draw check instead of failing. - Added a `max_geometry_input_components = 64` test block exercising both the pruned/10-param passes and the `Location 16` (`4 * 16 + 4 = 68 > 64`) / 16-param refusals on all GPUs. Validated locally on NVIDIA GeForce GTX 1050 Ti (driver 582.28, Windows 10 19045) with `spirv_bary_fallback`, `d3d12_bary_fallback` (eager + lazy), `d3d12_f16_halves`, `d3d12_geometry`, `spirv_f16_halves`, `shader_library`, `spirv-val` (`vulkan1.2` + `vulkan1.3` on all 7 synthesized GS binaries), and the Python/semantic test suites. AI-assisted: yes
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/1497/head:github-bot/gh-1497'
git switch 'github-bot/gh-1497'

Merge

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