runtime: forward mixed clip and cull distances in the fallback geometry shader #2304
Open
github-bot
wants to merge 7 commits from
github-bot/gh-2304 into main
AGit
pull from: github-bot/gh-2304
merge into: github:main
github:main
github:docs/animation-merge-remnants
github:docs/story-dedup-and-cli
github:docs/restofworld-merge-remnants
github:docs/gamedata-dedup-tables
github:docs/textures-bcpack-tables-and-cli
github:docs/exe-fail-fast-shims-sync
github:fix/address-guard-wraparound-parity
github:fix/cvt-f16-denorm-and-clamp
github:docs/pso-cache-scope-note
github:docs/viewer-readme
github:docs/textures-arrays-dds-preview
github:docs/conformance-readme-status
github:fix/docs-validators-fences-urls
github:claude/loop-total
github:claude/pops-collision-seed
github:claude/dstorage-hold-page-reads
github:claude/host-image-copy-switch
github:feat/gdk-lifecycle-window-hook
github:claude/d16s8-uav-nvidia-fallback
github:feat/mfplat-offline-shim
github:claude/gameinput-slow-reader
github:fix/rt-null-barrier-clear
github:claude/depth-resolve-sample-positions
github:integration/palmetto-parity
github:claude/valu-literal-sext
github:claude/slot74-pool-handle
github:claude/rgb9e5-uint-alias-view
github:claude/fssm-root-layout-tables
github:feat/gdk-speech-display-lifecycle
github:asset-audio-skip-current
github:qemmhd/old-9940-rectangle-quad-lists
github:feat/ws2-offline-shim
github:qemmhd/rt-d16-unorm-uav
github:feat/xs-device-stops-7-9
github:qemmhd/rt-depth-same-base-shapes
github:qemmhd/rt-lazy-attachment-variant
github:feat/acphal-xma2-decoder
github:asset-audio-skip
github:codex/coord-claim-check-20261124-7e48
github:feat/xs-frame-pacing-presentx
github:feat/xs-device-vm-options
github:old-pr/9844
github:old-pr/9978
github:old-pr/9815
github:old-pr/10057
github:old-pr/9874
github:old-pr/9965
github:old-pr/9863
github:old-pr/10068
github:old-pr/10066
github:old-pr/10067
github:old-pr/10007
github:old-pr/10061
github:old-pr/10065
github:old-pr/10059
github:old-pr/10063
github:old-pr/10055
github:old-pr/10062
github:old-pr/10042
github:old-pr/10041
github:old-pr/10049
github:old-pr/10047
github:old-pr/10046
github:old-pr/10045
github:old-pr/10056
github:old-pr/10043
github:old-pr/10036
github:old-pr/10034
github:old-pr/9984
github:old-pr/10052
github:old-pr/10038
github:old-pr/10033
github:old-pr/10028
github:old-pr/10050
github:old-pr/9891
github:old-pr/9889
github:old-pr/10051
github:old-pr/10019
github:old-pr/10027
github:old-pr/10029
github:old-pr/10031
github:old-pr/10026
github:old-pr/9941
github:old-pr/10030
github:old-pr/10040
github:old-pr/9990
github:old-pr/10021
github:old-pr/9962
github:old-pr/10022
github:old-pr/10020
github:old-pr/10015
github:old-pr/10025
github:old-pr/9886
github:old-pr/10048
github:old-pr/10014
github:old-pr/10011
github:old-pr/9861
github:old-pr/10010
github:old-pr/10008
github:old-pr/9860
github:old-pr/10006
github:old-pr/9920
github:old-pr/9995
github:old-pr/10000
github:old-pr/10016
github:old-pr/10004
github:old-pr/10023
github:old-pr/9982
github:old-pr/9981
github:old-pr/9983
github:old-pr/9970
github:old-pr/9969
github:old-pr/9968
github:old-pr/9971
github:old-pr/9972
github:old-pr/9942
github:old-pr/9963
github:old-pr/9960
github:old-pr/9964
github:old-pr/9985
github:old-pr/9973
github:old-pr/9862
github:old-pr/9953
github:old-pr/10017
github:old-pr/9952
github:old-pr/9955
github:old-pr/9946
github:old-pr/9954
github:old-pr/9938
github:old-pr/9956
github:old-pr/9856
github:old-pr/9947
github:old-pr/9924
github:old-pr/9961
github:old-pr/9927
github:old-pr/9979
github:old-pr/10032
github:old-pr/9926
github:old-pr/5237
github:old-pr/9951
github:old-pr/9931
github:old-pr/9902
github:old-pr/9921
github:old-pr/9994
github:old-pr/9775
github:old-pr/9768
github:old-pr/9905
github:old-pr/9936
github:old-pr/9901
github:old-pr/9904
github:old-pr/9906
github:old-pr/9988
github:old-pr/9908
github:old-pr/9909
github:old-pr/9911
github:old-pr/9912
github:old-pr/9913
github:old-pr/9887
github:old-pr/9916
github:old-pr/9919
github:old-pr/9925
github:old-pr/9933
github:old-pr/9935
github:old-pr/9918
github:old-pr/9879
github:old-pr/9880
github:old-pr/9881
github:old-pr/9996
github:old-pr/9876
github:old-pr/9892
github:old-pr/9899
github:old-pr/9915
github:old-pr/9914
github:old-pr/9872
github:old-pr/9869
github:old-pr/9866
github:old-pr/9819
github:old-pr/10012
github:old-pr/9857
github:old-pr/9893
github:old-pr/9897
github:old-pr/9928
github:old-pr/9868
github:old-pr/9917
github:old-pr/9940
github:old-pr/9873
github:old-pr/9816
github:old-pr/10009
github:old-pr/9900
github:old-pr/9966
github:old-pr/9859
github:old-pr/9843
github:old-pr/9991
github:old-pr/10058
github:old-pr/9883
github:old-pr/9838
github:old-pr/9835
github:old-pr/9959
github:old-pr/9895
github:old-pr/9837
github:old-pr/9858
github:old-pr/9865
github:old-pr/9864
github:old-pr/9840
github:old-pr/9820
github:old-pr/4669
github:old-pr/9848
github:old-pr/9850
github:old-pr/9810
github:old-pr/9799
github:old-pr/9853
github:old-pr/9875
github:old-pr/9831
github:old-pr/9796
github:old-pr/9801
github:old-pr/9813
github:old-pr/9794
github:old-pr/7417
github:old-pr/9781
github:old-pr/9806
github:old-pr/9958
github:old-pr/9809
github:old-pr/9791
github:old-pr/9792
github:old-pr/10053
github:old-pr/9784
github:old-pr/9789
github:old-pr/9849
github:old-pr/9846
github:old-pr/9773
github:old-pr/9785
github:old-pr/9803
github:old-pr/9826
github:old-pr/9839
github:old-pr/9922
github:old-pr/9948
github:old-pr/7189
github:old-pr/9957
github:old-pr/9823
github:old-pr/9807
github:old-pr/9851
github:old-pr/9774
github:old-pr/9830
github:old-pr/9836
github:old-pr/9822
github:old-pr/9783
github:old-pr/9833
github:old-pr/9890
github:old-pr/9770
github:old-pr/9769
github:old-pr/9772
github:old-pr/9787
github:old-pr/9852
github:old-pr/9834
github:old-pr/9845
github:old-pr/9871
github:old-pr/9771
github:old-pr/9776
github:old-pr/10005
github:old-pr/9949
github:old-pr/9923
github:old-pr/9805
github:old-pr/9829
github:old-pr/9790
github:old-pr/9827
github:old-pr/9929
github:old-pr/9855
github:old-pr/9934
github:old-pr/9907
github:old-pr/9910
github:old-pr/9779
github:old-pr/9780
github:old-pr/9885
github:old-pr/9882
github:old-pr/9877
github:old-pr/9998
github:old-pr/4251
github:old-pr/9987
github:old-pr/9989
github:old-pr/9950
github:old-pr/9777
github:old-pr/10044
github:old-pr/9884
github:old-pr/2906
github:old-pr/5076
github:old-pr/9937
github:old-pr/9986
github:old-pr/3014
github:old-pr/9943
github:old-pr/9939
github:old-pr/4682
github:old-pr/4765
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
bug
Something isn't working
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
question
Further information is requested
wontfix
This will not be worked on
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2304
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2304"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ecox982745 on GitHub · 2026-11-26 13:17 UTC · original
ecox982745:reviewed-bary-mixed-distances→main· +2798 −103 · 23 files · 7 commits · draftClaimed in the coordination issue as RT-BARY-FALLBACK-MIXED-DISTANCES.
Depends on: #1930 (which builds on #1426).
What changed
The fallback geometry shader now forwards both
ClipDistanceandCullDistancewhen a vertex shader writes both arrays. Each array keeps its own length. This allows the rasterizer to clip part of a primitive and to cull a whole primitive.ZroIsHere wrote the implementation and CPU test in mrgenty/leonida#1. This draft brings that work upstream at the request of the #1930 author. The published head is the original commit
096a26220. Review the two-file change.Verification
I reapplied the original commit locally on top of the updated #1930 head
682de2894. The resulting commitfcbc57c0dhas a byte-identical two-file diff and merges cleanly with main at73516a290.spirv-val --target-env vulkan1.2.git diff --checkboth passed. All fixtures were synthetic.Integration status
The public draft still points to
096a26220. GitHub rejected the rebased branch update because the dependency now includes upstream CI workflow changes and the connected OAuth app lacks theworkflowscope. The fallback change itself touches only the runtime shader builder and its test. For the latest verified integration, cherry-pick096a26220fonto #1930 at0b7532951f, then merge main atd1dff7949b. The resulting tree isff32b57406. Combined shader tests and RTX 4090 readbacks. This draft is waiting on #1930 and publication of the rebased head.AI-assisted: Yes. The original author disclosed AI assistance. OpenAI Codex (GPT-6) performed independent hardware verification, prepared the rebase and submitted the upstream draft.
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)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]>@wavehs on GitHub · 2026-11-26 19:12 UTC · original · reviewed
macOS arm64 check of #2304 (RT-BARY-FALLBACK-PER-VERTEX). A translator rule, a Python geometry-shader builder and the runtime builder; the branch is far behind and does not apply to
main, so what I could verify is the translator half and the generated modules.Tested head
096a26220(7 commits, 3 of them merges ofmainfrom when the branch was current), 533 commits behindmainbdbc7e923.It does not apply to
mainany more.git merge-tree --write-tree ubi/main 096a26220exits 1 with conflicts indocs/design.md,runtime/shims/d3d12_vulkan_device.cpp,runtime/test/vk_test_device.handtools/vk_subgroup_info.py. The branch's own diff against its merge-base (b0f3d3998, 533 commits back) failsgit apply --checkonmainin those four plusdocs/testing.mdandtests/test_vk_subgroup_info.py. So a rebase is needed before CI can run it; I tested two things that can be separated:main(tools/rdna2spirv.py,tools/bary_fallback_gs.py,tests/semantic/support.py,tests/semantic/test_interp_computed_ij.py,tests/test_shader_build_fallbacks.py,tests/test_run_gpu_tests.py,scripts/run_gpu_tests.pyapplied bypatch -p1, clean).tests/semantic/test_interp_computed_ij.py: 28 tests, OK - including theComputedIJBaryFallbackcases that compare every computed form against thePerVertexKHRpath and the geometry shader's ownspirv-val.tests/test_shader_build_fallbacks.py: 3 failures,tests/test_run_gpu_tests.py: 2 failures - not defects of the rule: they assert the build-side wording and selection that live in the runtime/make_game half, which I did not transplant (e.g. the test expectsper-vertex inputswheremainprintscomputed I/J pairs need PerVertexKHR inputs). They are a reminder that the whole PR has to be rebased before those suites mean anything.096a26220(vk_compute_test,vk_store_test,vk_harness) and ran the project's own runner withLEONIDA_BARY_FALLBACK=1and KosmicKrisp:274 shaders: 274 translated, 274 pass spirv-val.ps_bary,ps_ij_computed,ps_persp_bary,ps_scc_mask32,ps_uniform_branch(<name>.bary_gs.spv). Each passesspirv-val --target-env vulkan1.2independently (the builder already validates them; I re-ran the check on the artefacts of this run).158/264 passed, 72 skipped; the five GS fixtures reportSKIP (unsupported: no geometryShader). That is the honest outcome on this device.What this GPU cannot verify, and why it matters.
vk_subgroup_info.pyreportsgeometry_shader: false,per_vertex_inputs: false,barycentric_fallback: falsefor KosmicKrisp on an Apple M3 Pro: Apple GPUs have no geometry stage, so the pass-through GS this PR adds cannot be created here at all. The design row already lists "a GPU that needs the fallback" as unverified; this machine needs the fallback but cannot run it, so it does not close that gap. What I can say positively: under--bary-fallbackevery fixture translates, the PS values of the computed-I/J forms match thePerVertexKHRpath in the mini interpreter, and all five generated GS modules are valid Vulkan 1.2 SPIR-V.Review of the rule as far as it can be read
assemble()rents three consecutive free locations per per-vertex attribute, excluding the attribute's own location, and rejects a block that overlaps any other input (tools/rdna2spirv.py:15798-15808); the loop's search boundlen(taken) + 3is always enough because at mostlen(taken)of its candidates can be taken. The index keeps the attribute number ininputsfor those attributes (:19199) and records the block underbary_fallback_input.per_vertex(:19206), which is what both the Python GS builder and the runtime builder consume.P0 + I·(P1−P0) + J·(P2−P0)with its own I/J.--f16-interp-fallbackplus--bary-fallback(the Pascal combination) is covered by the new semantic cases; the 16-bit reads decode the raw words of the array rather than the producer's halves, which is the only consistent choice since there are no halves on that path.Findings
runtime/src/arena_blocks.handruntime/shims/d3d12_vulkan_device.cpphave moved under it, andtools/vk_subgroup_info.pynow conflicts, so the automatic fallback selection changes need re-checking againstmain's version after the rebase.VK_KHR_fragment_shader_barycentric(or Pascal) remains the way to execute it; the author already reports such a check on a GTX 1060.run_gpu_tests.py --require-passexits 1 withno GPU tests passedbecause the only fixture skipped. That is the runner's contract, but a first-time user on Apple Silicon may read it as a failure; a line in the message when the skip isno geometryShaderwould explain it.python -I scripts/check_no_game_data.pyon the seven transplanted files: clean. I did not run the shader corpus or GPU fixtures againstmain(the translator change cannot be applied there beyond the files above), so no baseline deltas are claimed beyond the semantic counts.No game files. AI-assisted.
@ecox982745 on GitHub · 2026-11-26 19:18 UTC · original
I followed up on the macOS review. The full dependency stack merges cleanly with main
2d43417d49after reapplying the two-file mixed clip/cull commit. All five fixtures that skipped on Apple M3 ran on an RTX 4090.To reproduce the tested tree, start at #1930 head
682de28946, cherry-pick096a26220f, then merge2d43417d49. The resulting Git tree is6ff8680e10ce90599940f3ece50488949c6fa829. The public draft still points to the older stack. The individual change in this PR touches onlyspirv_bary_fallback.hand its C++ test. The translator and device-selection changes are in its dependencies.spirv-val --target-env vulkan1.2and matched the prior rebased build byte for byte, including mixed clip/cull.ps_bary,ps_ij_computed,ps_persp_bary,ps_scc_mask32andps_uniform_brancheach passed the pixel readback with automatic selection and withLEONIDA_BARY_FALLBACK=1. The forced runs emitted five geometry shaders, all independently validated.d3d12_bary_fallbackpassed with Vulkan validation enabled, including partial clipping, f16 relocation and both computed-I/J layouts.The RTX reports
geometry_shader=true,per_vertex_inputs=trueandbarycentric_fallback=false. Automatic selection used its native path. Forcing the fallback exercised the geometry stage on hardware. The public branch update is still pending.@ecox982745 on GitHub · 2026-11-26 23:17 UTC · original
I tested this patch against the updated dependency in #1930, including a draw that needs both changes in the same geometry shader. Cherry-picking
096a26220fonto0b7532951fapplied cleanly (tree8b52538a2e). Merging maind1dff7949binto that result also applied cleanly. All results below are from the resulting treeff32b57406f99271788e9e039d496b8b854bae37.RTX 4090, Windows 11, NVIDIA 616.64. The synthetic vertex shader writes two clip distances and one cull distance. The fragment shader reads the per-vertex attribute at 29 alongside decoded FP16 halves of 0.25 and 0.75. I compared all four channels at every pixel of each 64 × 64 readback with the expected values.
The two FP16 channels kept their expected values in every drawn pixel, and every unshaded pixel retained the clear color. As a control I omitted the raw-export set from the generator for one full draw. The linked high half at location 29 then appeared as 0.75 instead of 0 in all 4,096 pixels. All seven draws ran with Khronos validation and produced no validation errors.
The stock
shader_library,spirv_f16_halves, andspirv_bary_fallbackCPU tests passed. All 13 geometry modules dumped by the generator passedspirv-valfor Vulkan 1.2 and 1.3. Both D3D12 GPU tests (d3d12_f16_halves,d3d12_bary_fallback) also passed on the 4090 with validation enabled. The public draft head is still096a26220f. AI-assisted verification.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.