From da4bcfbf48c2ae10161e4a843b8237734886e771 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Wed, 5 Sep 2018 00:03:15 -0300 Subject: [PATCH] Remove MaxBpp hardcoded value --- Ryujinx.Graphics/Gal/OpenGL/ImageHandler.cs | 29 ++++++++----------- .../Gal/OpenGL/OGLRenderTarget.cs | 3 +- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Ryujinx.Graphics/Gal/OpenGL/ImageHandler.cs b/Ryujinx.Graphics/Gal/OpenGL/ImageHandler.cs index 94e062a728..56ddf820ac 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/ImageHandler.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/ImageHandler.cs @@ -6,9 +6,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL { class ImageHandler { - //TODO: Use a variable value here - public const int MaxBpp = 16; - private static int CopyBuffer = 0; private static int CopyBufferSize = 0; @@ -39,15 +36,15 @@ namespace Ryujinx.Graphics.Gal.OpenGL this.Image = Image; } - public void EnsureSetup(GalImage Image) + public void EnsureSetup(GalImage NewImage) { - if (Width != Image.Width || - Height != Image.Height || - Format != Image.Format || + if (Width != NewImage.Width || + Height != NewImage.Height || + Format != NewImage.Format || !Initialized) { (PixelInternalFormat InternalFormat, PixelFormat PixelFormat, PixelType PixelType) = - OGLEnumConverter.GetImageFormat(Image.Format); + OGLEnumConverter.GetImageFormat(NewImage.Format); GL.BindTexture(TextureTarget.Texture2D, Handle); @@ -58,12 +55,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL CopyBuffer = GL.GenBuffer(); } - int MaxWidth = Math.Max(Image.Width, Width); - int MaxHeight = Math.Max(Image.Height, Height); + int CurrentSize = Math.Max(ImageTable.GetImageSize(NewImage), + ImageTable.GetImageSize(Image)); - int CurrentSize = MaxWidth * MaxHeight * MaxBpp; - - GL.BindBuffer(BufferTarget.PixelPackBuffer, CopyBuffer); + GL.BindBuffer(BufferTarget.PixelPackBuffer, CopyBuffer); GL.BindBuffer(BufferTarget.PixelUnpackBuffer, CopyBuffer); if (CopyBufferSize < CurrentSize) @@ -95,8 +90,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL TextureTarget.Texture2D, Level, InternalFormat, - Image.Width, - Image.Height, + NewImage.Width, + NewImage.Height, Border, PixelFormat, PixelType, @@ -104,11 +99,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL if (Initialized) { - GL.BindBuffer(BufferTarget.PixelPackBuffer, 0); + GL.BindBuffer(BufferTarget.PixelPackBuffer, 0); GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0); } - this.Image = Image; + Image = NewImage; this.InternalFormat = InternalFormat; this.PixelFormat = PixelFormat; diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs index 0c738f051a..a169e75d21 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLRenderTarget.cs @@ -1,4 +1,5 @@ using OpenTK.Graphics.OpenGL; +using Ryujinx.Graphics.Texture; using System; namespace Ryujinx.Graphics.Gal.OpenGL @@ -379,7 +380,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL { if (Texture.TryGetImage(Key, out ImageHandler Tex)) { - byte[] Data = new byte[Tex.Width * Tex.Height * ImageHandler.MaxBpp]; + byte[] Data = new byte[ImageTable.GetImageSize(Tex.Image)]; GL.BindTexture(TextureTarget.Texture2D, Tex.Handle);