mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:40:52 +01:00
[PR #509] [CLOSED] SHADER-659: a v_interp pair weighs with the barycentric its operand holds #557
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#557
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/509
Author: @fiestorra
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:carry/interp-pair-roles📝 Commits (1)
ae07e41Interpolate a v_interp pair with the barycentric its registers name (SHADER-659)📊 Changes
7 files changed (+183 additions, -70 deletions)
View changed files
📝
docs/design.md(+1 -1)📝
runtime/test/shaders/check.py(+32 -1)➕
runtime/test/shaders/ps_interp_pair_roles.asm(+22 -0)📝
scripts/run_gpu_tests.py(+14 -1)📝
tests/semantic/test_interp_guards.py(+64 -35)📝
tests/semantic/test_interp_p1lv_f16.py(+23 -20)📝
tools/rdna2spirv.py(+27 -12)📄 Description
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.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.