From 3bad321d2b0994cd19129bc18ed98bb3ab81c3b0 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Fri, 15 Jan 2021 15:14:00 -0300 Subject: Fix mipmap base level being ignored for sampled textures and images (#1911) * Fix mipmap base level being ignored for sampled textures and images * Fix layer size and max level for textures * Missing XML doc + reorder comments --- Ryujinx.Graphics.Gpu/Image/TextureManager.cs | 40 ++++++---------------------- 1 file changed, 8 insertions(+), 32 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Image/TextureManager.cs') diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs index 993218ce..5bad3952 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs @@ -514,7 +514,7 @@ namespace Ryujinx.Graphics.Gpu.Image flags |= TextureSearchFlags.WithUpscale; } - Texture texture = FindOrCreateTexture(info, flags, sizeHint); + Texture texture = FindOrCreateTexture(info, flags, 0, sizeHint); texture.SynchronizeMemory(); @@ -598,7 +598,9 @@ namespace Ryujinx.Graphics.Gpu.Image target, formatInfo); - Texture texture = FindOrCreateTexture(info, TextureSearchFlags.WithUpscale, sizeHint); + int layerSize = !isLinear ? colorState.LayerSize * 4 : 0; + + Texture texture = FindOrCreateTexture(info, TextureSearchFlags.WithUpscale, layerSize, sizeHint); texture.SynchronizeMemory(); @@ -648,7 +650,7 @@ namespace Ryujinx.Graphics.Gpu.Image target, formatInfo); - Texture texture = FindOrCreateTexture(info, TextureSearchFlags.WithUpscale, sizeHint); + Texture texture = FindOrCreateTexture(info, TextureSearchFlags.WithUpscale, dsState.LayerSize * 4, sizeHint); texture.SynchronizeMemory(); @@ -660,9 +662,10 @@ namespace Ryujinx.Graphics.Gpu.Image /// /// Texture information of the texture to be found or created /// The texture search flags, defines texture comparison rules + /// Size in bytes of a single texture layer /// A hint indicating the minimum used size for the texture /// The texture - public Texture FindOrCreateTexture(TextureInfo info, TextureSearchFlags flags = TextureSearchFlags.None, Size? sizeHint = null) + public Texture FindOrCreateTexture(TextureInfo info, TextureSearchFlags flags = TextureSearchFlags.None, int layerSize = 0, Size? sizeHint = null) { bool isSamplerTexture = (flags & TextureSearchFlags.ForSampler) != 0; @@ -722,34 +725,7 @@ namespace Ryujinx.Graphics.Gpu.Image } // Calculate texture sizes, used to find all overlapping textures. - SizeInfo sizeInfo; - - if (info.Target == Target.TextureBuffer) - { - sizeInfo = new SizeInfo(info.Width * info.FormatInfo.BytesPerPixel); - } - else if (info.IsLinear) - { - sizeInfo = SizeCalculator.GetLinearTextureSize( - info.Stride, - info.Height, - info.FormatInfo.BlockHeight); - } - else - { - sizeInfo = SizeCalculator.GetBlockLinearTextureSize( - info.Width, - info.Height, - info.GetDepth(), - info.Levels, - info.GetLayers(), - info.FormatInfo.BlockWidth, - info.FormatInfo.BlockHeight, - info.FormatInfo.BytesPerPixel, - info.GobBlocksInY, - info.GobBlocksInZ, - info.GobBlocksInTileX); - } + SizeInfo sizeInfo = info.CalculateSizeInfo(layerSize); // Find view compatible matches. ulong size = (ulong)sizeInfo.TotalSize; -- cgit v1.2.3