aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs
diff options
context:
space:
mode:
authorgdk <gab.dark.100@gmail.com>2019-10-13 03:02:07 -0300
committerThog <thog@protonmail.com>2020-01-09 02:13:00 +0100
commit1876b346fea647e8284a66bb6d62c38801035cff (patch)
tree6eeff094298cda84d1613dc5ec0691e51d7b35f1 /Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs
parentf617fb542a0e3d36012d77a4b5acbde7b08902f2 (diff)
Initial work
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs b/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs
new file mode 100644
index 00000000..e2c40805
--- /dev/null
+++ b/Ryujinx.Graphics.Gpu/Engine/MethodCopyTexture.cs
@@ -0,0 +1,70 @@
+using Ryujinx.Graphics.GAL;
+using Ryujinx.Graphics.Gpu.State;
+
+namespace Ryujinx.Graphics.Gpu.Engine
+{
+ partial class Methods
+ {
+ private void CopyTexture(int argument)
+ {
+ CopyTexture dstCopyTexture = _context.State.GetCopyDstTexture();
+ CopyTexture srcCopyTexture = _context.State.GetCopySrcTexture();
+
+ Image.Texture srcTexture = _textureManager.FindOrCreateTexture(srcCopyTexture);
+
+ if (srcTexture == null)
+ {
+ return;
+ }
+
+ // When the source texture that was found has a depth format,
+ // we must enforce the target texture also has a depth format,
+ // as copies between depth and color formats are not allowed.
+ if (srcTexture.Format == Format.D32Float)
+ {
+ dstCopyTexture.Format = RtFormat.D32Float;
+ }
+
+ Image.Texture dstTexture = _textureManager.FindOrCreateTexture(dstCopyTexture);
+
+ if (dstTexture == null)
+ {
+ return;
+ }
+
+ CopyTextureControl control = _context.State.GetCopyTextureControl();
+
+ CopyRegion region = _context.State.GetCopyRegion();
+
+ int srcX1 = (int)(region.SrcXF >> 32);
+ int srcY1 = (int)(region.SrcYF >> 32);
+
+ int srcX2 = (int)((region.SrcXF + region.SrcWidthRF * region.DstWidth) >> 32);
+ int srcY2 = (int)((region.SrcYF + region.SrcHeightRF * region.DstHeight) >> 32);
+
+ int dstX1 = region.DstX;
+ int dstY1 = region.DstY;
+
+ int dstX2 = region.DstX + region.DstWidth;
+ int dstY2 = region.DstY + region.DstHeight;
+
+ Extents2D srcRegion = new Extents2D(
+ srcX1 / srcTexture.Info.SamplesInX,
+ srcY1 / srcTexture.Info.SamplesInY,
+ srcX2 / srcTexture.Info.SamplesInX,
+ srcY2 / srcTexture.Info.SamplesInY);
+
+ Extents2D dstRegion = new Extents2D(
+ dstX1 / dstTexture.Info.SamplesInX,
+ dstY1 / dstTexture.Info.SamplesInY,
+ dstX2 / dstTexture.Info.SamplesInX,
+ dstY2 / dstTexture.Info.SamplesInY);
+
+ bool linearFilter = control.UnpackLinearFilter();
+
+ srcTexture.HostTexture.CopyTo(dstTexture.HostTexture, srcRegion, dstRegion, linearFilter);
+
+ dstTexture.Modified = true;
+ }
+ }
+} \ No newline at end of file