diff options
Diffstat (limited to 'Ryujinx.Graphics.GAL/TextureCreateInfo.cs')
| -rw-r--r-- | Ryujinx.Graphics.GAL/TextureCreateInfo.cs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.GAL/TextureCreateInfo.cs b/Ryujinx.Graphics.GAL/TextureCreateInfo.cs index eedf58a0..3ccfb700 100644 --- a/Ryujinx.Graphics.GAL/TextureCreateInfo.cs +++ b/Ryujinx.Graphics.GAL/TextureCreateInfo.cs @@ -1,5 +1,6 @@ using Ryujinx.Common; using System; +using System.Numerics; namespace Ryujinx.Graphics.GAL { @@ -112,6 +113,25 @@ namespace Ryujinx.Graphics.GAL return 1; } + public readonly int GetLevelsClamped() + { + int maxSize = Width; + + if (Target != Target.Texture1D && + Target != Target.Texture1DArray) + { + maxSize = Math.Max(maxSize, Height); + } + + if (Target == Target.Texture3D) + { + maxSize = Math.Max(maxSize, Depth); + } + + int maxLevels = BitOperations.Log2((uint)maxSize) + 1; + return Math.Min(Levels, maxLevels); + } + private static int GetLevelSize(int size, int level) { return Math.Max(1, size >> level); |
