fix(shader): v_writelane_b32 ignores EXEC #411

Merged
MichonGoddijn231849 merged 1 commit from upstream-pr/411 into main 2026-10-04 01:06:17 +00:00
MichonGoddijn231849 commented 2026-10-02 21:56:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-02T21:56:37Z.


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. #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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4721895771 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/411). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-10-02T21:56:37Z. --- ### 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 - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none. #322 also edits `tests/execution/WriteLane.cpp` (and the WriteLane lane wrap); whichever merges second keeps both changes - [x] AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!411
No description provided.