graphics: sample a copy of depth targets on hosts without feedback loops #1241
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1241
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1241/head"
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?
@TheCruZ on GitHub · 2026-10-08 19:37 UTC · original
pr/depth-copy-no-feedback-loop→main· +133 −15 · 4 files · 1 commits · closed without mergingSummary
Fixes the emulator exiting with
depth attachment feedback loop is not supported by the hostin Grand Theft Auto V (PPSA04263) on GPUs whose driver lacks the Vulkan feedback loop extensions (reported by a user of my fork with a Radeon RX 9060 XT).Problem
Some GTA V draws sample the depth or stencil target they also write. Vulkan allows that only through
VK_EXT_attachment_feedback_loop_layoutandVK_EXT_attachment_feedback_loop_dynamic_state; when the host does not provide both,attachment_feedback_loop_enabledis false andAcquireRenderTargetsexited on the first such draw.Change
Without feedback loops, for each texture binding that samples aspects the draw also writes,
AcquireRenderTargetscopies the sampled mips, layers and aspects of the depth image into an image of its own (TextureCache::CopyDepthForFeedback, outside the render pass) and rebinds the texture and its mip views to that copy. The draw then reads the depth from before it ran, as translators without feedback loops do. The copy has the depth image's layout without guest memory (never registered or tracked), is kept until the depth image is deleted (released through a deferred operation, since queued work may still sample it), recreated if the depth image changes shape, and refreshed for every such draw. Hosts with feedback loops keep sampling the attachment as before.Relation to #1187
#1187 handles hosts that have
VK_EXT_attachment_feedback_loop_layoutbut not the dynamic-state extension, by baking the feedback loop flag into the pipeline, with exact feedback semantics. This PR covers hosts without feedback loop support (the path that still exits after #1187, e.g. when the layout extension is missing too), at the cost of sampling the pre-draw depth. The two can coexist: with #1187 merged, this path would only run when the host has no usable feedback loop at all.Testing
shader_recompiler_compute_tests: newCheckRasterizationWithoutFeedbackLoopsruns the depth read/write draw ofCheckRasterization(true)with feedback loops disabled and checks that the attachment is not put in the feedback layout and that the pixel shader samples a different image (the copy). Passes in--sampled-depth-resource-onlyand in the default run.AI usage
AI (Claude Opus 5.5) was used to investigate the issue and to implement the change. I reviewed the code, understand it, tested it as described above, and wrote this description myself, in general fully tested the game while doing few missions and playing in-game with my GTA V fork, i will be bringing PRs here after test them enough.
@coderabbitai[bot] on GitHub · 2026-10-08 19:38 UTC · original
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@overlordxrz-source on GitHub · 2026-10-10 02:03 UTC · original
Hi @TheCruZ, great work on the GTA fork. I'm overlordxrz-source. I have #1187, which handles the other half of the feedback-loop exit: AMD drivers that have VK_EXT_attachment_feedback_loop_layout but not the dynamic-state extension. It complements your #1241, with no file overlap.
I saw you and Nmzik agreed he'd take fork commits with credit, so I don't want to duplicate that. Would you be OK with me sending a few of your small, self-contained ones that have no PR yet as separate upstream PRs, co-authored by you, with your measurements quoted? They are d8883d4b1 (LRU touch once per tick), dec15d520 (stencil associations without the full scan) and 8f092c828 (suballocate small BDA buffers). If you'd rather send them yourself or leave them to Nmzik, no problem at all, just say so.
One thing on the AMD "descriptor set does not fit a pool sized for it" exit in #829: the counts it prints are the default sizes, so LargePoolSizes didn't raise anything. Either that layout never reached RegisterLayout, or no type needs more than default/4. Logging the vk::Result and the registered counts in Allocate might narrow it down. Happy to test or rebase anything that would help.
AI-assisted: yes.
@TheCruZ on GitHub · 2026-10-10 10:32 UTC · original · edited 2026-10-10 10:34 UTC
@overlordxrz-source yeah feel free to pr any of my changes to the repo with any modification that you want, we need to speed the things up, a lot of forks with great fixes but a bottleneck to merge al together
@Nmzik i was think in that they other day, I'm not sure the level of control that gives GitHub to every branch but would be nice that you create 2 stages branchs i think where under request people can request access to modify those on granted they can directly merge all his changes to stage1, the Game there will have a lot of Bugs, but people can test his games with stage1 and directly remove(not modify to track it) a commit without intervention, all with pullrequests no direct changes to prevent multi dev removing work of each other, stage2 will be filled with pullrequests that are at stage1 for more than 5 days doing cherry picks in order to keep more stable ones, since stage1 has the commit and the revert commits those are omited in the migration, in stage2 we repeat the process for main but changes can't be added stage2 only reverted, if any dev does anything wrong first get a warning second is removed from the access, a discord Channel to talk about the stages, fixes and removals with help a lot to sync that
This can make that all parallel work from all devs get commited simultaneously without need to review every single commit and test on all games since devs are doing his tests with his games already
@overlordxrz-source on GitHub · 2026-10-10 22:41 UTC · original
@TheCruZ thank you, that's really generous. Heads-up on what I'm filing from your fork, each as its own PR on current main, with you as co-author and your measurements quoted as yours:
AssociateStencil(), which rebuilds the stencil plane.I'm holding d8883d4b1 (LRU touch once per tick) for now, given the new README rule. I'm also leaving out everything you already have open (#925, #931 and your #1220–#1259 PRs), and the big perf rewrites. PRs: #1388 and #1389. If you'd rather any of these go through you or Nmzik instead, say so and I'll close mine.
AI-assisted: yes.
@overlordxrz-source on GitHub · 2026-10-11 03:57 UTC · original
@TheCruZ I saw you closed this one. Was there a reason, like a problem you found or a plan to do it differently? If not, I'd like to re-propose it on current main with you as co-author. The exit is still there on main (renderDraw.cpp:539), it's the open #1123 stop on Arc, and mikeb1031 and TotoWood both confirmed your v7 fixes it. It applies to main without changes and merges cleanly with #1187, #1388 and #1389. If you'd rather it not go in, or plan to resend it yourself, I'll leave it.
I'd also send a4733f06a (linear-image readback on by default) for the vehicle damage in #971/#979, with your measurements quoted. Tell me if you'd rather it stay opt-in.
AI-assisted: yes.
@overlordxrz-source on GitHub · 2026-10-11 07:57 UTC · original
Thanks for reopening, @TheCruZ. For @Nmzik's convenience: I checked this head against current main together with #1187, #1388 and #1389. It merges cleanly with each of them and with all three stacked, and the changed TUs (textureCache.cpp, renderDraw.cpp) compile for x86_64 on every combination. With #1187 merged, the copy path here only runs on hosts that lack VK_EXT_attachment_feedback_loop_layout entirely, so the two cover different GPUs: this one for Arc B580 (#1123) and the RX 9060 XT report, #1187 for AMD drivers with the layout extension but no dynamic state. AI-assisted: yes.
@overlordxrz-source on GitHub · 2026-10-11 15:21 UTC · original
@TheCruZ ported your 840a5442 as #1421 (authorship kept, credited), since it fixes the #829 car-entry crash on its own. Shout if you'd rather file it yourself and I'll close mine.
@overlordxrz-source on GitHub · 2026-10-11 15:43 UTC · original
Correction to my earlier note: #1388 and this PR both add a TextureCache member on the same line of textureCache.h, so they conflicted. I've pushed a commit to #1388 that moves its member; they now merge cleanly in either order. Sorry for the noise.
@overlordxrz-source on GitHub · 2026-10-12 05:23 UTC · original
Hey @TheCruZ, thanks again for being OK with us porting your fork commits. Before we touch anything I went through the fork against main and your PRs, so we don't step on what you're already filing. These ones aren't in any upstream PR yet:
Small and self-contained
b5a4c947cshader: decode GPU-selected formatted loads from one window (the 70 s → 7 s pipeline for cs 0xfa8b1616). It applies to main as-is, but the shader is only reached with #1257/#1258. Fold it into #1258, or want us to file it after?a4733f06aread back linear images by default (wheels, #971/#888). You weren't sure about turning it on for every game, so I'll leave that call to you.04abd479f+2c8b9ddf5V_FRACT F32/F16/F64 clamp (the F64 one is At0mC3's). Heads-up: #1212 with the same idea was closed.e81661f3btessellation on by default (after #1245)ba0f01cc8descriptor pool for oversized sets (AMD crash). Looks like it belongs with #1257.Perf series (yours to shape, I'd rather not touch these)
e68140e23,6101f2da6,47f13b286,7d19adea66bb856a91,3bba1f44e,baa4dbbb2,31ed3c63496e9010ca,ed4da8708d14bf3e61,b90947f9f,6bf52ec7d,b8ef7162f, plus the small ones (661ee5430,450bc5890,b19caa460,c0c4f52a3,b2e6c7050,a3ae8b84b,0bff4ac5c)Which ones do you want to file yourself, and which would you like us to port (with you as author)? I have
b5a4c947cready as a patch with you as author, but I'm holding it until you say so.@TheCruZ on GitHub · 2026-10-12 09:18 UTC · original
To be right, i have created the PRs just to make them visible, you can port any of the changes from my fork to kytyPS5 upstream and close any of my PRs by yourself while i'm as a author/coauthor, taking care of all the PRs is a bit complicated for me due the constant changes of upstream, in my fork i have it sync with upstream to don't have conflicts if you want
And about things like "read back linear images", to be right for GTAV is just needed then i think that is a need on the emulator it self, other thing is that causes a bug on some specific game that we fix later or we just allow to disable it for the specific game etc then yeah i would enable for the emulator itself but i only tested it on GTAV
Pull request closed