1
0
Fork 0

Fix additional reinterpretation nonsense (#6521)

* surface_params: Ensure pixel formats are not the same

* rasterizer_cache: Check copyable interval
This commit is contained in:
GPUCode 2023-05-09 12:01:15 +03:00 committed by GitHub
parent f9ab0b3042
commit b9d644b777
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -858,10 +858,11 @@ SurfaceId RasterizerCache<T>::FindMatch(const SurfaceParams& params, ScaleMatch
});
IsMatch_Helper(std::integral_constant<MatchFlags, MatchFlags::Reinterpret>{}, [&] {
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<MatchFlags, MatchFlags::Expand>{}, [&] {
return std::make_pair(surface.CanExpand(params), surface.GetInterval());

View File

@ -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;
}