Collected sampler/graphics fixes for Neptunia ReVerse (PPSA02721) #857
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!857
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/857/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?
@EmK530 on GitHub · 2026-09-26 21:58 UTC · original
EmK530:shader/neptunia-fixes→main· +274 −22 · 18 files · 9 commits · closed without mergingNotice
Every change targeting a fix for the game is isolated into its own commit, this PR description will go over every change made and why it was made. I've categorized each commit into two sections: one section is critical for getting the game to function, the other section is for extra fixes that get the game to pass Vulkan validation.
The commits to pass validation are not mandatory to include but are a part of this PR in case they may be of value, leave them out of cherry-picking if they are wrong or not desired.
Critical commits
a6e271b: Fix blending on reordered-channel render targets.SRC_ALPHAblend would incorrectly read a large red channel and treat it as an abnormally high alpha value.dualSrcBlend.EXITcall if preferred.d699613+156e6ba: Clear stale buffer GPU-dirty records when a render target overwrites them.d699613) fixes random black frames in the game. During gameplay Neptunia clears the display buffer with a compute fill, which marks that memory region as GPU-modified in the buffer cache. When a render target later draws into the same region, the flag is never reset and the region is still deemed GPU-modified. This causedSafeToDownloadto fail, so the GC freed the image without saving it. At the next flip no image was found for the display buffer so a new one was created from empty data and black was presented.b877b4b).bdc9668: Dodge unknown anisotropy ratio crashes and default to 16x.Validation fixes
These commits cover crashes only present with Vulkan validation, may be useful regardless so they are documented and included in this PR.
Tests were performed on a RTX 5070, validation errors may not show on all system configurations.
5222898: Emulate unnormalized sampler coordinates in the shader.b23d7cd: Change 5:6:5 targets to R5G6B5 and apply a red/blue swap.f2faaa6: ClampmipLodBiasto not be greater thanmaxSamplerLodBias.31.67, whereas the limit on my device was15.ffa9c62: Clampmin_lodto not be greater thanmax_lod.Testing
Broad tests have not been performed on these commits, a quick verification on ASTRO BOT was made to ensure nothing regressed before this PR was submitted, suggested to scrutinize each commit before cherry-picking.
Test files were modified by commits:
b23d7cd,156e6baand have been ran to ensure all pass which they do.AI usage
AI was involved in the process of investigating issues and was responsible for implementing most changes. I have studied the changes in post and written the PR and change descriptions myself unless explicitly stated (
5222898).Anisotropy ratio encodings 5-7 are reserved. Neptunia ReVerse binds descriptors with such a value in slots the shader never samples, and the EXIT("unknown ratio") stopped the emulator. Use the maximum ratio and log the descriptor once instead. Co-Authored-By: Claude Sonnet 5 <[email protected]>@coderabbitai[bot] on GitHub · 2026-09-26 22:09 UTC · original · edited 2026-09-28 18:38 UTC
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
3c8d8daf-30d8-4827-83ba-86f89a0abdf6📥 Commits
Reviewing files that changed from the base of the PR and between
156e6ba7eaandc9fb9fe494.📒 Files selected for processing (7)
src/graphics/host_gpu/renderer/cache/bufferCache.hsrc/graphics/host_gpu/renderer/cache/samplerCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cppsrc/graphics/shader/recompiler/ir/passes/ResourceMaterialization.htests/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.
📝 Walkthrough
Walkthrough
The changes add GPU-dirty byte tracking updates after image writes, sampler-state specialization and shader-side emulation for unnormalized coordinates, and blend handling for mapped color outputs. They also add RGB565 format resolution and update related tests.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: 🟡 Moderate · up to
c9fb9Some mapped blends and texture gathers can render incorrectly, and a sparse multi-target shader can terminate. Resolve or explicitly accept these risks before merging.
Security Architecture Review
Security architecture risk: 🟡 Moderate · up to
c9fb9The memory-ownership change may allow a guest-memory read before updated image contents are available in backing memory. No new privilege or cross-tenant exposure has been established, but the synchronization path needs confirmation.
Retained concerns
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❓ 1
❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 16 files. (2 skipped: 2 too large.)
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.@ -178,0 +217,4 @@BlendMappingSupport ClassifyBlendMapping(const HW::BlendControl& blend,const Prospero::ColorComponentMapping& mapping) {if (mapping.IsIdentity() || mapping.Map(3) == 3u) {return BlendMappingSupport::Direct;@coderabbitai[bot] on GitHub · 2026-09-26 22:09 UTC · original
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not classify permuted constant-color blending as direct.
A mapping such as
ColorMappingBgrakeeps alpha in physical A, so this branch returnsDirect. If a blend factor iskConstantColororkOneMinusConstantColorand the R and B blend constants differ, the shader swaps the exported channels but the Vulkan blend constants remain in physical channel order. The resulting blend differs from the guest blend. The later!uses_alphareturn has the same problem when a mapping moves alpha. Reject these factor-and-mapping combinations, or permute the blend constants consistently. (docs.vulkan.org)@ -622,1 +687,4 @@pixel_info.target_export_mapping[1] = pixel_info.target_export_mapping[0];} else if (blend.enable && !context.GetRenderTarget(0).info.blend_bypass &&pixel_info.target_output_mode[0] != 0 && pixel_info.target_output_mode[1] == 0 &&ClassifyBlendMapping(blend, pixel_info.target_export_mapping[0]) ==@coderabbitai[bot] on GitHub · 2026-09-26 22:09 UTC · original
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Keep the remap path off shaders with other MRT outputs.
If MRT1 is disabled but a pixel shader exports MRT2, this condition enables
dual_source_blending.DefineOutputsinsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cppthen callsEXIT_NOT_IMPLEMENTEDfor the MRT2 binding because its index exceeds 1. The new path turns a sparse multi-target draw into a termination. Check all other MRT outputs before selecting the remap path, and use the unsupported-blend fallback when they are present. Dual-source attachment capacity is also device-dependent. (docs.vulkan.org)@ -476,0 +491,4 @@const uint32_t components = info.coordinate_components;std::vector<uint32_t> words {spv::OpCompositeConstruct, TypeF32Vector(state, components),state.builder.AllocateId()};@coderabbitai[bot] on GitHub · 2026-09-26 22:09 UTC · original
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 40575
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 41993
Use a scalar type for one-dimensional coordinates.
Dim1Dsetscoordinate_componentsto one.TypeF32Vectoralways requestsOpTypeVector, so the scalar early return occurs after an invalid one-component vector type is created.🐛 Suggested fix
📝 Committable suggestion
@ -717,0 +761,4 @@// Unnormalized samplers have no mip selection, so they sample level zero explicitly.const bool unnormalized = mem.sampler < state.program.info.samplers.size() &&state.program.info.samplers[mem.sampler].unnormalized;const bool explicit_lod = unnormalized || HasFlag(mem, Decoder::ImageSampleFlagDerivative) ||@coderabbitai[bot] on GitHub · 2026-09-26 22:09 UTC · original
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Handle unnormalized coordinates in the gather branch.
ImageGatherRawreturns before this flag is read. For a 2D gather with a force-unnormalized sampler, the gather branch passes texel coordinates directly to the normalized Vulkan sampler. Coordinates such as(4, 4)then address the wrong texels. Read the flag before the gather branch and convert gather coordinates using the image extent. The 1D gather helper also needs its coordinate input checked. (registry.khronos.org)@coderabbitai[bot] on GitHub · 2026-09-26 22:09 UTC · original · reviewed
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
f322eda5-d834-41ee-9907-1d11e35bfccd📥 Commits
Reviewing files that changed from the base of the PR and between
a22a9d9348and156e6ba7ea.📒 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/samplerCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/image/textureCommon.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.hsrc/graphics/host_gpu/renderer/pipeline/shaders.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cppsrc/graphics/shader/recompiler/ir/ShaderIR.hsrc/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cppsrc/graphics/shader/recompiler/ir/passes/ResourceMaterialization.hsrc/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cppsrc/graphics/shader/shader.cppsrc/graphics/shader/shader.htests/ShaderRecompilerComputeTests.cpptests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@EmK530 on GitHub · 2026-09-27 13:28 UTC · original
Resolved conflict from
9229c04, commitbdc9668no longer applies 🎉@EmK530 on GitHub · 2026-09-28 18:36 UTC · original
Verified recent changes, this PR's commit
d699613is now obsolete as it was resolved by6ee1bf9🎉@Nmzik on GitHub · 2026-09-29 16:08 UTC · original · edited 2026-09-29 16:11 UTC
@EmK530 Thanks for detailed PR. I loved it. sorry for waiting. Everything cherry picked. I checked Vulkan validation too. Will leave them for now except one
Pull request closed