From dbce3455ada55822cd613095c5b16c169e76c60d Mon Sep 17 00:00:00 2001 From: riperiperi Date: Wed, 10 Mar 2021 00:24:46 +0000 Subject: [PATCH] Fix lineSize for LinearStrided -> Linear conversion (#2091) Fixes a possible crash when width is greater than stride, which can happen due to alignment when copying textures. --- Ryujinx.Graphics.Texture/LayoutConverter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ryujinx.Graphics.Texture/LayoutConverter.cs b/Ryujinx.Graphics.Texture/LayoutConverter.cs index ed046fb5..fb25541b 100644 --- a/Ryujinx.Graphics.Texture/LayoutConverter.cs +++ b/Ryujinx.Graphics.Texture/LayoutConverter.cs @@ -256,7 +256,7 @@ namespace Ryujinx.Graphics.Texture int h = BitUtils.DivRoundUp(height, blockHeight); int outStride = BitUtils.AlignUp(w * bytesPerPixel, HostStrideAlignment); - int lineSize = w * bytesPerPixel; + int lineSize = Math.Min(stride, outStride); Span output = new byte[h * outStride];