Skip to content

fix(shader): v_writelane_b32 ignores EXEC - #411

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:fix/writelane-ignores-exec
Oct 4, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:fix/writelane-ignores-exec

Conversation

@MichonGoddijn231849

Copy link
Copy Markdown
Contributor

What

v_writelane_b32 writes one lane of a VGPR and ignores EXEC (RDNA2 ISA, V_WRITELANE_B32). The translation wrote its result through the exec-masked VGPR write, so it became Select(exec bit of LaneId, WriteLane(...), old). A write to a lane that is inactive at that point was dropped.

Compilers use v_writelane/v_readlane to spill SGPRs into VGPR lanes inside divergent control flow, where the spill lane is often inactive. Besides the wrong value at run time, the exec select hid the WriteLane from ReadLaneEliminator, so descriptors reloaded with v_readlane stayed lane-dependent. Draws then failed with GetSamplerResource dword 0 is not a valid runtime value; chain: ReadLane(SelectU32(INotEqual32(... LaneId ...), WriteLane(...), ...)).

The WriteLane result now goes straight to the destination VGPR. The SPIR-V lowering already selects per invocation on SubgroupLocalInvocationId == lane.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • ctest: all tests pass. agc_driver_write_lane now sets exec_lo = 1 around the write to lane 5. Without the fix it fails (lane 5 keeps its old value); with it, it passes.
  • GTA V (PPSA04264), Prologue: about 950 draws per 10 s were skipped with the ReadLane chain above. None remain.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none. fix(shader): wrap the v_readlane_b32 lane select at the wave size #322 also edits tests/execution/WriteLane.cpp (and the WriteLane lane wrap); whichever merges second keeps both changes
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

V_WRITELANE_B32 writes the selected lane regardless of EXEC, but the
translation routed it through the exec-masked VGPR write, so a spill to an
inactive lane was dropped. The WriteLane test now writes lane 5 while only
lane 0 is active.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Oct 2, 2026
@oneandonlydean
oneandonlydean merged commit 7384588 into boykopovar:main Oct 4, 2026
3 checks passed
@MichonGoddijn231849
MichonGoddijn231849 deleted the fix/writelane-ignores-exec branch October 9, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants