From 0108004691a582f7df8e629c1e68a6bb0e0b90e7 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Fri, 27 Nov 2020 18:46:23 +0000 Subject: Prefer truly perfect texture matches over fomat aliased ones (#1754) --- Ryujinx.Graphics.Gpu/Image/Texture.cs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Image/Texture.cs') diff --git a/Ryujinx.Graphics.Gpu/Image/Texture.cs b/Ryujinx.Graphics.Gpu/Image/Texture.cs index 7fb41572..45a27051 100644 --- a/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -800,29 +800,31 @@ namespace Ryujinx.Graphics.Gpu.Image /// /// Texture information to compare against /// Comparison flags - /// True if the textures are strictly equal or similar, false otherwise - public bool IsPerfectMatch(TextureInfo info, TextureSearchFlags flags) + /// A value indicating how well this texture matches the given info + public TextureMatchQuality IsExactMatch(TextureInfo info, TextureSearchFlags flags) { - if (!TextureCompatibility.FormatMatches(Info, info, (flags & TextureSearchFlags.ForSampler) != 0, (flags & TextureSearchFlags.ForCopy) != 0)) + TextureMatchQuality matchQuality = TextureCompatibility.FormatMatches(Info, info, (flags & TextureSearchFlags.ForSampler) != 0, (flags & TextureSearchFlags.ForCopy) != 0); + + if (matchQuality == TextureMatchQuality.NoMatch) { - return false; + return matchQuality; } if (!TextureCompatibility.LayoutMatches(Info, info)) { - return false; + return TextureMatchQuality.NoMatch; } if (!TextureCompatibility.SizeMatches(Info, info, (flags & TextureSearchFlags.Strict) == 0)) { - return false; + return TextureMatchQuality.NoMatch; } if ((flags & TextureSearchFlags.ForSampler) != 0 || (flags & TextureSearchFlags.Strict) != 0) { if (!TextureCompatibility.SamplerParamsMatches(Info, info)) { - return false; + return TextureMatchQuality.NoMatch; } } @@ -832,15 +834,15 @@ namespace Ryujinx.Graphics.Gpu.Image if (!msTargetCompatible && !TextureCompatibility.TargetAndSamplesCompatible(Info, info)) { - return false; + return TextureMatchQuality.NoMatch; } } else if (!TextureCompatibility.TargetAndSamplesCompatible(Info, info)) { - return false; + return TextureMatchQuality.NoMatch; } - return Info.Address == info.Address && Info.Levels == info.Levels; + return Info.Address == info.Address && Info.Levels == info.Levels ? matchQuality : TextureMatchQuality.NoMatch; } /// -- cgit v1.2.3