diff options
author | gdkchan <gab.dark.100@gmail.com> | 2021-05-21 20:26:49 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-22 01:26:49 +0200 |
commit | e9c15d32cbdd5d59373ede7d5dd15f4150ef3c4c (patch) | |
tree | 81ccf8f9cfbd6951e50e08ac277835ac042ece5a /Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs | |
parent | a03bbef4d665143420c7d7f561f07aa2c3db1c3e (diff) |
Use a different method for out of bounds blit (#2302)
* Use a different method for out of bounds blit
* This is not needed
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs b/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs index 173f5fe4..1a22bdbf 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs @@ -43,7 +43,26 @@ namespace Ryujinx.Graphics.Gpu.Engine var srcCopyTextureFormat = srcCopyTexture.Format.Convert(); - Texture srcTexture = TextureManager.FindOrCreateTexture(srcCopyTexture, srcCopyTextureFormat, true, srcHint); + int srcWidthAligned = srcCopyTexture.Stride / srcCopyTextureFormat.BytesPerPixel; + + ulong offset = 0; + + // 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 done by simply adding an offset to the texture address, so that the initial + // gap is skipped and the copy is inside bounds again. + // This is required by the proprietary guest OpenGL driver. + if (srcCopyTexture.LinearLayout && srcCopyTexture.Width == srcX2 && srcX2 > srcWidthAligned && srcX1 > 0) + { + offset = (ulong)(srcX1 * srcCopyTextureFormat.BytesPerPixel); + srcCopyTexture.Width -= srcX1; + srcX2 -= srcX1; + srcX1 = 0; + } + + Texture srcTexture = TextureManager.FindOrCreateTexture(srcCopyTexture, offset, srcCopyTextureFormat, true, srcHint); if (srcTexture == null) { @@ -64,7 +83,7 @@ namespace Ryujinx.Graphics.Gpu.Engine dstCopyTextureFormat = dstCopyTexture.Format.Convert(); } - Texture dstTexture = TextureManager.FindOrCreateTexture(dstCopyTexture, dstCopyTextureFormat, srcTexture.ScaleMode == TextureScaleMode.Scaled, dstHint); + Texture dstTexture = TextureManager.FindOrCreateTexture(dstCopyTexture, 0, dstCopyTextureFormat, srcTexture.ScaleMode == TextureScaleMode.Scaled, dstHint); if (dstTexture == null) { @@ -90,30 +109,6 @@ 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 (srcX2 / srcTexture.Info.SamplesInX > srcTexture.Info.Width) - { - srcCopyTexture.Height++; - - srcTexture = TextureManager.FindOrCreateTexture(srcCopyTexture, srcCopyTextureFormat, srcTexture.ScaleMode == TextureScaleMode.Scaled, srcHint); - scale = srcTexture.ScaleFactor; - - srcRegion = new Extents2D( - (int)Math.Ceiling(scale * ((srcX1 / srcTexture.Info.SamplesInX) - srcTexture.Info.Width)), - (int)Math.Ceiling(scale * ((srcY1 / srcTexture.Info.SamplesInY) + 1)), - (int)Math.Ceiling(scale * ((srcX2 / srcTexture.Info.SamplesInX) - srcTexture.Info.Width)), - (int)Math.Ceiling(scale * ((srcY2 / srcTexture.Info.SamplesInY) + 1))); - - srcTexture.HostTexture.CopyTo(dstTexture.HostTexture, srcRegion, dstRegion, linearFilter); - } - dstTexture.SignalModified(); } } |