From 1bb08742c1df4ac1a9d4a5240fdf186db77bfbcc Mon Sep 17 00:00:00 2001 From: gdk Date: Sun, 13 Oct 2019 22:48:09 -0300 Subject: [PATCH] Calculate width from stride on texture copies --- Ryujinx.Graphics.Gpu/Image/TextureManager.cs | 13 ++++++++++++- Ryujinx.Graphics.Texture/LayoutConverter.cs | 7 ++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs index 56dff9ad65..23416ddd36 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs @@ -245,9 +245,20 @@ namespace Ryujinx.Graphics.Gpu.Image FormatInfo formatInfo = copyTexture.Format.Convert(); + int width; + + if (copyTexture.LinearLayout) + { + width = copyTexture.Stride / formatInfo.BytesPerPixel; + } + else + { + width = copyTexture.Width; + } + TextureInfo info = new TextureInfo( address, - copyTexture.Width, + width, copyTexture.Height, copyTexture.Depth, 1, diff --git a/Ryujinx.Graphics.Texture/LayoutConverter.cs b/Ryujinx.Graphics.Texture/LayoutConverter.cs index 36ae522b50..ef80144ec4 100644 --- a/Ryujinx.Graphics.Texture/LayoutConverter.cs +++ b/Ryujinx.Graphics.Texture/LayoutConverter.cs @@ -108,11 +108,8 @@ namespace Ryujinx.Graphics.Texture { int outOffs = 0; - int w = width; - int h = height; - - w = BitUtils.DivRoundUp(w, blockWidth); - h = BitUtils.DivRoundUp(h, blockHeight); + int w = BitUtils.DivRoundUp(width, blockWidth); + int h = BitUtils.DivRoundUp(height, blockHeight); int outStride = BitUtils.AlignUp(w * bytesPerPixel, AlignmentSize);