mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-26 08:15:59 +03:00
[PR #3224] [MERGED] ir_passes: Fold readlane with ff1 pattern #3317
Labels
No labels
Bloodborne
bug
contributor wanted
documentation
enhancement
frontend
good first issue
help wanted
linux
pull-request
question
release
verification progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shadPS4#3317
Loading…
Add table
Add a link
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/shadps4-emu/shadPS4/pull/3224
Author: @raphaelthegreat
Created: 7/10/2025
Status: ✅ Merged
Merged: 7/10/2025
Merged by: @georgemoralis
Base:
main← Head:readlane-ff1📝 Commits (1)
cbea56bir_passes: Fold readlane with ff1 pattern📊 Changes
3 files changed (+17 additions, -4 deletions)
View changed files
📝
src/shader_recompiler/backend/spirv/emit_spirv_instructions.h(+1 -1)📝
src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp(+2 -3)📝
src/shader_recompiler/ir/passes/readlane_elimination_pass.cpp(+14 -0)📄 Description
I've recently spotted the following shader pattern, used in some waterfall loops, which is essentially a we-have-v_readfirstlane_b32-at-home
Which on main gets translated to
There are 2 issues here. First EmitReadLane assumes the lane id is a constant u32, which is not always the case (the large number here is because that's a pointer stored in the Opaque IR::Value). Second is that s_ff1_i32_b64 is implemented with GetSrc64 instead of thread bits. This instruction should probably be swapped to thread bits but because I don't remember the original usecase, which could have been 64-bit, I won't change it in this PR.
To solve this issue, the readlane elimination pass will detect when readlane has an non immediate lane coming from FindILSB64 and substitute it with ReadFirstLane
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.