From b9d644b77726d4e1a4d6b8fbd8e0b2f00675bdf8 Mon Sep 17 00:00:00 2001 From: GPUCode <47210458+GPUCode@users.noreply.github.com> Date: Tue, 9 May 2023 12:01:15 +0300 Subject: [PATCH] Fix additional reinterpretation nonsense (#6521) * surface_params: Ensure pixel formats are not the same * rasterizer_cache: Check copyable interval --- src/video_core/rasterizer_cache/rasterizer_cache.h | 9 +++++---- src/video_core/rasterizer_cache/surface_params.cpp | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/video_core/rasterizer_cache/rasterizer_cache.h b/src/video_core/rasterizer_cache/rasterizer_cache.h index b942e5d6e..685c5d381 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache.h +++ b/src/video_core/rasterizer_cache/rasterizer_cache.h @@ -858,10 +858,11 @@ SurfaceId RasterizerCache::FindMatch(const SurfaceParams& params, ScaleMatch }); IsMatch_Helper(std::integral_constant{}, [&] { ASSERT(validate_interval); - const bool matched = - !boost::icl::contains(surface.invalid_regions, *validate_interval) && - surface.CanReinterpret(params); - return std::make_pair(matched, surface.GetInterval()); + const SurfaceInterval copy_interval = + surface.GetCopyableInterval(params.FromInterval(*validate_interval)); + const bool matched = boost::icl::length(copy_interval & *validate_interval) != 0 && + surface.CanReinterpret(params); + return std::make_pair(matched, copy_interval); }); IsMatch_Helper(std::integral_constant{}, [&] { return std::make_pair(surface.CanExpand(params), surface.GetInterval()); diff --git a/src/video_core/rasterizer_cache/surface_params.cpp b/src/video_core/rasterizer_cache/surface_params.cpp index de630e804..87b6a7274 100644 --- a/src/video_core/rasterizer_cache/surface_params.cpp +++ b/src/video_core/rasterizer_cache/surface_params.cpp @@ -27,8 +27,9 @@ bool SurfaceParams::CanSubRect(const SurfaceParams& sub_surface) const { bool SurfaceParams::CanReinterpret(const SurfaceParams& other_surface) { return other_surface.addr >= addr && other_surface.end <= end && - pixel_format != PixelFormat::Invalid && GetFormatBpp() == other_surface.GetFormatBpp() && - other_surface.is_tiled == is_tiled && other_surface.stride == stride && + pixel_format != PixelFormat::Invalid && pixel_format != other_surface.pixel_format && + GetFormatBpp() == other_surface.GetFormatBpp() && other_surface.is_tiled == is_tiled && + other_surface.stride == stride && (other_surface.addr - addr) % BytesInPixels(is_tiled ? 64 : 1) == 0 && GetSubRect(other_surface).right <= stride; }