aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2021-03-02 22:30:54 +0000
committerGitHub <noreply@github.com>2021-03-02 19:30:54 -0300
commitb530f0e1104723b894695b2860cf0f568f24cc9a (patch)
tree04f6b7d76d334ddc5c0378f6aa00b98739bc793e /Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
parent7a90abc03555f41ba7589bc8e1f714839f9e2fed (diff)
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.
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs41
1 files changed, 37 insertions, 4 deletions
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
/// <param name="lhs">Texture information of the texture view</param>
/// <param name="rhs">Texture information of the texture view to match against</param>
/// <param name="level">Mipmap level of the texture view in relation to this texture</param>
- /// <returns>True if the sizes are compatible, false otherwise</returns>
+ /// <returns>The view compatibility level of the view sizes</returns>
public static TextureViewCompatibility ViewSizeMatches(TextureInfo lhs, TextureInfo rhs, int level)
{
Size size = GetAlignedSize(lhs, level);
@@ -236,6 +236,27 @@ namespace Ryujinx.Graphics.Gpu.Image
}
/// <summary>
+ /// Checks if the potential child texture fits within the level and layer bounds of the parent.
+ /// </summary>
+ /// <param name="parent">Texture information for the parent</param>
+ /// <param name="child">Texture information for the child</param>
+ /// <param name="layer">Base layer of the child texture</param>
+ /// <param name="level">Base level of the child texture</param>
+ /// <returns>Full compatiblity if the child's layer and level count fit within the parent, incompatible otherwise</returns>
+ 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;
+ }
+ }
+
+ /// <summary>
/// Checks if the texture sizes of the supplied texture informations match.
/// </summary>
/// <param name="lhs">Texture information to compare</param>
@@ -382,10 +403,22 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary>
/// <param name="lhs">Texture information of the texture view</param>
/// <param name="rhs">Texture information of the texture view</param>
- /// <returns>True if the formats are compatible, false otherwise</returns>
- public static bool ViewFormatCompatible(TextureInfo lhs, TextureInfo rhs)
+ /// <returns>The view compatibility level of the texture formats</returns>
+ 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;
}
/// <summary>