mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:10:53 +01:00
[PR #2239] rdna2spirv: lower computed I/J barycentrics under --f16-interp-fallback (SHADER-F16-INTERP-COMPUTED-IJ) #2242
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#2242
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/2239
Author: @zmasi
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:fix/rdna2spirv-f16-interp-computed-ij📝 Commits (1)
cd8d9aardna2spirv: lower computed I/J barycentrics under --f16-interp-fallback📊 Changes
11 files changed (+512 additions, -63 deletions)
View changed files
📝
docs/design.md(+1 -0)📝
runtime/test/shaders/build.py(+6 -6)📝
runtime/test/shaders/check.py(+4 -4)📝
scripts/run_gpu_tests.py(+4 -5)➕
tests/semantic/fixtures/ps_ij_computed_deriv_fallback.asm(+30 -0)📝
tests/semantic/spirv_mini_interp.py(+24 -0)📝
tests/semantic/test_interp_computed_ij.py(+7 -7)➕
tests/semantic/test_interp_computed_ij_fallback.py(+312 -0)📝
tests/test_run_gpu_tests.py(+17 -13)📝
tests/test_shader_build_fallbacks.py(+30 -16)📝
tools/rdna2spirv.py(+77 -12)📄 Description
Claimed in the coordination issue as:
SHADER-F16-INTERP-COMPUTED-IJ(https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7188273837)Depends on: #1426 (orthogonal topic: #1426 handles
--bary-fallbackwithFlat vec4[3]geometry-shader pass-through and leavesF16_HALVES and not BARY_FALLBACKrefused; listed here because adjacent hunk context intools/rdna2spirv.pyandtests/test_shader_build_fallbacks.pysits nearby on merge)What and why
When
per_vertex_inputsis unavailable and no geometry shader is used (--f16-interp-fallbackwithout--bary-fallback, e.g. on MoltenVK / Apple Silicon whereBuiltIn BaryCoordKHRis available withoutPerVertexKHRor geometry shaders),interp_ij_analysisintools/rdna2spirv.pyrefused all 207 pixel shaders in the corpus that compute custom(I, J)barycentrics into VGPRs (computed I/J pair under --f16-interp-fallback: no PerVertexKHR inputs).OpCapability InterpolationFunction(InterpolateAtOffset) cannot be used without enablingsampleRateShadingand is rejected onBaryCoordKHRby SPIRV-Cross MSL.Because perspective-correct
BaryCoordKHR(I, J)already absorbs1/W, every smooth-interpolated inputP(both standardf32attributes and decoded--f16-interp-fallbackhalves) satisfies the exact affine relationP = P_0 + I \cdot P_{10} + J \cdot P_{20}across all four invocations of a2 \times 2screen quad. UnderF16_HALVES and not BARY_FALLBACK:OpDPdxFineandOpDPdyFine(OpCapability DerivativeControl, core Vulkan 1.0, zero device feature bits, zero extraLocations, zero geometry shader) ofBaryCoordKHR.y/.zand each computed(attribute, component)channel into uniform%entry.±inf, andNaNdeterminants using integer IEEE-754 normal-range bit comparisons (0x00800000 <= (OpBitcast_u32(det) & 0x7FFFFFFF) < 0x7F800000, avoidingOpFDiv-by-zero and MoltenVK'sOpFOrdNotEqualNaN hazard) so degenerate quads cleanly fall back to pixel-centerP_c.P(I', J') = P_c + \alpha \cdot d_x P + \beta \cdot d_y Pwith pure scalar ALU at eachv_interpsite, including inside non-uniformEXEC-masked branches and loops.--bary-fallback(BARY_FALLBACK) refusal and defaultPerVertexKHRemission completely unchanged.Tested
--f16-interp-fallback):26,296 / 26,503->26,503 / 26,503(100%) translated and26,503 / 26,503passspirv-val(--target-env vulkan1.2 --allow-offset-texture-operand); all207 / 207previously refused pixel shaders passspirv-val, remain byte-identical under default flags, and remain refused under--bary-fallbackalone.LEONIDA_F16_INTERP_FALLBACK=1 LEONIDA_BARY_FALLBACK=0,VK_LAYER_KHRONOS_validation1.4.363):runtime/test/shaders/build.py vs_ids ps_ij_computed ps_interp_f16_high vs_f16_pack:4/4translated,4/4spirv-valpass (OpCapability FragmentBarycentricKHR+OpCapability DerivativeControl, zeroPerVertexKHR).vk_pipeline_check:2/2PS modules ok,2/2PS pipelines ok,0validation errors.vk_harness vs_ids.spv ps_ij_computed.spv(64x64):4,096 / 4,096pixels pass (exact_xyw = 4096/4096,exact_z_bits = 4096/4096,max_err_z = 0.0);scripts/run_gpu_tests.py --filter ps_ij_computedpasses1/1.python -m compileall -q make_game.py tools tests,tests/semantic/test_interp_computed_ij_fallback.py,tests/semantic/test_interp*.py(211/211),tests/test_shader_build_fallbacks.py(7/7),tests/test_run_gpu_tests.py(71/71),tests/test_text_write_line_endings.py,tests/test_docs_*.py, andpython -I scripts/check_no_game_data.pyacross all touched files (all pass).GPUs tested: NVIDIA GeForce RTX 3090, driver 610.88 (Vulkan 1.4.341, Khronos validation layer 1.4.363), Windows 11 x64
AI-assisted: yes
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.