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
pull from: github-bot/gh-1497
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!1497
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1497"
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?
@robot00f on GitHub · 2026-11-25 02:14 UTC · original
robot00f:feat/rt-bary-fallback-pso→main· +2206 −10 · 9 files · 3 commits · openClaimed 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-fallbackemits a pixel shader's raw barycentrics as an ordinary perspective-interpolatedvec3<f32>Inputand records"bary_fallback_input": {"location": N}inspirv/index.json. Offlinetools/bary_fallback_gs.pyalready specified the triangle pass-through geometry shader shape, andPipelineState::create_graphicsalready supported explicit geometry stages (#2109), rectangle-list geometry stages (#984) and per-pipeline--f16-interp-fallbacklinking (spirv_f16_halves.h), butShaderLibrarydid not readbary_fallback_inputandcreate_graphicsdid not insert the pass-through geometry stage — leaving any graphics PSO with a--bary-fallbackPS without a stage writingbary_location.This PR wires
--bary-fallbackpixel shaders end to end into D3D12→Vulkan graphics PSO creation:runtime/src/shader_library.h: parses"bary_fallback_input": {"location": N}(exact non-negativeuint32_t) intoShaderEntry::bary_fallback_location.runtime/src/spirv_bary_fallback.h: pure C++20leonida::build_bary_fallback_gs(vs_words, ps_words, bary_location, gs_words, &info, &error)synthesizing a SPIR-V 1.5Geometrymodule (Trianglesin,Invocations 1,OutputTriangleStrip,OutputVertices 3) for the(VS, PS)pair:BuiltIn Positionacross the three triangle vertices and writes(1, 0, 0),(0, 1, 0),(0, 0, 1)toOutput vec3<f32>atbary_location;vec4<f32>Locationinput the PS declares (other thanbary_location) that the VS exports, leaves unread VS outputs unconsumed onVS -> GS(even if the VS exports an unread output atbary_location), and zero-fills any unexported PSLocationinput viaOpConstantNullwithout declaring a dangling GSInput(VUID-RuntimeSpirv-OpEntryPoint-08743);BuiltIn ClipDistanceorBuiltIn CullDistance(float[1..8]) and forwards it with the matching capability, rejecting mixedClipDistance+CullDistanceandShaderLayer/ShaderViewportIndex.runtime/shims/d3d12_vulkan_device.cpp: inPipelineState::create_graphicsandstage_words(StageSource::bary_fallbackfor lazy graphics pipeline builds), runsbuild_bary_fallback_gsafterlink_f16_halveson the post-link(vs, ps)words (clampingtop_locationagainstmaxGeometryInputComponents/maxGeometryOutputComponents) so relocated/synthesizedf16_halveslocations are forwarded automatically through the GS. Refuses mesh PSOs, explicitdesc.GS, rectangle-list PSOs, disabledgeometryShader/shaderClipDistance/shaderCullDistance(E_NOTIMPLviastream_unsupported), and non-trianglePrimitiveTopologyType(E_INVALIDARG).runtime/CMakeLists.txt,runtime/test/vk_test_device.h,runtime/test/*):shader_library_testwithbary_fallback_inputindex parsing checks;spirv_bary_fallback(spirv_bary_fallback_test.cpp), a portable pure-CPU test covering pass-through locations, unread VS locations, unexported PSFlatzero-fill,ClipDistance[2],CullDistance[3], combinedlink_f16_halves+build_bary_fallback_gs, and clean refusals;shaderClipDistanceandshaderCullDistancewhere available invktest::Deviceand addsd3d12_bary_fallback(d3d12_bary_fallback_test.cpp), exercising real Vulkan GPU draws through the Xbox-ABI proxy.Tested
ctest --output-on-failure -R "^(shader_library|spirv_bary_fallback|d3d12_bary_fallback)$", plusLEONIDA_LAZY_GRAPHICS=0andLEONIDA_LAZY_GRAPHICS=1): 3/3 passed on all runs:d3d12_bary_fallbackverified all 256 pixels of: (1) a non-uniform-W (w = 1, 2, 4) triangle checking perspective-correct(b0, b1, b2)+ pass-throughLocation 0(center=(184,49,22,191)vs affine(128,64,64,191)), (2)ClipDistance[1]clippingndc_x < 0while preserving barycentrics onndc_x > 0, (3) a 16-param VS + collidingf16_halves+bary_fallback_inputPSO combininglink_f16_halvesrelocation/synthesis withbuild_bary_fallback_gs, plusE_INVALIDARG/E_NOTIMPLrefusal checks.spirv_bary_fallback_test --dump-dir(gs_basic,gs_unread_vs,gs_zero_fill,gs_clip2,gs_cull3,gs_f16_linked) and validated each withspirv-val --target-env vulkan1.2andspirv-val --target-env vulkan1.3(0 errors).spirv_f16_halves,d3d12_f16_halves,d3d12_geometry,d3d12_translated_draw(4/4 passed).python -I scripts/check_no_game_data.pyon 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.VK_LAYER_KHRONOS_validationis 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
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).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)@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_baryandps_ij_computedat the translator head with both fallbacks enabled. I passed the resulting VS/PS modules and the location in their index directly tobuild_bary_fallback_gsfrom this PR's head,bff50180. Neither PS had f16-halves relocation metadata.ps_bary, location 1ps_ij_computed, location 3 withper_vertex: {"0": 0}PS pass-through Input at Location 0 is not vec4<f32>The computed input at location 0 is a flat array of three vec4s. The runtime currently reads only
bary_fallback_input.locationand expects the other inputs to be ordinary vec4s. The integration needs to carry theper_vertexmapping into GS generation and fill each array element from the corresponding vertex, as #1426's offline builder does. The existingps_ij_computedfixture would make a regression test for that link.The GPU draws used this PR's
vk_harnesson 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.@ytsodacan on GitHub · 2026-11-25 03:36 UTC · original · edited 2026-11-25 03:43 UTC
[KEEP]
31ff7194:change-scope,no-game-data,windows,linux-gpu-toolsandmacosare all queued.ps_ij_computed) is refused by the runtime builder (PS pass-through Input at Location 0 is not vec4<f32>), becauseper_vertexis 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.runtime/src/spirv_bary_fallback.h,runtime/shims/d3d12_vulkan_device.cppand tests). It sits alongside open #1426, #120, #1440 and #875 on the same fallback feature, so ordering needs a maintainer decision.ps_ij_computedregression test) and green CI.@whoalin1 on GitHub · 2026-11-25 07:53 UTC · original
Independent verification (native Windows 11, validation on):
spirv_bary_fallback+shader_librarypass; all 6 dumped GS SPIR-V modules passspirv-valunder bothvulkan1.2andvulkan1.3targets (12/12 clean).d3d12_bary_fallback,d3d12_f16_halves,d3d12_geometry,spirv_f16_halves; alsod3d12_bary_fallbackpasses withLEONIDA_LAZY_GRAPHICS=1.StageSource::bary_fallbackrebuild 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-ancestornegative), so the computed-I/Jper_vertexcase from the original report still needs that carry-over — matching @ecox982745's comment. #1426 is itself currently conflicting vs main.AI-assisted verification.
@aslan2142 on GitHub · 2026-11-25 19:30 UTC · original
Tested
483f0128emerged ontomain, Windows build under Wine, on Mesa lavapipe and RADV (gfx1036 iGPU):spirv_bary_fallbackpasses on both.d3d12_bary_fallbackpasses on lavapipe but fails on RADV, 3 of 3 runs, atd3d12_bary_fallback_test.cpp:623:CreateGraphicsPipelineStatefails for case 3 (vs_16p+ps_bary_f16). Cases 1 and 2 pass.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).
@ZroIsHere on GitHub · 2026-11-26 00:59 UTC · original
I opened a focused stacked follow-up for the low
maxGeometryInputComponentscase: 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.@mrgenty on GitHub · 2026-11-26 21:00 UTC · original
Tested at your current head
53df7d1a, merged ontomain73516a29together 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_fallbackandd3d12_bary_fallbackpass with no validation message, andrun_semantic_tests.pypasses: 498 files, 6,357 tests, 0 failed. The merge ontomainhad 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.@robot00f on GitHub · 2026-11-27 00:42 UTC · original
Thanks for testing on RADV
gfx1036and catching both the silent failure andVUID-RuntimeSpirv-Location-06272, @aslan2142 (and thanks @ZroIsHere forrobot00f/leonida#1)!Updated in
961d719d(merged currentmainwith no rebase/force-push):mainto clear the unrelated baseline CI failures (vk_null_descriptor_test.cppandcs_dpp_cmp.asm).Inputs onVS -> GS(runtime/src/spirv_bary_fallback.h, co-authored with @ZroIsHere):build_bary_fallback_gsnow tracks pointer aliases rooted at PSInputvariables (throughOpAccessChain/OpPtrAccessChain,OpCopyObject,OpSelect, andOpPhiintoOpLoad,GLSL.std.450InterpolateAt*,OpFunctionCall, andOpCopyMemory*) and zero-fills unread FSSM table declarations in the synthesized GS without declaring GSInputs from the VS.[rt] d3d12:diagnostics (runtime/shims/d3d12_vulkan_device.cpp):maxGeometryInputComponents,maxGeometryOutputComponents, andmaxGeometryTotalOutputComponentsfromVkPhysicalDeviceProperties::limits.BaryFallbackGsInfonow reports both per-vertex scalar component totals and highest4 * Location + componentsbounds (VUID-RuntimeSpirv-Location-06272), andcreate_graphicsrefuses pipelines that exceed device geometry limits beforevkCreateShaderModule/vkCreateGraphicsPipelineswhile logging the shader names, location/component count, and device limit (including when--bary-fallbackcapsf16_halvestop_location).spirv_bary_fallback_test&d3d12_bary_fallback_testformaxGeometryInputComponents = 64GPUs:ps_bary_pruned(16-param VS + 25 unread PS inputs pruned so live inputs stay< 16) andps_bary_f16_low(10-param VS +f16_halvesrelocated into0..14), both running within 64 geometry input components.vs_16p + ps_bary_f16case (where raw VS outputs occupy0..15, so relocatedf16_halvessit at[28, 29]and genuinely require>= 120geometry components), devices withmaxGeometryInputComponents < 120ormaxGeometryOutputComponents < 120now assert clean refusal andSKIPthat draw check instead of failing.max_geometry_input_components = 64test block exercising both the pruned/10-param passes and theLocation 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.3on all 7 synthesized GS binaries), and the Python/semantic test suites.AI-assisted: yes
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.