Remove MaxBpp hardcoded value
This commit is contained in:
parent
c6c8a21054
commit
da4bcfbf48
2 changed files with 14 additions and 18 deletions
|
@ -6,9 +6,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
class ImageHandler
|
class ImageHandler
|
||||||
{
|
{
|
||||||
//TODO: Use a variable value here
|
|
||||||
public const int MaxBpp = 16;
|
|
||||||
|
|
||||||
private static int CopyBuffer = 0;
|
private static int CopyBuffer = 0;
|
||||||
private static int CopyBufferSize = 0;
|
private static int CopyBufferSize = 0;
|
||||||
|
|
||||||
|
@ -39,15 +36,15 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
this.Image = Image;
|
this.Image = Image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnsureSetup(GalImage Image)
|
public void EnsureSetup(GalImage NewImage)
|
||||||
{
|
{
|
||||||
if (Width != Image.Width ||
|
if (Width != NewImage.Width ||
|
||||||
Height != Image.Height ||
|
Height != NewImage.Height ||
|
||||||
Format != Image.Format ||
|
Format != NewImage.Format ||
|
||||||
!Initialized)
|
!Initialized)
|
||||||
{
|
{
|
||||||
(PixelInternalFormat InternalFormat, PixelFormat PixelFormat, PixelType PixelType) =
|
(PixelInternalFormat InternalFormat, PixelFormat PixelFormat, PixelType PixelType) =
|
||||||
OGLEnumConverter.GetImageFormat(Image.Format);
|
OGLEnumConverter.GetImageFormat(NewImage.Format);
|
||||||
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, Handle);
|
GL.BindTexture(TextureTarget.Texture2D, Handle);
|
||||||
|
|
||||||
|
@ -58,12 +55,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
CopyBuffer = GL.GenBuffer();
|
CopyBuffer = GL.GenBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
int MaxWidth = Math.Max(Image.Width, Width);
|
int CurrentSize = Math.Max(ImageTable.GetImageSize(NewImage),
|
||||||
int MaxHeight = Math.Max(Image.Height, Height);
|
ImageTable.GetImageSize(Image));
|
||||||
|
|
||||||
int CurrentSize = MaxWidth * MaxHeight * MaxBpp;
|
GL.BindBuffer(BufferTarget.PixelPackBuffer, CopyBuffer);
|
||||||
|
|
||||||
GL.BindBuffer(BufferTarget.PixelPackBuffer, CopyBuffer);
|
|
||||||
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, CopyBuffer);
|
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, CopyBuffer);
|
||||||
|
|
||||||
if (CopyBufferSize < CurrentSize)
|
if (CopyBufferSize < CurrentSize)
|
||||||
|
@ -95,8 +90,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
TextureTarget.Texture2D,
|
TextureTarget.Texture2D,
|
||||||
Level,
|
Level,
|
||||||
InternalFormat,
|
InternalFormat,
|
||||||
Image.Width,
|
NewImage.Width,
|
||||||
Image.Height,
|
NewImage.Height,
|
||||||
Border,
|
Border,
|
||||||
PixelFormat,
|
PixelFormat,
|
||||||
PixelType,
|
PixelType,
|
||||||
|
@ -104,11 +99,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
if (Initialized)
|
if (Initialized)
|
||||||
{
|
{
|
||||||
GL.BindBuffer(BufferTarget.PixelPackBuffer, 0);
|
GL.BindBuffer(BufferTarget.PixelPackBuffer, 0);
|
||||||
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0);
|
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Image = Image;
|
Image = NewImage;
|
||||||
|
|
||||||
this.InternalFormat = InternalFormat;
|
this.InternalFormat = InternalFormat;
|
||||||
this.PixelFormat = PixelFormat;
|
this.PixelFormat = PixelFormat;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
|
using Ryujinx.Graphics.Texture;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gal.OpenGL
|
namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
@ -379,7 +380,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
{
|
{
|
||||||
if (Texture.TryGetImage(Key, out ImageHandler Tex))
|
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);
|
GL.BindTexture(TextureTarget.Texture2D, Tex.Handle);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue