mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-25 15:56:00 +03:00
[PR #2786] [MERGED] resource_tracking_pass: Add heuristic to detect incorrectly tracked buffer sharp. #2978
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#2978
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/2786
Author: @squidbus
Created: 4/14/2025
Status: ✅ Merged
Merged: 4/15/2025
Merged by: @squidbus
Base:
main← Head:sharp-track📝 Commits (1)
21531f1resource_tracking_pass: Add heuristic to detect incorrectly tracked buffer sharp.📊 Changes
1 file changed (+31 additions, -4 deletions)
View changed files
📝
src/shader_recompiler/ir/passes/resource_tracking_pass.cpp(+31 -4)📄 Description
Currently sharp tracking does a breadth-first search which always visits right-hand arguments first. In some cases, this may follow phis down paths that cannot be reached by an actual shader, leading to the incorrect sharp source.
For example, take the following excerpt of control flow:
Depending on the first branch, this shader will either unconditionally go to a terminating branch at the end of the shader, or continue on with the rest of the code. After control flow and SSA, this results in phis under
L176_0choosing between user data at the beginning of the shader and values loaded inside the unconditionally branching block, despite it being unreachable. This is fine for actual shader execution since the phis will resolve based on the block that execution came from, but since sharp tracking does not consider reach-ability, it may track to the incorrect source inside the branching block.This PR attempts to help deal with this problem by adding a heuristic for buffers to detect invalid sharp tracking paths. If the tracking reaches a sharp that points to a buffer with an invalid type value (must be 0), it assumes that the sharp must have been tracked wrong. The tracking is re-run with it excluded, and the process repeats until either a valid looking source is found or all paths are exhausted.
The proper solution would be full reach-ability testing in sharp tracking, but in lieu of that (I admittedly don't have a strong enough grasp on the control flow stuff to implement this myself), this heuristic can help some games running into the issue.
Fixes a crash going in-game in CUSA16404.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.