From 6e48aa253cefe59deb449a2ab70e4c8ce9de556a Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Thu, 16 Aug 2018 20:20:01 -0300 Subject: [PATCH] Code cleanup --- Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs | 34 +++++++++++-------- Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs | 7 ---- Ryujinx.Graphics/Gal/OpenGL/TCE.cs | 7 ---- Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs | 1 + 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs index 7f8cb63ffc..5badfcfb2a 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs @@ -1,7 +1,6 @@ using OpenTK; using OpenTK.Graphics.OpenGL; using System; -using System.Collections.Generic; namespace Ryujinx.Graphics.Gal.OpenGL { @@ -56,12 +55,17 @@ namespace Ryujinx.Graphics.Gal.OpenGL private int CropRight; private int CropBottom; + //This framebuffer is used to attach guest rendertargets, + //think of it as a dummy OpenGL VAO private int DummyFrameBuffer; + //These framebuffers are used to blit images private int SrcFb; private int DstFb; + //Holds current attachments, used to avoid unnecesary calls to OpenGL private int[] ColorAttachments; + private int DepthAttachment; private int StencilAttachment; @@ -92,20 +96,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL 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) { @@ -436,6 +426,20 @@ namespace Ryujinx.Graphics.Gal.OpenGL 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( int SrcX0, int SrcY0, diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs index fe865cf422..ba43951005 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLTexture.cs @@ -72,8 +72,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL (PixelInternalFormat InternalFormat, PixelFormat Format, PixelType Type) = OGLEnumConverter.GetImageFormat(Image.Format); - GL.GetError(); - GL.TexImage2D( TextureTarget.Texture2D, Level, @@ -84,11 +82,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL Format, Type, Data); - - if (GL.GetError() != ErrorCode.NoError) - { - throw new InvalidOperationException($"{InternalFormat} {Format} {Type}"); - } } int SwizzleR = (int)OGLEnumConverter.GetTextureSwizzle(Image.XSource); diff --git a/Ryujinx.Graphics/Gal/OpenGL/TCE.cs b/Ryujinx.Graphics/Gal/OpenGL/TCE.cs index ea130e086b..5f7cff8fc9 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/TCE.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/TCE.cs @@ -89,8 +89,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL const int Level = 0; const int Border = 0; - GL.GetError(); - GL.TexImage2D( TextureTarget.Texture2D, Level, @@ -102,11 +100,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL PixelType, IntPtr.Zero); - if (GL.GetError() != ErrorCode.NoError) - { - throw new InvalidOperationException($"{InternalFormat} {PixelFormat} {PixelType}"); - } - if (Initialized) { GL.BindBuffer(BufferTarget.PixelPackBuffer, 0); diff --git a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs index 28142e6418..f04eee5f62 100644 --- a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs @@ -102,6 +102,7 @@ namespace Ryujinx.HLE.Gpu.Engines SetAlphaBlending(State); SetPrimitiveRestart(State); + //Enabling multiple framebuffer attachments cause graphics reggresions SetFrameBuffer(Vmm, 0); SetZeta(Vmm);