Code cleanup

This commit is contained in:
ReinUsesLisp 2018-08-16 20:20:01 -03:00
commit 6e48aa253c
4 changed files with 20 additions and 29 deletions

View file

@ -1,7 +1,6 @@
using OpenTK; using OpenTK;
using OpenTK.Graphics.OpenGL; using OpenTK.Graphics.OpenGL;
using System; using System;
using System.Collections.Generic;
namespace Ryujinx.Graphics.Gal.OpenGL namespace Ryujinx.Graphics.Gal.OpenGL
{ {
@ -56,12 +55,17 @@ namespace Ryujinx.Graphics.Gal.OpenGL
private int CropRight; private int CropRight;
private int CropBottom; private int CropBottom;
//This framebuffer is used to attach guest rendertargets,
//think of it as a dummy OpenGL VAO
private int DummyFrameBuffer; private int DummyFrameBuffer;
//These framebuffers are used to blit images
private int SrcFb; private int SrcFb;
private int DstFb; private int DstFb;
//Holds current attachments, used to avoid unnecesary calls to OpenGL
private int[] ColorAttachments; private int[] ColorAttachments;
private int DepthAttachment; private int DepthAttachment;
private int StencilAttachment; private int StencilAttachment;
@ -92,20 +96,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Attach(ref ColorAttachments[Attachment], 0, FramebufferAttachment.ColorAttachment0 + Attachment); Attach(ref ColorAttachments[Attachment], 0, FramebufferAttachment.ColorAttachment0 + Attachment);
} }
private void Attach(ref int OldHandle, int NewHandle, FramebufferAttachment FbAttachment)
{
if (OldHandle != NewHandle)
{
GL.FramebufferTexture(
FramebufferTarget.DrawFramebuffer,
FbAttachment,
NewHandle,
0);
OldHandle = NewHandle;
}
}
public void BindZeta(long Key) public void BindZeta(long Key)
{ {
@ -436,6 +426,20 @@ namespace Ryujinx.Graphics.Gal.OpenGL
GL.DrawBuffers(8, DrawBuffers); GL.DrawBuffers(8, DrawBuffers);
} }
private void Attach(ref int OldHandle, int NewHandle, FramebufferAttachment FbAttachment)
{
if (OldHandle != NewHandle)
{
GL.FramebufferTexture(
FramebufferTarget.DrawFramebuffer,
FbAttachment,
NewHandle,
0);
OldHandle = NewHandle;
}
}
private void CopyTextures( private void CopyTextures(
int SrcX0, int SrcX0,
int SrcY0, int SrcY0,

View file

@ -72,8 +72,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
(PixelInternalFormat InternalFormat, PixelFormat Format, PixelType Type) = OGLEnumConverter.GetImageFormat(Image.Format); (PixelInternalFormat InternalFormat, PixelFormat Format, PixelType Type) = OGLEnumConverter.GetImageFormat(Image.Format);
GL.GetError();
GL.TexImage2D( GL.TexImage2D(
TextureTarget.Texture2D, TextureTarget.Texture2D,
Level, Level,
@ -84,11 +82,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
Format, Format,
Type, Type,
Data); Data);
if (GL.GetError() != ErrorCode.NoError)
{
throw new InvalidOperationException($"{InternalFormat} {Format} {Type}");
}
} }
int SwizzleR = (int)OGLEnumConverter.GetTextureSwizzle(Image.XSource); int SwizzleR = (int)OGLEnumConverter.GetTextureSwizzle(Image.XSource);

View file

@ -89,8 +89,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
const int Level = 0; const int Level = 0;
const int Border = 0; const int Border = 0;
GL.GetError();
GL.TexImage2D( GL.TexImage2D(
TextureTarget.Texture2D, TextureTarget.Texture2D,
Level, Level,
@ -102,11 +100,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
PixelType, PixelType,
IntPtr.Zero); IntPtr.Zero);
if (GL.GetError() != ErrorCode.NoError)
{
throw new InvalidOperationException($"{InternalFormat} {PixelFormat} {PixelType}");
}
if (Initialized) if (Initialized)
{ {
GL.BindBuffer(BufferTarget.PixelPackBuffer, 0); GL.BindBuffer(BufferTarget.PixelPackBuffer, 0);

View file

@ -102,6 +102,7 @@ namespace Ryujinx.HLE.Gpu.Engines
SetAlphaBlending(State); SetAlphaBlending(State);
SetPrimitiveRestart(State); SetPrimitiveRestart(State);
//Enabling multiple framebuffer attachments cause graphics reggresions
SetFrameBuffer(Vmm, 0); SetFrameBuffer(Vmm, 0);
SetZeta(Vmm); SetZeta(Vmm);