Repository navigation
Conversation
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 <cursoragent@cursor.com>
|
I found one remaining coverage gap in the fallback GS builder: |
|
I implemented this follow-up in a stacked PR against your integration branch: mrgenty#1. It forwards ClipDistance and CullDistance independently and updates the generator coverage. Local tests were not run; the PR checks should validate it. |
|
I checked the two open test cases in the PR description on
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 For reproduction, I built the assembly with this head's @zmasi, for the 207 refusals in your Vega report, this head includes #1426 and its runtime dependencies. If your Vulkan backend reports AI-assisted with OpenAI Codex ( |
… PSOs
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)
|
@ecox982745 — yes. The earlier Vega report and this rerun are missing exactly the same 207 pixel shaders before the change. On AMD Radeon Pro Vega II (Vega 20 / gfx906), Mesa RADV 26.0.8, Ubuntu 26.04, Vulkan 1.4.335.
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 That last check uses partner stubs; it is not a claim that 207 retail draws rendered correctly. Separately, a synthetic 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. |
|
@ecox982745 — the full-corpus Vega 20 scan has finished. Both unfiltered
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 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. |
|
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
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. |
|
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. |
…pairs (RT-BARY-FALLBACK-PER-VERTEX)
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 <noreply@anthropic.com>
07d0699 to
682de28
Compare
|
Opened #2304 against upstream main as a draft with |
|
Rebased on @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#1 in favour of #2304. |
|
Thanks for updating the stack and the attribution. I rebased #2304 locally on your exact head 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 |
… linking (RT-BARY-FALLBACK-PER-VERTEX) 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 #2; the fix follows his commit 7f63a48, and the block reservation his bdff821, adapted to this branch without the geometry-input packing. Co-authored-by: Marcelo Frayha <marcelofrayha@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed Tested on the RTX 3060 (validation on): |
|
@mrgenty — verified
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 AI-assisted. |
…mponent limits - 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 <42916282+ZroIsHere@users.noreply.github.com>
|
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 CPU check. With the barycentric vector at location 3, a VS attribute at 16, and its computed-I/J Counting inputs from the final 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 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, |
|
@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 This is an integration issue in the combined header, not a new failure of either standalone head. AI-assisted. |
# Conflicts: # runtime/shims/d3d12_vulkan_device.cpp # runtime/test/d3d12_bary_fallback_test.cpp # runtime/test/spirv_bary_fallback_test.cpp
…(RT-BARY-FALLBACK-PER-VERTEX) ProjectLeonida#1497's precheck compares BaryFallbackGsInfo with maxGeometryInput/OutputComponents, but the info left out the per_vertex blocks: an attribute read only by a block had a GS Input that was not counted, and each vec4[3] output (Locations base..base+2, 12 components, zero-filled or not) was missing from the output bounds. Attribute 16 with its block at 14..16 reported 0/15 while the module needs 68/68, so a 64-component device would get it. Inputs are now counted from the GS's final Input map (a location shared by an ordinary output and a block once), and each block adds 12 output components and its last Location to the output bound. spirv_bary_fallback_test 7i checks 68/68, the 64/64 edge and a zero-filled block; it fails with the old count. Also fixes two leftovers of the ProjectLeonida#1497 merge in the tests: build_ps declared its uint type twice when a PS had both a block and an access chain, and an extra brace closed the D3D12 test's index.json early. Found by @ecox982745 and confirmed on a Vega 20 by @zmasi in ProjectLeonida#1930.
|
Updated: merged #1497 at RTX 3060, NVIDIA 621.24, validation on: |
|
@mrgenty @ecox982745 — tested
The practical remaining boundary is the built-in accounting in the geometry precheck, not a pixel mismatch. Layer check in the tested SDK · interface limit in the spec. I did not resubmit the flagged module. AI-assisted. |
Search for the lowest available block of three until one is found. The number of occupied locations does not bound the start of the first free block. Exercise two computed attributes after sparse reads at locations 0, 1, 2, 4, 6 and 8. Reported in ProjectLeonida#1608 (issuecomment-7234323048). AI-assisted-by: OpenAI Codex (GPT-6) (cherry picked from commit d1361e9)
…-BARY-FALLBACK-PER-VERTEX) The Khronos validation layer checks VUID-RuntimeSpirv-Location-06272 for a geometry shader as the last interface slot plus the components of its built-in variables (sl_spirv.cpp, SDK 1.4.341), so the fallback GS's Position (4) and any forwarded ClipDistance/CullDistance count on top of the Location end. The precheck compared the Location end alone: a block at 13..15 (end 64) passed on a 64-component device and drew correctly, but the layer reported 06272 (68 components). BaryFallbackGsInfo gains builtin_components (4 + dist_count), and the precheck refuses a stage whose Location end plus built-ins is above maxGeometryInput/OutputComponents. spirv_bary_fallback_test 7i checks the 68 of the 13..15 block, the 64 edge at 12..14 and a ClipDistance[2] adding 2. Reported by @zmasi on a Vega 20 (RADV) in ProjectLeonida#1930.
|
Updated, thanks @zmasi and @ecox982745:
RTX 3060, NVIDIA 621.24, validation on: |
main now lowers a computed I/J pair under --f16-interp-fallback alone with quad derivatives (ProjectLeonida#2239), while this branch lowers it under --bary-fallback (alone or with --f16-interp-fallback) from the Flat vec4[3] its geometry shader fills. The two cover different modes, so the merge keeps both: the per-vertex path when --bary-fallback is on or there is no f16 fallback, Gen.ij_quad_eval otherwise, and no refusal of a computed pair in either. build.py, check.py and run_gpu_tests.py build and run ps_ij_computed in every mode, and the tests that expected a refusal under one of the fallbacks check the translation instead. Also keeps main's bary_fallback_gs validation, driver version in vk_subgroup_info and <memory> in shader_library.h.
|
Merged RTX 3060, NVIDIA 621.24, validation on: |
Claimed in the coordination issue as: RT-BARY-FALLBACK-PER-VERTEX (#1608 (comment))
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 aFlatvec4[3]input, at the first of three locations the index gives asbary_fallback_input.per_vertex(attribute → first location). #1497's builder reads onlybary_fallback_input.locationand expects every other PS input to be avec4, 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 withmainin onedocs/design.mdrow and I took its side, which ismain's text plus its additions.The commit:
runtime/src/shader_library.h: parsesper_vertexintoShaderEntry::bary_fallback_per_vertex. Keys and values are exactu32s; 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_gstakes 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 aFlatvec4[3]output at the first location (element k = vertex k, the same at each of the three vertices it emits), astools/bary_fallback_gs.pydoes. 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 notvec4<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_graphicsand the lazystage_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 withLEONIDA_VK_VALIDATION=1;d3d12_bary_fallbackalso withLEONIDA_LAZY_GRAPHICS=0and=1under 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.2andvulkan1.3on all 9 modulesspirv_bary_fallback_test --dump-dirwrites (the 6 from runtime/d3d12: synthesize --bary-fallback geometry shader in graphics PSOs #1497 and 3 new): 18/18 clean.shader_library, twelve newper_vertexparsing 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 rdna2spirv: computed I/J pairs under --bary-fallback (SHADER-COMPUTED-IJ-NO-PERVERTEX) #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 noper_vertexin its index entry is refused withE_FAIL.python -I scripts/check_no_game_data.pyon 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:
fragmentShaderBarycentric; the test drives the fallback path on it directly. A run ofd3d12_bary_fallbackon such a card would be welcome.ps_ij_computedfrom rdna2spirv: computed I/J pairs under --bary-fallback (SHADER-COMPUTED-IJ-NO-PERVERTEX) #1426 translated byrdna2spirv.pyand drawn through the runtime (nollvm-mcwith the AMDGPU target on this machine).--f16-interp-fallbackrelocation in one PSO.GPUs tested: NVIDIA GeForce RTX 3060, driver 621.24, Windows 11 (10.0.26300)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase). — based onmainb0f3d399plus runtime/d3d12: synthesize --bary-fallback geometry shader in graphics PSOs #1497 and rdna2spirv: computed I/J pairs under --bary-fallback (SHADER-COMPUTED-IJ-NO-PERVERTEX) #1426; it will need a rebase as those land.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