aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs')
-rw-r--r--Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs42
1 files changed, 16 insertions, 26 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs
index 7dde32d8..ff5dc1b8 100644
--- a/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs
+++ b/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs
@@ -56,6 +56,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
private int DepthAttachment;
private int StencilAttachment;
+ private int CopyPBO;
+
public OGLRenderTarget(OGLTexture Texture)
{
ColorAttachments = new int[8];
@@ -358,45 +360,33 @@ namespace Ryujinx.Graphics.Gal.OpenGL
return;
}
- byte[] Data = GetData(Key);
-
- GL.PixelStore(PixelStoreParameter.UnpackRowLength, OldImage.Width);
+ if (CopyPBO == 0)
+ {
+ CopyPBO = GL.GenBuffer();
+ }
- Texture.Create(Key, Data, NewImage);
+ GL.BindBuffer(BufferTarget.PixelPackBuffer, CopyPBO);
- GL.PixelStore(PixelStoreParameter.UnpackRowLength, 0);
- }
+ GL.BufferData(BufferTarget.PixelPackBuffer, Math.Max(ImageUtils.GetSize(OldImage), ImageUtils.GetSize(NewImage)), IntPtr.Zero, BufferUsageHint.StreamCopy);
- public byte[] GetData(long Key)
- {
if (!Texture.TryGetImageHandler(Key, out ImageHandler CachedImage))
{
- return null;
- }
-
- if (SrcFb == 0)
- {
- SrcFb = GL.GenFramebuffer();
+ throw new InvalidOperationException();
}
- GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, SrcFb);
-
- FramebufferAttachment Attachment = GetAttachment(CachedImage);
-
- GL.FramebufferTexture(FramebufferTarget.ReadFramebuffer, Attachment, CachedImage.Handle, 0);
+ (_, PixelFormat Format, PixelType Type) = OGLEnumConverter.GetImageFormat(CachedImage.Format);
- int Size = ImageUtils.GetSize(CachedImage.Image);
+ GL.BindTexture(TextureTarget.Texture2D, CachedImage.Handle);
- byte[] Data = new byte[Size];
+ GL.GetTexImage(TextureTarget.Texture2D, 0, Format, Type, IntPtr.Zero);
- int Width = CachedImage.Width;
- int Height = CachedImage.Height;
+ GL.BindBuffer(BufferTarget.PixelPackBuffer, 0);
- (_, PixelFormat Format, PixelType Type) = OGLEnumConverter.GetImageFormat(CachedImage.Format);
+ GL.BindBuffer(BufferTarget.PixelUnpackBuffer, CopyPBO);
- GL.ReadPixels(0, 0, Width, Height, Format, Type, Data);
+ Texture.Create(Key, ImageUtils.GetSize(NewImage), NewImage);
- return Data;
+ GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0);
}
private static FramebufferAttachment GetAttachment(ImageHandler CachedImage)