mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:15:51 +01:00
[PR #1930] runtime/d3d12: the --bary-fallback geometry stage feeds computed I/J pairs (RT-BARY-FALLBACK-PER-VERTEX) #1938
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#1938
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/1930
Author: @mrgenty
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:rt-bary-fallback-per-vertex📝 Commits (7)
e7987dbTranslate computed I/J pairs when a GPU has no per-vertex inputs.b9191a3Merge remote-tracking branch 'origin/main' into fix/computed-ij-no-pervertex53df7d1runtime/d3d12: synthesize --bary-fallback geometry shader in graphics PSOsd36d9efMerge #1497 into rt-bary-fallback-per-vertex52d6df8Merge #1426 into rt-bary-fallback-per-vertex682de28runtime/d3d12: the --bary-fallback geometry stage feeds computed I/J pairs (RT-BARY-FALLBACK-PER-VERTEX)0b75329runtime/d3d12: computed I/J reads only the VS's raw outputs after f16 linking (RT-BARY-FALLBACK-PER-VERTEX)📊 Changes
24 files changed (+2879 additions, -108 deletions)
View changed files
📝
docs/design.md(+2 -2)📝
docs/testing.md(+4 -1)📝
make_game.py(+22 -4)📝
runtime/CMakeLists.txt(+10 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+95 -10)📝
runtime/src/shader_library.h(+34 -0)➕
runtime/src/spirv_bary_fallback.h(+551 -0)📝
runtime/src/spirv_f16_halves.h(+16 -3)➕
runtime/test/d3d12_bary_fallback_test.cpp(+1000 -0)📝
runtime/test/shader_library_test.cpp(+86 -0)📝
runtime/test/shaders/build.py(+9 -7)📝
runtime/test/shaders/check.py(+5 -4)➕
runtime/test/spirv_bary_fallback_test.cpp(+715 -0)📝
runtime/test/vk_test_device.h(+2 -0)📝
scripts/run_gpu_tests.py(+6 -5)📝
tests/semantic/support.py(+4 -2)📝
tests/semantic/test_interp_computed_ij.py(+153 -14)📝
tests/test_make_game_translator_flags.py(+20 -5)📝
tests/test_run_gpu_tests.py(+21 -18)📝
tests/test_shader_build_fallbacks.py(+22 -14)...and 4 more files
📄 Description
Claimed in the coordination issue as: RT-BARY-FALLBACK-PER-VERTEX (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7167254678)
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 #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 #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 #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 #1497 and #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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.