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.Texture/SizeCalculator.cs | 36 +++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'Ryujinx.Graphics.Texture') diff --git a/Ryujinx.Graphics.Texture/SizeCalculator.cs b/Ryujinx.Graphics.Texture/SizeCalculator.cs index 9339ba12..2dc60869 100644 --- a/Ryujinx.Graphics.Texture/SizeCalculator.cs +++ b/Ryujinx.Graphics.Texture/SizeCalculator.cs @@ -20,7 +20,8 @@ namespace Ryujinx.Graphics.Texture int bytesPerPixel, int gobBlocksInY, int gobBlocksInZ, - int gobBlocksInTileX) + int gobBlocksInTileX, + int gpuLayerSize = 0) { bool is3D = depth > 1; @@ -94,14 +95,29 @@ namespace Ryujinx.Graphics.Texture layerSize += totalBlocksOfGobsInZ * totalBlocksOfGobsInY * robSize; } - layerSize = AlignLayerSize( - layerSize, - height, - depth, - blockHeight, - gobBlocksInY, - gobBlocksInZ, - gobBlocksInTileX); + if (layers > 1) + { + layerSize = AlignLayerSize( + layerSize, + height, + depth, + blockHeight, + gobBlocksInY, + gobBlocksInZ, + gobBlocksInTileX); + } + + int totalSize; + + if (layerSize < gpuLayerSize) + { + totalSize = (layers - 1) * gpuLayerSize + layerSize; + layerSize = gpuLayerSize; + } + else + { + totalSize = layerSize * layers; + } if (!is3D) { @@ -117,8 +133,6 @@ namespace Ryujinx.Graphics.Texture } } - int totalSize = layerSize * layers; - return new SizeInfo(mipOffsets, allOffsets, levels, layerSize, totalSize); } -- cgit v1.2.3