From 9d65003ced1e74491060eac82a032c0ba31345f4 Mon Sep 17 00:00:00 2001 From: TideOPL Date: Thu, 8 Oct 2026 10:06:11 +0100 Subject: [PATCH] fix(agc): treat other-shaped views of a depth surface's memory as reused memory Engines alias transient render targets, so a texture can sit at the address of a depth surface after the memory has been handed to a color image: a 384x384 R11G11B10 texture over a 384x384 D32S8 surface, say. Sampling it threw "sampling the depth plane ... is not implemented" and the draw was skipped. A view with another extent, or a depth-plane view in a format that cannot hold the plane (neither the plane's own R32F / R16 unorm nor a T# that reads the raw depth bits), is now treated as memory reuse: the lookup falls through to the ordinary texture path instead of the depth surface. Stencil-plane views keep their current handling. --- .../prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp index 33194fdb2..d1cc7c90a 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp @@ -169,7 +169,16 @@ std::shared_ptr DepthSurfaceTexture(const Context& context, std::spancontext.device == context.device && (surface->target.address == resource.baseAddress || (surface->target.stencilAddress != 0 && surface->target.stencilAddress == resource.baseAddress)); }); - return found == list.rend() ? nullptr : (*found)->Sampled(words, resource, components); + if (found == list.rend()) return nullptr; + const auto& target = (*found)->target; + if (resource.width != target.extent.width || resource.height != target.extent.height) return nullptr; + const bool stencil = target.stencilAddress != 0 && resource.baseAddress == target.stencilAddress; + if (!stencil) { + const bool d16 = target.format == VK_FORMAT_D16_UNORM || target.format == VK_FORMAT_D16_UNORM_S8_UINT; + const bool depthBits = words.size() >= 4 && ShaderRecompiler::DepthBitsTextureWidth(words[1], words[3]) == (d16 ? 16u : 32u); + if (ResolveTextureFormat(resource.format) != (d16 ? VK_FORMAT_R16_UNORM : VK_FORMAT_R32_SFLOAT) && !depthBits) return nullptr; + } + return (*found)->Sampled(words, resource, components); } bool DepthSurfaceAt(std::uint64_t address) {