From b530f0e1104723b894695b2860cf0f568f24cc9a Mon Sep 17 00:00:00 2001 From: riperiperi Date: Tue, 2 Mar 2021 22:30:54 +0000 Subject: Texture Cache: "Texture Groups" and "Texture Dependencies" (#2001) * Initial implementation (3d tex mips broken) This works rather well for most games, just need to fix 3d texture mips. * Cleanup * Address feedback * Copy Dependencies and various other fixes * Fix layer/level offset for copy from view<->view. * Remove dirty flag from dependency The dirty flag behaviour is not needed - DeferredCopy is all we need. * Fix tracking mip slices. * Propagate granularity (fix astral chain) * Address Feedback pt 1 * Save slice sizes as part of SizeInfo * Fix nits * Fix disposing multiple dependencies causing a crash This list is obviously modified when removing dependencies, so create a copy of it. --- Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs | 41 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs') diff --git a/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs b/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs index e3574be5..d613612f 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs @@ -215,7 +215,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Texture information of the texture view /// Texture information of the texture view to match against /// Mipmap level of the texture view in relation to this texture - /// True if the sizes are compatible, false otherwise + /// The view compatibility level of the view sizes public static TextureViewCompatibility ViewSizeMatches(TextureInfo lhs, TextureInfo rhs, int level) { Size size = GetAlignedSize(lhs, level); @@ -235,6 +235,27 @@ namespace Ryujinx.Graphics.Gpu.Image size.Height == otherSize.Height) ? result : TextureViewCompatibility.Incompatible; } + /// + /// Checks if the potential child texture fits within the level and layer bounds of the parent. + /// + /// Texture information for the parent + /// Texture information for the child + /// Base layer of the child texture + /// Base level of the child texture + /// Full compatiblity if the child's layer and level count fit within the parent, incompatible otherwise + public static TextureViewCompatibility ViewSubImagesInBounds(TextureInfo parent, TextureInfo child, int layer, int level) + { + if (level + child.Levels <= parent.Levels && + layer + child.GetSlices() <= parent.GetSlices()) + { + return TextureViewCompatibility.Full; + } + else + { + return TextureViewCompatibility.Incompatible; + } + } + /// /// Checks if the texture sizes of the supplied texture informations match. /// @@ -382,10 +403,22 @@ namespace Ryujinx.Graphics.Gpu.Image /// /// Texture information of the texture view /// Texture information of the texture view - /// True if the formats are compatible, false otherwise - public static bool ViewFormatCompatible(TextureInfo lhs, TextureInfo rhs) + /// The view compatibility level of the texture formats + public static TextureViewCompatibility ViewFormatCompatible(TextureInfo lhs, TextureInfo rhs) { - return FormatCompatible(lhs.FormatInfo, rhs.FormatInfo); + if (FormatCompatible(lhs.FormatInfo, rhs.FormatInfo)) + { + if (lhs.FormatInfo.IsCompressed != rhs.FormatInfo.IsCompressed) + { + return TextureViewCompatibility.CopyOnly; + } + else + { + return TextureViewCompatibility.Full; + } + } + + return TextureViewCompatibility.Incompatible; } /// -- cgit v1.2.3