mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:55:52 +01:00
[PR #658] [MERGED] rdna2spirv: v_writelane_b32 keeps its destination's other lanes in read_before_write_vgprs (OLD-9910, SHADER-768) #698
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#698
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/658
Author: @LouisRiverstone
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism
Base:
main← Head:carry-old-9910📝 Commits (1)
f05bc53read_before_write_vgprs: v_writelane_b32 keeps its destination's other lanes (SHADER-768)📊 Changes
2 files changed (+112 additions, -12 deletions)
View changed files
➕
tests/semantic/test_writelane_read_before_write.py(+82 -0)📝
tools/rdna2spirv.py(+30 -12)📄 Description
Claimed in the coordination issue as: OLD-9910 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129736114)
Replaces the carried-over draft #175. I'm the original author of old upstream PR 9910.
What and why
SHADER-768:
read_before_write_vgprsintools/rdna2spirv.pytreatedv_writelane_b32as a full write of its destination.v_writelane_b32 vD, sSRC, sLANEwrites one lane ofvDand leaves the other lanes as they were. The translator's own emission already loads the oldvDand selects per lane. So when a shader's first touch of a VGPR is a writelane and it reads that register later, the value from shader entry is read in the lanes that weren't written.Treating every writelane destination as a read goes too far the other way. On the old PR, shdann showed a VS that spills an SGPR into one lane of
v40around the fetch call and reads it back withv_readlane; that VS would be rejected withfetch mapping. So the kept lanes are now carried: they count as a read only when something other thanv_readlane_b32reads the register before a full write.reg_reads_writes(per slice) counts the destination as read.DST_ALSO_READholds the accumulating ops that both functions used to list separately.Known approximation, also written in the docstring: a
v_readlaneof a lane the writelane didn't write reads the entry value, and that read isn't counted.Diff: the old branch's final tree diff applied on current
main(21625bca8), one commit. It applied cleanly.main'sv_swap_b32entry and the d16formatexclusion are kept.Tested
python -I tests/semantic/test_writelane_read_before_write.py: 9 tests OK (carried vs used lanes, the readlane spill, a full write ending the carry, shdann's VS spill and PSv0barycentric cases translated end to end).python -I scripts/run_semantic_tests.py tests/semantic: 466 files, 6117 tests, 0 files failed (Linux, Python 3.14.4).python -m compileall -q make_game.py tools tests: OK.GPUs tested: n/a (CPU-only change, no GPU fixture)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: this fixes a register-use analysis, not a translation rule)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.