graphics: fix sparse-wave reductions, BDA bounds and extra mip views #1898
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!1898
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1898"
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-25 12:33 UTC · original
herrMirto:fix/fc27-shader-mip-corrections→main· +429 −35 · 14 files · 1 commits · openI revisited the graphics changes from #1693 on current main after getting EA FC27 into a match. The game was running considerably faster than during my earlier investigation, but several elements were still rendering incorrectly. With the updated combined build, I have now observed a substantial improvement in the game.
This PR carries forward the remaining shader/BDA fixes and the extra-mip/cache handling. It also includes the later neutral-seed restriction from
8a71ab10, which was missing from the first version I recovered locally. It does not include the separateNpEntitlementAccessPftstate query, submitted in #1897.Why these changes are needed
Whole-wave UMax and OR reductions
Main already recognizes a particular full-EXEC prefix-scan sequence as a UMin reduction. I extended the same proof to unsigned maximum and bitwise OR. These sequences combine values read from lanes 31 and 63. Fragment execution can have sparse participation, so those physical endpoint invocations may be absent. Reading an absent endpoint is not a reliable way to recover the whole-wave result.
The matcher emits an explicit subgroup reduction only when it recognizes the complete supported sequence. The SPIR-V emitter combines both emulated halves when using split-wave execution, then shares the whole-wave result between the halves. Shader feature collection requests subgroup arithmetic for the new operations.
The seed must use the operation's neutral fallback: all ones for UMin, zero for UMax and OR. I also brought over the conservative check for a literal full EXEC: a masked seed with a non-neutral fallback is rejected rather than accepted merely because there is no saved symbolic EXEC witness. The
LiteralWrongNeutralregression covers this case for all three operations.Guest BDA address bounds
The page-table helper previously packed the address and narrowed its page index before rejecting addresses outside the supported guest ranges. An address in the hole between the lower and extended ranges, or one with high bits lost during narrowing, could alias a valid table entry.
The helper now checks the full 64-bit address against the lower and extended guest ranges first. Invalid addresses return the existing zero-pointer sentinel before accessing the page table. This is a general address-translation safeguard; I have not isolated its individual contribution to the visual improvement in FC27.
Extra guest mip views and texture-cache identity
During the earlier investigation I encountered a separate mip-count validation problem involving a 64×64 texture. A guest chain can describe more levels than a Vulkan image of that extent can represent. Simply reducing the mip count or recomputing the layout for a smaller image can change which guest bytes are read.
The new normalization runs after main's existing mip resolver. It keeps the original guest extent and level count, represents the selected host mip subset, and preserves the original allocation, offsets, array strides and mip-tail records. It rejects unsupported selections rather than silently truncating the requested view. Metadata/depth/multisample cases that require this rebasing remain unsupported.
Two different extra mips can both become a 1×1 host image with the same guest allocation and host dimensions. Those properties alone do not identify the same texels. The texture-cache backing comparison therefore also checks the original guest chain and selected base mip. Repeated requests for the same mip remain reusable.
Relationship to main and other PRs
This is a follow-up to #1693, reduced to changes that remain relevant on
83f8bfd3. Main already has the reused-selector SETPC fix and BDA table initialization, so I did not reintroduce the older implementations. I also left main's image creation flags in place instead of restoring the old compressed-volume fallback.As discussed on #1693, #1570 overlaps the reduction work and supports more operations and shapes. I am happy to reconcile that portion with the broader implementation; I am not presenting this as a replacement for it. The BDA and mip/cache changes can be reviewed independently of that overlap.
Tests and results
I built the Release emulator and the following test targets from the same workspace:
scalar_provenance_tests,shader_cfg_testsandshader_recompiler_compute_tests.Executed for this updated build:
scalar_provenance_tests— passed. Covers the supported UMin/UMax/OR proofs, neutral and masked seeds, the added literal-EXEC/non-neutral case, mixed operations and malformed sequences that must not be rewritten.shader_cfg_tests— passed, exit 0. Includes the recovered extra-mip layout test with one and two array layers, selected levels 0/6/7/8, repeated layout reconstruction, preserved offsets/strides/tail coordinates, valid upload records, and rejection of an unrepresentable two-level selection. Its log includes expected errors from negative/death tests.shader_recompiler_compute_tests --oversized-mip-cache-only— passed on AMD/RADV. The host check verifies that distinct mips 7 and 8 are not interchangeable while identical views remain reusable. The GPU test writes different RGBA uint texels to each mip and layer, alternates requests in the order 7, 8, 7, 8, downloads each image through the production texture cache, and checks all components. Every request returned the correct mip and layer, for both one and two layers.kyty_emulator --helpandgit diff --check— passed.In the preceding local build,
shader_recompiler_compute_tests --bda-address-range-onlyalso passed on RADV, covering a valid rebased guest allocation and invalid addresses that must not alias a mapped page. That BDA code and its regression are unchanged in this update; I did not rerun that selector for the final mip build. SPIR-V validation is performed by the compute test harness during compilation.In-game observations and limits
I tested EA FC27 and observed a substantial improvement after these changes. I had already reached a match before this update; the remaining problem was incorrect rendering, despite better FPS than my earlier attempts.
The manual result comes from the combined build with the separate PFT state-query change. I have not measured a controlled per-change FPS delta, isolated which patch fixes each visual artifact, or established that all rendering problems are resolved. I also have not validated this build across other GPU vendors or other games. The sparse-wave/address/layout issues are generic code paths, but that does not establish their impact on every title.
@coderabbitai[bot] on GitHub · 2026-10-25 12:43 UTC · original
No actionable comments were generated in the recent review.
83d63c96-0cc9-4191-888b-a903518c67aeReviewing files that changed from the base of the PR and between
83f8bfd3c9andf975ad1c19.src/graphics/host_gpu/renderer/cache/textureCache.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/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; 6 remain after this review.
Walkthrough
The changes normalize selected guest mip views while preserving their original physical layout and include guest mip-chain state in texture cache identity. The shader recompiler adds unsigned-maximum and bitwise-OR subgroup reductions. Generated BDA pointer lookup now validates addresses before page-table access. Tests cover mip normalization and caching, wave-reduction matching, and invalid BDA addresses.
Suggested reviewers:
nmzik,senaxxPriority:
Normal
Change: Bug fix
Merge Risk:
Minimal · up to
f975aNo identified issue remains that should block merging after normal checks.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 24.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 11 files. (3 skipped: 1 unsupported, 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.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.