diff options
author | gdkchan <gab.dark.100@gmail.com> | 2021-01-15 15:14:00 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-15 19:14:00 +0100 |
commit | 3bad321d2b0994cd19129bc18ed98bb3ab81c3b0 (patch) | |
tree | 0c1c3610b7b0b42a2be3f797baf46ce42986a98b /Ryujinx.Graphics.Gpu/Image/TextureManager.cs | |
parent | 1e5b37c94f870dc3faa94fb2d095cfa39fecb2a3 (diff) |
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
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image/TextureManager.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TextureManager.cs | 40 |
1 files changed, 8 insertions, 32 deletions
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 /// </summary> /// <param name="info">Texture information of the texture to be found or created</param> /// <param name="flags">The texture search flags, defines texture comparison rules</param> + /// <param name="layerSize">Size in bytes of a single texture layer</param> /// <param name="sizeHint">A hint indicating the minimum used size for the texture</param> /// <returns>The texture</returns> - 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; |