From e25b7c9848b6ec486eb513297b5c536857665c7f Mon Sep 17 00:00:00 2001 From: gdkchan Date: Thu, 5 Dec 2019 17:34:47 -0300 Subject: Initial support for the guest OpenGL driver (NVIDIA and Nouveau) --- Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs') diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs b/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs index c482451a..1b47eac2 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs @@ -64,6 +64,29 @@ namespace Ryujinx.Graphics.Gpu.Engine srcTexture.HostTexture.CopyTo(dstTexture.HostTexture, srcRegion, dstRegion, linearFilter); + // For an out of bounds copy, we must ensure that the copy wraps to the next line, + // so for a copy from a 64x64 texture, in the region [32, 96[, there are 32 pixels that are + // outside the bounds of the texture. We fill the destination with the first 32 pixels + // of the next line on the source texture. + // This can be emulated with 2 copies (the first copy handles the region inside the bounds, + // the second handles the region outside of the bounds). + // We must also extend the source texture by one line to ensure we can wrap on the last line. + // This is required by the (guest) OpenGL driver. + if (srcRegion.X2 > srcTexture.Info.Width) + { + srcCopyTexture.Height++; + + srcTexture = _textureManager.FindOrCreateTexture(srcCopyTexture); + + srcRegion = new Extents2D( + srcRegion.X1 - srcTexture.Info.Width, + srcRegion.Y1 + 1, + srcRegion.X2 - srcTexture.Info.Width, + srcRegion.Y2 + 1); + + srcTexture.HostTexture.CopyTo(dstTexture.HostTexture, srcRegion, dstRegion, linearFilter); + } + dstTexture.Modified = true; } } -- cgit v1.2.3