Repository navigation
Conversation
…SHADER-659) A p1 multiplies P10 and a p2 multiplies P20 with the value the register its op names. A pair written the other way round, one that names the same coordinate twice, and one that reads a plain v_mov copy rooted at the other coordinate are therefore modelled as the pair of weights they name - the attribute read per-vertex and weighted with those two values, on the computed-I/J path that already seeds v0/v1 from BaryCoordKHR - instead of refused. Sources whose value the model cannot name are still refused, as is an opposite-role read with no partner op to take the other axis from. A matching-role source keeps the centre-interpolated read it had: re-translating the 26503-listing corpus with main 902358c and with this change translated 26503 both times, every .spv byte-identical and index.json identical, which is what the source census says - no listing in the corpus names the other role. Confirmed by runtime/test/shaders/ps_interp_pair_roles.asm (4096/4096 pixels on a gfx1036 iGPU, AMD Radeon Graphics driver 31.0.24002.92, and on an RTX 4090 driver 32.0.16.2124; the standard pair in the same draw as the control), by the role-pair and copy-root cases measured by value in tests/semantic/test_interp_guards.py and tests/semantic/test_interp_p1lv_f16.py, and by the whole-corpus runs above. docs/design.md records the rule and how it was checked. Coordinated as SHADER-659 in #4571.
demoz53
added a commit
to demoz53/leonida
that referenced
this pull request
Nov 24, 2026
…ycentric its registers name (SHADER-659)
Contributor
Author
|
Closing this. I am moving my work to a different project and will not continue here. The pair-role reading in this branch was my best local understanding at the time and it did not land; I am leaving it unlanded rather than rebasing it. The branch will be deleted shortly. Written with an AI assistant. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as:
SHADER-659(claim comment).What this changes
A
v_interppair carries two barycentrics in one register pair, and the two ops of a site name which one they weigh with:v_interp_p1_*multiplies the value ofP10by its operand,v_interp_p2_*multipliesP20by its operand. So the question at a site is not which slot the operand sits in but what the register holds.v0holdsI,v1holdsJ, and a plainv_movchain rooted at one of them holds that same coordinate (interp_copy_sourcesis what proves the single write and the unwritten root).On
maina source in the other role is refused rather than modelled:interp_pair_src(tools/rdna2spirv.py:14325-14339) accepts onlyv{want}for the op,wantbeing 0 forp1and 1 forp2, or a copy rooted at it, and anything else raisesUnsupported("… only v{want} (or a plain v_mov copy of it) is modelled").interp_ij_analysishands those sources to it (:16709-16713). A program that reads the pair the other way round —p1onv1,p2onv0— is therefore either refused or, if the analysis happened to treat it as computed, modelled with the weights of the coordinates it does not name.This models the other-role case instead of refusing it: in
interp_ij_analysisa site is marked computed when its operand provably holds the other coordinate (reaching_write, or a copy whose root is the other register), the pair's weights become the two barycentrics swapped — each axis weighted with its own operand, which is what the hardware computes from the registers the ops name — and the prologue seedsv0/v1fromBaryCoordKHRfor such a pair. A source whose role matches, and a listing whose sources are the coordinates its ops weight, keep the existing path and their bit-identical.spv. A source whose value is unknown is still refused, naming the role. The contract row "v_interp operand guards" indocs/design.mdsays the rule and how it was confirmed.One correction to my own claim comment: it mentioned a pair held in an SGPR pair. This PR does not cover that — an SGPR operand is still refused as an operand — and it is not in the diff. What is covered is a pair read as a VGPR pair with the roles swapped, and both ops reading the same coordinate.
Fixture and tests
runtime/test/shaders/ps_interp_pair_roles.asm(new, wired intoruntime/test/shaders/check.pyandscripts/run_gpu_tests.py) draws the test triangle the other fixtures use —vs_tri/vs_ids:(-1,-1), (3,-1), (-1,3)withattr0 = (0,0), (2,0), (0,2)— over a 64×64 frame, soi = (x + 0.5)/128andj = (y + 0.5)/128,attr0.xinterpolates to2iandattr0.yto2j. Four pairs each read one component:v2p1(v1)/p2(v0)onattr0.x2jv3p1(v0)/p2(v1)onattr0.x(the standard pair, the control)2iv4p1(v0)/p2(v0)onattr0.y2iv5p1(v1)/p2(v1)onattr0.y2jso
mrt0 = (2j, 2i, 2i, 2j) = ((y+0.5)/64, (x+0.5)/64, (x+0.5)/64, (y+0.5)/64). A model that used the hardware weights whatever register the op named would give(2i, 2i, 2j, 2j), and the two differ in three of the four components.tests/semantic/test_interp_guards.pyaddstest_swapped_and_same_register_pairs_take_the_named_weights,test_opposite_role_read_without_its_partner_refusedandtest_copy_carries_the_coordinate_its_root_holds, and rewrites the expectations of the cases that used to assert a refusal.tests/semantic/test_interp_p1lv_f16.pyis adjusted for the same rule on the f16 pair.Evidence on
ece4ba5b3Head
ae07e4118, one commit rebased cleanly ontoece4ba5b3, 7 files, +183/−70:in
tools/rdna2spirv.pyacrossinterp_pair_srcandinterp_ij_analysis.py -3.13 -I -m unittest discover -s tests/semantic -p "test_interp_guards.py"— cleanece4ba5b3:Ran 14 tests / OK. This branch:Ran 15 tests / OK.-p "test_interp_p1lv_f16.py"— cleanece4ba5b3:Ran 36 tests / OK. This branch:Ran 37 tests / OK.tools/rdna2spirv.pytaken fromece4ba5b3and my tests left in place:test_interp_guards.pyRan 15 tests / FAILED (failures=2, errors=5)andtest_interp_p1lv_f16.pyRan 37 tests / FAILED (errors=1). Restoring the file returns both to OK, so the new cases only pass with the model change.--shard i/8(8 parts) and validated withspirv-as/spirv-valfrom Vulkan SDK 1.4.363.0: the 26,503 listings disassembled from the 1.0.2.1 executable, run once withmain's translator and once with mine into two separate output trees. Both produced 26,503.spvasmand 26,503.spv, and a byte-by-byte comparison of all 26,503 pairs on both kinds found 0 differences, with no file present on one side and missing on the other. So nothing in this game changes value, nothing that compiled stops compiling, and no listing is newly accepted or newly refused. The shape this PR models is one no shader in this game uses; what it changes is what happens at such a site instead of a refusal.py -3.13 -I -m unittest discover -s tests -p "test_docs_*.py"on this branch:Ran 47 tests in 45.692s / OK. The same battery on cleanece4ba5b3measured earlier in the same session:Ran 47 tests in 45.178s / OK. Same 47 tests, no failures either side.What was measured on hardware, and when
The value rule itself was checked on this machine's gfx1036 iGPU (
LEONIDA_HW_ARCH=gfx1036, Radeon 780M) on 2026-11-23, on the base that was current then: the fixture set ran green with the model change in, and the four pairs ofps_interp_pair_roles.asmproducedmrt0 = (2j, 2i, 2i, 2j)as above. That device run has not been repeated onece4ba5b3; the fixture is wired intoruntime/test/shaders/check.pyandscripts/run_gpu_tests.pyso anyone with a device can run it, and I can re-run it on this machine if you want the number on this base. Everything in the list above is CPU-side — the translator, its tests, and the whole-corpus translation — and needed no runtime build and no GPU.Written with an AI assistant.
Neighbour I read before claiming
The open draft #120 is SHADER-415 — computed I/J pairs under
--bary-fallback,bary_fallback_input.per_vertexandGen.pv_input(). It changes no pair-component ordering, and itsv_interp_mov_f32text is about array elements (p0reading element 0,p10/p20the deltas), which is a different thing from which coordinate ap1/p2operand holds. But it edits the same neighbourhood oftranslate()andassemble(), so if it lands first I will rebase this on it rather than ask you to resolve anything.