From 76e5af967a39879187214f0973d226eba126e93f Mon Sep 17 00:00:00 2001 From: gdkchan Date: Fri, 3 Jul 2020 20:37:36 -0300 Subject: [PATCH] Fix buffer to 3D texture copy (#1354) --- Ryujinx.Graphics.Gpu/Engine/MethodCopyBuffer.cs | 4 +++- Ryujinx.Graphics.Texture/BlockLinearLayout.cs | 1 - Ryujinx.Graphics.Texture/LayoutConverter.cs | 2 -- Ryujinx.Graphics.Texture/OffsetCalculator.cs | 14 ++++++++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodCopyBuffer.cs b/Ryujinx.Graphics.Gpu/Engine/MethodCopyBuffer.cs index 2e6fe0ab..277054ce 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodCopyBuffer.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodCopyBuffer.cs @@ -44,6 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Engine cbp.SrcStride, srcLinear, src.MemoryLayout.UnpackGobBlocksInY(), + src.MemoryLayout.UnpackGobBlocksInZ(), srcBpp); var dstCalculator = new OffsetCalculator( @@ -52,6 +53,7 @@ namespace Ryujinx.Graphics.Gpu.Engine cbp.DstStride, dstLinear, dst.MemoryLayout.UnpackGobBlocksInY(), + dst.MemoryLayout.UnpackGobBlocksInZ(), dstBpp); ulong srcBaseAddress = _context.MemoryManager.Translate(cbp.SrcAddress.Pack()); @@ -70,7 +72,7 @@ namespace Ryujinx.Graphics.Gpu.Engine { srcSpan.CopyTo(dstSpan); // No layout conversion has to be performed, just copy the data entirely. } - else + else { unsafe bool Convert(Span dstSpan, ReadOnlySpan srcSpan) where T : unmanaged { diff --git a/Ryujinx.Graphics.Texture/BlockLinearLayout.cs b/Ryujinx.Graphics.Texture/BlockLinearLayout.cs index 0b112242..02b69987 100644 --- a/Ryujinx.Graphics.Texture/BlockLinearLayout.cs +++ b/Ryujinx.Graphics.Texture/BlockLinearLayout.cs @@ -41,7 +41,6 @@ namespace Ryujinx.Graphics.Texture public BlockLinearLayout( int width, int height, - int depth, int gobBlocksInY, int gobBlocksInZ, int bpp) diff --git a/Ryujinx.Graphics.Texture/LayoutConverter.cs b/Ryujinx.Graphics.Texture/LayoutConverter.cs index 525271c4..2ad57d59 100644 --- a/Ryujinx.Graphics.Texture/LayoutConverter.cs +++ b/Ryujinx.Graphics.Texture/LayoutConverter.cs @@ -84,7 +84,6 @@ namespace Ryujinx.Graphics.Texture BlockLinearLayout layoutConverter = new BlockLinearLayout( wAligned, h, - d, mipGobBlocksInY, mipGobBlocksInZ, bytesPerPixel); @@ -256,7 +255,6 @@ namespace Ryujinx.Graphics.Texture BlockLinearLayout layoutConverter = new BlockLinearLayout( wAligned, h, - d, mipGobBlocksInY, mipGobBlocksInZ, bytesPerPixel); diff --git a/Ryujinx.Graphics.Texture/OffsetCalculator.cs b/Ryujinx.Graphics.Texture/OffsetCalculator.cs index 1f5d9614..6d283954 100644 --- a/Ryujinx.Graphics.Texture/OffsetCalculator.cs +++ b/Ryujinx.Graphics.Texture/OffsetCalculator.cs @@ -23,6 +23,7 @@ namespace Ryujinx.Graphics.Texture int stride, bool isLinear, int gobBlocksInY, + int gobBlocksInZ, int bytesPerPixel) { _width = width; @@ -40,13 +41,22 @@ namespace Ryujinx.Graphics.Texture _layoutConverter = new BlockLinearLayout( wAligned, height, - 1, gobBlocksInY, - 1, + gobBlocksInZ, bytesPerPixel); } } + public OffsetCalculator( + int width, + int height, + int stride, + bool isLinear, + int gobBlocksInY, + int bytesPerPixel) : this(width, height, stride, isLinear, gobBlocksInY, 1, bytesPerPixel) + { + } + public void SetY(int y) { if (_isLinear)