fix(gpu): correct SPIR-V reductions, BDA safety and texture mip views #1693
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!1693
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1693/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?
@herrMirto on GitHub · 2026-10-19 09:10 UTC · original
herrMirto:fix/spirv-shader-and-texture-fixes→main· +567 −44 · 18 files · 2 commits · closed without mergingA "small" PR containing changes made during some tests with EA FC27. Going from not rendering the main menus at all, until having a full match played, with pretty much everything being correctly rendered. Also, there was some improvements on FPSs, as on the first tries they were around 3fps and on latest around 10fps.
Tested on Linux(SteamOS) Ryzen 7 9800X3D + RX 9070 XT 16 GB + 32 GB RAM
The regression tests are based on shader and texture scenarios encountered while testing EA FC27.
@coderabbitai[bot] on GitHub · 2026-10-19 09:58 UTC · original · edited 2026-10-19 12:26 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
c076434d-d9e8-4559-9a68-c6bbc4781ebe📥 Commits
Reviewing files that changed from the base of the PR and between
cdb803a98dand8a71ab106f.📒 Files selected for processing: 17
src/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/bufferCache.hsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/image/image.cppsrc/graphics/host_gpu/renderer/image/imageInfo.cppsrc/graphics/host_gpu/renderer/image/imageInfo.hsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cppsrc/graphics/shader/recompiler/frontend/cfg/ShaderCFG.cppsrc/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cppsrc/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpptests/ScalarProvenanceTests.cpptests/ShaderRecompilerComputeTests.cpptests/shaderCfgTests.cpp🚧 Files skipped from review as they are similar to previous changes: 14
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
The changes add one-time BDA buffer initialization and validate flat BDA addresses. Image handling normalizes oversized guest mip views and includes guest mip metadata in cache identity. The shader recompiler adds unsigned-maximum and bitwise-OR subgroup reductions, adjusts jump-table selector handling, and probes usage flags for block-compressed volume images. Tests cover these paths, including mip layouts and cached contents.
Suggested reviewers:
nmzikPriority: ⬆️ High
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
8a71aNo confirmed issue prevents merging after normal checks.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 61.70% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 15 files. (2 skipped: 2 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
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.@ -144,0 +148,4 @@if (seed == nullptr || seed->Arg(2).Resolve() == Value(neutral)) return prefix;continue;}if (seed != nullptr && seed->Arg(2).Resolve() == Value(neutral)) {@coderabbitai[bot] on GitHub · 2026-10-19 09:58 UTC · original · edited 2026-10-19 12:18 UTC
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1567
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 40222
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 18758
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 24185
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4830
Preserve the neutral-seed check when
saved_execis empty.FullExec(Value(true))does not setsaved_exec. InCase::LiteralMasked, the execution controls are literaltrue, but the retained seed is still aSelectU32with a masked false branch. Line 141 returns before checking that branch. A wrong fallback can therefore reach the subgroup reduction for all three operations.Case::Literalcovers only the unmasked seed path.🐛 Suggested fix
Add a regression case with literal execution controls and a non-neutral masked seed.
✅ Addressed in commit
8a71ab1@coderabbitai[bot] on GitHub · 2026-10-19 09:58 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
1f050349-8a96-4cb8-9857-3806f9c577b5📥 Commits
Reviewing files that changed from the base of the PR and between
e5f0ee7fc2andcdb803a98d.📒 Files selected for processing: 18
src/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/bufferCache.hsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/image/image.cppsrc/graphics/host_gpu/renderer/image/imageInfo.cppsrc/graphics/host_gpu/renderer/image/imageInfo.hsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cppsrc/graphics/shader/recompiler/frontend/cfg/ShaderCFG.cppsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.incsrc/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cppsrc/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpptests/ScalarProvenanceTests.cpptests/ShaderRecompilerComputeTests.cpptests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@theantipopau on GitHub · 2026-10-20 00:50 UTC · original
Heads-up on process, not content: only the CodeRabbit check has reported here — no platform builds ran, so the +567/-44 across 18 files (including shader CFG, SPIR-V emitters, and mip-view paths) is currently unverified by CI. A rebase onto current main plus a push should trigger the build matrix. Note the base has moved a lot underneath this (VR #1726, EQAA handling, CopyImage clamping at
440245f6); worth a fresh conflict check too.@Nmzik on GitHub · 2026-10-20 02:48 UTC · original
@herrMirto Hi! Can you explain the other commits you made and how you came up with those fixes?
For me, the game goes into a match after the “Preserve reused selectors in S_SETPC dword jump tables” fix
@Nmzik on GitHub · 2026-10-20 03:03 UTC · original
@herrMirto on GitHub · 2026-10-20 06:57 UTC · original
Hi, I might have done my fork and my last pull on the wrong moment. But basically, the majority of the changes were related to not rendering the initial menu, where you can select "Kick off" and then the others one. The fixes were focused mostly on adjusting the shaders.
I will try again with the main branch and see how it goes!
@Nawid3333 on GitHub · 2026-10-20 16:17 UTC · original
@herrMirto a note on the reduction part, so it doesn't get done twice: my open #1570 generalizes the same
UMinReductionMatcher(302240da) and conflicts with this PR in six files. It covers UMax and bitwise OR as well (plus add, UMin, SMin, SMax, AND and XOR, and the row_xmask butterfly shape next to the row_shr scan), with 32 graphics cases.One difference: this PR also rejects a match with a literal full EXEC when the seed select's fallback isn't the operation's neutral value; #1570 keeps main's behaviour there. If that check came from an FC27 shader, I'd like to look at it.
If you split the PR when you retry on main, the reduction part could rest on #1570, or the other way round, whichever @Nmzik prefers.
@Nmzik on GitHub · 2026-10-20 19:18 UTC · original
@herrMirto I'm willing to accept your other changes if you can explain them (or at least tell me which mode/options you used and what graphical artifacts you noticed and where). For now, as far as I can see, your other changes arent necessary. Thanks for understanding!
@Nmzik on GitHub · 2026-10-20 19:18 UTC · original
@herrMirto Preserve reused selectors in S_SETPC dword jump tables. credited to you in main branch
@herrMirto on GitHub · 2026-10-21 07:51 UTC · original
Hi everyone, sorry for the delay. My earlier explanation wasn't detailed enough.
I was testing the Kick Off mode on EA FC27 on SteamOS.
After selecting Kick Off and trying to enter the mode, the game would close. During the investigation I also encountered problems with the main menu rendering, the pre-match events and so on.
The changes accumulated while investigating those failures. With the combined changes, I eventually played a full match, but I can't claim that every remaining change is necessary.
Here is the reasoning behind the changes:
S_SETPC selector reuse: the shader translation rejected a jump-table pattern where the table load overwrites its selector register. After that fix, the previously failing shader completed SPIR-V emission. Thanks @Nmzik for integrating it and crediting me.
UMax and OR reductions: I extended the existing UMin matcher to cover the equivalent maximum and OR sequences, avoiding dependence on endpoint lanes that may be absent during fragment execution. At that stage of the investigation, the branch progressed past the previously hanging pipelines and then encountered a separate mip-count validation error involving a 64×64 texture. (This was mainly happening after clicking on "Kick-Off", during the loading of the next menus)
Mip views: the change represents selected guest mip levels within Vulkan's limits while preserving their original memory offsets, array strides and mip-tail layout.(This was happening mainly before the rendering of the match or right after the teams were selected)
Texture-cache identity: this concerns cached texture images, rather than the shader cache. While reviewing the mip-view changes, I added a regression where two different extra mips become 1×1 host images. The cache considered them interchangeable despite their different physical layouts. That test failed before the fix and passed afterward, but I haven't demonstrated that this collision caused the Kick Off crash.
BDA handling: these changes reject invalid guest addresses before page-table lookup and initialize the page-table and fault storage before GPU use. They address memory-handling cases found during the investigation, but I haven't isolated their individual effect on FC27.
Compressed 3D textures: this adds a fallback when a driver supports sampled compressed volumes without extended usage. This also needs an isolated reproduction against current main before I can justify it as an FC27 requirement.
@Nawid3333, thanks for pointing out the overlap with #1570. I'm fine with separating the reduction changes and using your broader implementation if that's preferred.
I am far from being a C++ developer, but I am curious enough to try to put some code together, test and compare between the attempts.
Let me know if you need more clarification.
Pull request closed