|
@@ -10,6 +10,7 @@ using System;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
|
+using System.Numerics;
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gpu.Image
|
|
namespace Ryujinx.Graphics.Gpu.Image
|
|
|
{
|
|
{
|
|
@@ -23,6 +24,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|
|
// This method uses much more memory so we want to avoid it if possible.
|
|
// This method uses much more memory so we want to avoid it if possible.
|
|
|
private const int ByteComparisonSwitchThreshold = 4;
|
|
private const int ByteComparisonSwitchThreshold = 4;
|
|
|
|
|
|
|
|
|
|
+ private const int MinLevelsForForceAnisotropy = 5;
|
|
|
|
|
+
|
|
|
private struct TexturePoolOwner
|
|
private struct TexturePoolOwner
|
|
|
{
|
|
{
|
|
|
public TexturePool Pool;
|
|
public TexturePool Pool;
|
|
@@ -49,6 +52,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
public TextureInfo Info { get; private set; }
|
|
public TextureInfo Info { get; private set; }
|
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Set when anisotropic filtering can be forced on the given texture.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ public bool CanForceAnisotropy { get; private set; }
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Host scale factor.
|
|
/// Host scale factor.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -1129,6 +1137,24 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Determine if this texture can have anisotropic filtering forced.
|
|
|
|
|
+ /// Filtered textures that we might want to force anisotropy on should have a lot of mip levels.
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <returns>True if anisotropic filtering can be forced, false otherwise</returns>
|
|
|
|
|
+ private bool CanTextureForceAnisotropy()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!(Target == Target.Texture2D || Target == Target.Texture2DArray))
|
|
|
|
|
+ {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int maxSize = Math.Max(Info.Width, Info.Height);
|
|
|
|
|
+ int maxLevels = BitOperations.Log2((uint)maxSize) + 1;
|
|
|
|
|
+
|
|
|
|
|
+ return Info.Levels >= Math.Min(MinLevelsForForceAnisotropy, maxLevels);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Check if this texture and the specified target have the same number of dimensions.
|
|
/// Check if this texture and the specified target have the same number of dimensions.
|
|
|
/// For the purposes of this comparison, 2D and 2D Multisample textures are not considered to have
|
|
/// For the purposes of this comparison, 2D and 2D Multisample textures are not considered to have
|
|
@@ -1219,6 +1245,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|
|
{
|
|
{
|
|
|
Info = info;
|
|
Info = info;
|
|
|
Target = info.Target;
|
|
Target = info.Target;
|
|
|
|
|
+ CanForceAnisotropy = CanTextureForceAnisotropy();
|
|
|
|
|
|
|
|
_depth = info.GetDepth();
|
|
_depth = info.GetDepth();
|
|
|
_layers = info.GetLayers();
|
|
_layers = info.GetLayers();
|