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.
This commit is contained in:
riperiperi 2021-03-02 22:30:54 +00:00 committed by GitHub
parent 7a90abc035
commit b530f0e110
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1915 additions and 220 deletions

View file

@ -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);
@ -235,6 +235,27 @@ namespace Ryujinx.Graphics.Gpu.Image
size.Height == otherSize.Height) ? result : TextureViewCompatibility.Incompatible;
}
/// <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>
@ -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>