mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #1497] runtime/d3d12: synthesize --bary-fallback geometry shader in graphics PSOs #1527
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1527
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1497
Author: @robot00f
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:feat/rt-bary-fallback-pso📝 Commits (1)
53df7d1runtime/d3d12: synthesize --bary-fallback geometry shader in graphics PSOs📊 Changes
8 files changed (+1747 additions, -10 deletions)
View changed files
📝
runtime/CMakeLists.txt(+10 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+90 -10)📝
runtime/src/shader_library.h(+10 -0)➕
runtime/src/spirv_bary_fallback.h(+428 -0)➕
runtime/test/d3d12_bary_fallback_test.cpp(+678 -0)📝
runtime/test/shader_library_test.cpp(+34 -0)➕
runtime/test/spirv_bary_fallback_test.cpp(+495 -0)📝
runtime/test/vk_test_device.h(+2 -0)📄 Description
Claimed in the coordination issue as: RT-BARY-FALLBACK-PSO (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7149404640)
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.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.