|
@@ -291,22 +291,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|
|
/// <returns>The minimum compatibility level of two provided view compatibility results</returns>
|
|
/// <returns>The minimum compatibility level of two provided view compatibility results</returns>
|
|
|
public static TextureViewCompatibility PropagateViewCompatibility(TextureViewCompatibility first, TextureViewCompatibility second)
|
|
public static TextureViewCompatibility PropagateViewCompatibility(TextureViewCompatibility first, TextureViewCompatibility second)
|
|
|
{
|
|
{
|
|
|
- if (first == TextureViewCompatibility.Incompatible || second == TextureViewCompatibility.Incompatible)
|
|
|
|
|
- {
|
|
|
|
|
- return TextureViewCompatibility.Incompatible;
|
|
|
|
|
- }
|
|
|
|
|
- else if (first == TextureViewCompatibility.LayoutIncompatible || second == TextureViewCompatibility.LayoutIncompatible)
|
|
|
|
|
- {
|
|
|
|
|
- return TextureViewCompatibility.LayoutIncompatible;
|
|
|
|
|
- }
|
|
|
|
|
- else if (first == TextureViewCompatibility.CopyOnly || second == TextureViewCompatibility.CopyOnly)
|
|
|
|
|
- {
|
|
|
|
|
- return TextureViewCompatibility.CopyOnly;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- return TextureViewCompatibility.Full;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return (TextureViewCompatibility)Math.Min((int)first, (int)second);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -628,15 +613,21 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|
|
/// <param name="lhs">Texture information of the texture view</param>
|
|
/// <param name="lhs">Texture information of the texture view</param>
|
|
|
/// <param name="rhs">Texture information of the texture view</param>
|
|
/// <param name="rhs">Texture information of the texture view</param>
|
|
|
/// <param name="caps">Host GPU capabilities</param>
|
|
/// <param name="caps">Host GPU capabilities</param>
|
|
|
|
|
+ /// <param name="flags">Texture search flags</param>
|
|
|
/// <returns>The view compatibility level of the texture formats</returns>
|
|
/// <returns>The view compatibility level of the texture formats</returns>
|
|
|
- public static TextureViewCompatibility ViewFormatCompatible(TextureInfo lhs, TextureInfo rhs, Capabilities caps)
|
|
|
|
|
|
|
+ public static TextureViewCompatibility ViewFormatCompatible(TextureInfo lhs, TextureInfo rhs, Capabilities caps, TextureSearchFlags flags)
|
|
|
{
|
|
{
|
|
|
FormatInfo lhsFormat = lhs.FormatInfo;
|
|
FormatInfo lhsFormat = lhs.FormatInfo;
|
|
|
FormatInfo rhsFormat = rhs.FormatInfo;
|
|
FormatInfo rhsFormat = rhs.FormatInfo;
|
|
|
|
|
|
|
|
if (lhsFormat.Format.IsDepthOrStencil() || rhsFormat.Format.IsDepthOrStencil())
|
|
if (lhsFormat.Format.IsDepthOrStencil() || rhsFormat.Format.IsDepthOrStencil())
|
|
|
{
|
|
{
|
|
|
- return lhsFormat.Format == rhsFormat.Format ? TextureViewCompatibility.Full : TextureViewCompatibility.Incompatible;
|
|
|
|
|
|
|
+ return FormatMatches(lhs, rhs, flags.HasFlag(TextureSearchFlags.ForSampler), flags.HasFlag(TextureSearchFlags.DepthAlias)) switch
|
|
|
|
|
+ {
|
|
|
|
|
+ TextureMatchQuality.Perfect => TextureViewCompatibility.Full,
|
|
|
|
|
+ TextureMatchQuality.FormatAlias => TextureViewCompatibility.FormatAlias,
|
|
|
|
|
+ _ => TextureViewCompatibility.Incompatible
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (IsFormatHostIncompatible(lhs, caps) || IsFormatHostIncompatible(rhs, caps))
|
|
if (IsFormatHostIncompatible(lhs, caps) || IsFormatHostIncompatible(rhs, caps))
|
|
@@ -754,49 +745,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|
|
return result ? TextureViewCompatibility.Full : TextureViewCompatibility.Incompatible;
|
|
return result ? TextureViewCompatibility.Full : TextureViewCompatibility.Incompatible;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /// <summary>
|
|
|
|
|
- /// Checks if a swizzle component in two textures functionally match, taking into account if the components are defined.
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- /// <param name="lhs">Texture information to compare</param>
|
|
|
|
|
- /// <param name="rhs">Texture information to compare with</param>
|
|
|
|
|
- /// <param name="swizzleLhs">Swizzle component for the first texture</param>
|
|
|
|
|
- /// <param name="swizzleRhs">Swizzle component for the second texture</param>
|
|
|
|
|
- /// <param name="component">Component index, starting at 0 for red</param>
|
|
|
|
|
- /// <returns>True if the swizzle components functionally match, false othersize</returns>
|
|
|
|
|
- private static bool SwizzleComponentMatches(TextureInfo lhs, TextureInfo rhs, SwizzleComponent swizzleLhs, SwizzleComponent swizzleRhs, int component)
|
|
|
|
|
- {
|
|
|
|
|
- int lhsComponents = lhs.FormatInfo.Components;
|
|
|
|
|
- int rhsComponents = rhs.FormatInfo.Components;
|
|
|
|
|
-
|
|
|
|
|
- if (lhsComponents == 4 && rhsComponents == 4)
|
|
|
|
|
- {
|
|
|
|
|
- return swizzleLhs == swizzleRhs;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Swizzles after the number of components a format defines are "undefined".
|
|
|
|
|
- // We allow these to not be equal under certain circumstances.
|
|
|
|
|
- // This can only happen when there are less than 4 components in a format.
|
|
|
|
|
- // It tends to happen when float depth textures are sampled.
|
|
|
|
|
-
|
|
|
|
|
- bool lhsDefined = (swizzleLhs - SwizzleComponent.Red) < lhsComponents;
|
|
|
|
|
- bool rhsDefined = (swizzleRhs - SwizzleComponent.Red) < rhsComponents;
|
|
|
|
|
-
|
|
|
|
|
- if (lhsDefined == rhsDefined)
|
|
|
|
|
- {
|
|
|
|
|
- // If both are undefined, return true. Otherwise just check if they're equal.
|
|
|
|
|
- return lhsDefined ? swizzleLhs == swizzleRhs : true;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- SwizzleComponent defined = lhsDefined ? swizzleLhs : swizzleRhs;
|
|
|
|
|
- SwizzleComponent undefined = lhsDefined ? swizzleRhs : swizzleLhs;
|
|
|
|
|
-
|
|
|
|
|
- // Undefined swizzle can be matched by a forced value (0, 1), exact equality, or expected value.
|
|
|
|
|
- // For example, R___ matches R001, RGBA but not RBGA.
|
|
|
|
|
- return defined == undefined || defined < SwizzleComponent.Red || defined == SwizzleComponent.Red + component;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Checks if the texture shader sampling parameters of two texture informations match.
|
|
/// Checks if the texture shader sampling parameters of two texture informations match.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -806,10 +754,10 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|
|
public static bool SamplerParamsMatches(TextureInfo lhs, TextureInfo rhs)
|
|
public static bool SamplerParamsMatches(TextureInfo lhs, TextureInfo rhs)
|
|
|
{
|
|
{
|
|
|
return lhs.DepthStencilMode == rhs.DepthStencilMode &&
|
|
return lhs.DepthStencilMode == rhs.DepthStencilMode &&
|
|
|
- SwizzleComponentMatches(lhs, rhs, lhs.SwizzleR, rhs.SwizzleR, 0) &&
|
|
|
|
|
- SwizzleComponentMatches(lhs, rhs, lhs.SwizzleG, rhs.SwizzleG, 1) &&
|
|
|
|
|
- SwizzleComponentMatches(lhs, rhs, lhs.SwizzleB, rhs.SwizzleB, 2) &&
|
|
|
|
|
- SwizzleComponentMatches(lhs, rhs, lhs.SwizzleA, rhs.SwizzleA, 3);
|
|
|
|
|
|
|
+ lhs.SwizzleR == rhs.SwizzleR &&
|
|
|
|
|
+ lhs.SwizzleG == rhs.SwizzleG &&
|
|
|
|
|
+ lhs.SwizzleB == rhs.SwizzleB &&
|
|
|
|
|
+ lhs.SwizzleA == rhs.SwizzleA;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|