Repository navigation
vk_pipeline_check: synthesize --bary-fallback GS stage for PS pipelines (VK-PIPELINE-CHECK-BARY-FALLBACK) - #1890
Conversation
madvillain91
left a comment
There was a problem hiding this comment.
Reviewed diff and independently verified commit 6a707a00d (including stacked #1497 commit 483f0128e) on Windows 11 with an NVIDIA Ampere GPU (against main 71a769d7d):
Environment
- OS: Windows 11 26H2 (build 26300.9711)
- Python: CPython
3.12.3(python -I) - Compiler: VS 2022 Build Tools (MSVC
19.44.35230.0, Ninja,RelWithDebInfo) - Vulkan SDK:
1.4.363.0 - GPU: NVIDIA GeForce RTX 3070 Ti (Ampere, 8192 MiB), driver
617.14, Vulkan1.4.351
Checks run
git diff --checkacross both commits (483f0128e,6a707a00d): clean- Built
spirv_bary_fallback_test,shader_library_test,d3d12_bary_fallback_test,vk_pipeline_check, andpipeline_cache_seed_testcleanly in an isolated build: 0 errors spirv_bary_fallback_test: PASSshader_library_test: PASS (SHA-256, inflate, JSON, FSSM extraction, FSPX programs and index lookup OK)d3d12_bary_fallback_test(plain &LEONIDA_VK_VALIDATION=1): PASS, 0 VUIDs (ps_bary (perspective w=1,2,4): center=(184,49,22,191) OK,ps_bary + ClipDistance[1]: left half clipped, right half interpolated OK,ps_bary_f16 (combined f16_halves relocation + bary GS): all 256 pixels OK)pipeline_cache_seed_test <vk_pipeline_check.exe>(LEONIDA_VK_VALIDATION=1): PASS, 0 VUIDs (ok: vk_pipeline_check cache hits on the runtime's device (NVIDIA GeForce RTX 3070 Ti))python -I runtime/test/check_vk_pipeline_bary_fallback.py --ctest --exe <vk_pipeline_check.exe>(plain &LEONIDA_VK_VALIDATION=1): 6/6 PASS in both modes (~5.7s)python -I tests/test_vk_pipeline_check_index.py -v(withLEONIDA_VK_PIPELINE_CHECKset): 13/13 PASS (1.62s)
Diff notes
parse_bary_fallback_input()cleanly validates"bary_fallback_input"(nullor object with unsigned"location" < 32) before loading Vulkan.stub_cache(std::map<std::string, StubEntry>) preserves reference stability across concurrent worker insertions, andgs_modis always destroyed after pipeline creation.geometryShader,shaderClipDistance, andshaderCullDistancefeature gates match the runtime path ind3d12_vulkan_device.cpp.
Not checked
- Corpus run with translated
--bary-fallbackshaders, non-NVIDIA hardware, or a GPU lackinggeometryShader/VK_KHR_fragment_shader_barycentric.
LGTM from this Windows 11 + NVIDIA RTX 3070 Ti verification (AI-assisted verification; synthetic test fixtures only, no game data).
|
The new bary-fallback test script passes on an AMD Radeon 780M The checker's new bary-fallback path builds a real pipeline on real hardware here, with synthetic fixtures: AMD Radeon 780M Graphics (RDNA3 iGPU), Windows 11, driver 32.0.32015.12012, Vulkan apiVersion 1.4.359. Built from this PR's tree (
What that means on this card: the checker built the synthesized Scope of what ran: tests 5 and 6 skip on a device without This exercises the checker half only. The runtime/D3D12 half - the AI-assisted (MiniMax Code). No game files. |
6a707a0 to
13b1ff9
Compare
… 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)
When `tools/rdna2spirv.py --bary-fallback` translates a pixel shader (for GPUs
without `VK_KHR_fragment_shader_barycentric` or drivers with broken
`BaryCoordKHR`), the emitted Fragment SPIR-V reads perspective barycentrics from
an ordinary smooth `vec3<f32>` `Input` recorded under
`"bary_fallback_input": {"location": N}` in `index.json`, while `"inputs"` lists
only the `vec4<f32>` user `param` locations exported by `stubs/vs_<inputs>.spv`.
Previously `vk_pipeline_check` ignored `"bary_fallback_input"` and built a
2-stage `VS_stub + PS` pipeline, leaving `Location N` unwritten by the preceding
stage (`VUID-RuntimeSpirv-OpEntryPoint-08743`), omitting the `geometryShader` /
`shaderClipDistance` / `shaderCullDistance` feature gates, and writing a 2-stage
entry into `pipeline_cache.bin` that misses the runtime's 3-stage `VS + GS + PS`
pipeline key.
- Parse `"bary_fallback_input"` in `vk_pipeline_check`'s `JsonParser` into
`ShaderMeta::bary_fallback_location` (accepting `null` or an object with an
unsigned 32-bit `"location" < 32`, rejecting non-objects, missing `"location"`,
and out-of-range locations with exit code 2 before loading Vulkan).
- Cache each loaded partner stub's SPIR-V words alongside its `VkShaderModule`
in `stub_cache` without re-reading disk per shader.
- Skip `--bary-fallback` `ps` entries with `no geometryShader` when the selected
device lacks `geometryShader`; otherwise synthesize the triangle pass-through
`VK_SHADER_STAGE_GEOMETRY_BIT` module in memory via
`leonida::build_bary_fallback_gs` (`runtime/src/spirv_bary_fallback.h`), gate
forwarded VS `ClipDistance` / `CullDistance` on `shaderClipDistance` /
`shaderCullDistance` before creating the GS module, compile the 3-stage
`VS + GS + PS` graphics pipeline, and fail the check (`PIPELINE FAIL`, exit 1)
if `build_bary_fallback_gs` rejects an incompatible `VS`/`PS` interface.
- Add CTest `vk_pipeline_check_bary_fallback`
(`runtime/test/check_vk_pipeline_bary_fallback.py`), index parser cases in
`tests/test_vk_pipeline_check_index.py`, and documentation in
`docs/pipeline_check.md`.
Depends on: ProjectLeonida#1497
Claim: ProjectLeonida#14 (comment)
AI-assisted: yes (Antigravity)
13b1ff9 to
79a2437
Compare
|
Hi @robot00f, thanks for this pull request. It currently conflicts with AI-assisted (Claude Code, Claude Opus 5.5). |
Claimed in the coordination issue as:
VK-PIPELINE-CHECK-BARY-FALLBACK(#14 (comment); continued in #1608)Depends on: #1497
What and why
When
tools/rdna2spirv.py --bary-fallbacktranslates a pixel shader (for GPUs withoutVK_KHR_fragment_shader_barycentric, such as NVIDIA Pascal, or drivers with brokenBaryCoordKHR), the Fragment SPIR-V reads perspective barycentrics from a smoothvec3<f32>Inputrecorded under"bary_fallback_input": {"location": N}inindex.json, while"inputs"lists only thevec4<f32>userparamlocations exported by<spirv dir>/stubs/vs_<inputs>.spv(tools/spirv_stubs.py).Previously
runtime/test/vk_pipeline_check.cppignored"bary_fallback_input"and built a 2-stageVS_stub + PSgraphics pipeline (runtime/test/vk_pipeline_check.cpp:1748-1764), which:Location Nunwritten by the preceding stage (VUID-RuntimeSpirv-OpEntryPoint-08743);geometryShader(shaderClipDistance/shaderCullDistance); andpipeline_cache.binthat misses the runtime's 3-stageVS + synthesized GS + PSpipeline (runtime/d3d12: synthesize --bary-fallback geometry shader in graphics PSOs #1497).Changes:
runtime/test/vk_pipeline_check.cpp:"bary_fallback_input"inJsonParserintoShaderMeta::bary_fallback_location(acceptingnullor{"location": 0..31}and rejecting non-objects, missing"location", or out-of-range locations before loading Vulkan).VkShaderModuleinstub_cachewithout re-reading disk per shader.--bary-fallbackpsentries withno geometryShaderwhenf2.features.geometryShaderis unavailable; otherwise synthesizes the triangle pass-throughVK_SHADER_STAGE_GEOMETRY_BITmodule in memory vialeonida::build_bary_fallback_gs(runtime/src/spirv_bary_fallback.h), gates forwarded VSClipDistance/CullDistanceonshaderClipDistance/shaderCullDistancebeforevkCreateShaderModule, compiles the 3-stageVS + GS + PSgraphics pipeline, and fails the check (PIPELINE FAIL, exit 1) ifbuild_bary_fallback_gsrejects an incompatibleVS/PSinterface.vk_pipeline_check_bary_fallback(runtime/test/check_vk_pipeline_bary_fallback.py, pure Python stdlib SPIR-V fixtures so Windows/Linux/macOS CI need nollvm-mc), index parser tests intests/test_vk_pipeline_check_index.py, and docs indocs/pipeline_check.md.Tested
ps_bary.asm(--bary-fallback,VK_LOADER_LAYERS_DISABLE=~implicit~,__GL_SHADER_DISK_CACHE=0):VS_stub + PS)VS_stub + bary_GS + PS)tools/shader_link_check.py)Location 1unwritten byvs_0.spv,VUID-RuntimeSpirv-OpEntryPoint-08743)1 compatible, 0 incompatible, 0 invalid(2 links checked)--cache-feedback)0 hits, 1 no hit reported(confirms 2-stage cache missed 3-stage pipeline)--cache-feedback)1 hits, 0 no hit reportedvk_pipeline_check_bary_fallback,vk_pipeline_check_cli,pipeline_cache_seed,vk_pipeline_check_stack,spirv_bary_fallback,d3d12_bary_fallback— all PASS 3/3python -I runtime/test/check_vk_pipeline_bary_fallback.py -v— PASS (valid 3-stageVS + GS + PScompile + cache write, incompatiblevec4bary_fallback_inputrejected withPIPELINE FAILexit 1, malformedindex.jsonbary_fallback_inputrejected with exit 2)python -I tests/test_vk_pipeline_check_index.py -v— 13/13 PASSpython -I tests/test_ctest_registration.py,tests/test_docs_links.py,tests/test_docs_table_rows.py,tests/test_text_write_line_endings.py— PASSpython -I scripts/check_no_game_data.pyon all touched files — PASSgeometryShader(MoltenVK; covered by CI'smacosjob).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 (rebased onto runtime/d3d12: synthesize --bary-fallback geometry shader in graphics PSOs #1497, which is rebased onto currentmain).docs/design.md, with how it was confirmed (n/a:vk_pipeline_checkchecker change, no translator change).