Repository navigation
rdna2spirv: load BaryCoordKHR for untouched or conditional v0/v1 in computed I/J pairs - #2742
Conversation
…omputed I/J pairs
|
Independent Vulkan check at One related case remains: EXEC can skip a VGPR write without a scalar branch. This straight-line pixel shader illustrates it: s_and_saveexec_b32 s10, s0
v_mov_b32_e32 v0, 0
s_mov_b32 exec_lo, s10
v_interp_p1_f32_e32 v2, v0, attr0.x
v_interp_p2_f32_e32 v2, v1, attr0.x
v_interp_p1_f32_e32 v3, v0, attr0.y
v_interp_p2_f32_e32 v3, v1, attr0.y
exp mrt0 v2, v3, v2, v3 done vm
s_endpgmPass I tested broadening the existing |
|
Tested on Linux (WSL2 Ubuntu, Python 3.10.12) and native Windows 11 (Python 3.13.1), CPU only: pass. Head fb50143, clean merge with main.
|
|
Thanks @duudiis for the independent RTX 5070 verification and for catching the straight-line EXEC-masked write case! Updated in |
|
Independent follow-up for computed I/J ( AI-assisted (Codex). |
|
Tested Independent synthetic Vulkan check of
AI-assisted verification. |
|
The GPU A/B isolates the effect of
AI-assisted verification. Only synthetic fixtures were used. |
|
Thanks @padhossein for catching the copied-coordinate case! Reproduced locally (got |
|
Tested Retested the copied-coordinate GPU case on
AI-assisted verification. |
Claim: #2716 (comment)
Problem
In
tools/rdna2spirv.py:translate(),no_barystripsv_interpsource VGPRs before callingread_before_write_vgprs(no_bary)so pristinev_interppairs don't pull inBaryCoordKHR. Later,interp_ij_analysis()promotes av_interp_p1/p2pair to computed I/J (PerVertexKHR) whenever eitherv0orv1is written anywhere in the shader, and emission loads both I and J from%vgpr.When a pixel shader overwrites only one coordinate (e.g.
v_mov_b32 v0, 0while leavingv1as hardwareJ, or vice versa) or overwritesv0/v1conditionally inside a branch, nothing outsidev_interpreads the untouched coordinate, sog.frag_inputsomitsbary_i/bary_j. The emitted SPIR-V reads0.0from zero-initialized%vgpr[0]/%vgpr[1]instead ofBaryCoordKHR.y/.z, silently miscompiling the interpolated attribute.Fix
interp_ij_analysis(insns, g)annotates computed sites withins["ij"], runread_before_write_vgprskeeping the source VGPRs of computedv_interpsites (and in branchy shaders, anyv0/v1named by a computed site'sij), registering any missing0: "bary_i"/1: "bary_j"entries ing.frag_inputs(plusg.cu(r)).v0andv1beforev_interpremain unchanged.tests/semantic/test_interp_computed_ij.pycovering only-Ioverwritten, only-Joverwritten, and conditional overwrite across a branch (both taken and untaken paths).Validation
main(49475796), returning0.0instead of2*I/2*Jfor the untouched/untaken coordinate.python -m unittest discover -s tests/semantic -p "test_interp*.py": 138/138 passed (18/18 intest_interp_computed_ij.py)python -I tests/test_resource_hygiene.py: 2/2 passedpython -I tests/test_text_write_line_endings.py: 2/2 passedpython -m compileall -q make_game.py tools tests: passedLimitations
spirv_mini_interpand synthetic fixtures only (no GPU run, nospirv-val/llvm-mc, no retail shader corpus).AI-assisted.