aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary <me@thog.eu>2021-06-01 09:29:01 +0200
committerGitHub <noreply@github.com>2021-06-01 09:29:01 +0200
commit7527c5b906b386eedaf285a0b0923174e37bb6d4 (patch)
tree918f6d07145c962102e17a9e81ed88af836da771
parent79b3243f54810eb7d449b739c8040af711c0a73c (diff)
Avoid clearing alpha channel by handle when presenting (#2323)
* Avoid clearning alpha channel by handle when presenting Previous code was binding then blitting while the framebuffer was bound and then clearing the alpha channel by its handle. This ended up triggering a bug since AMD driver 21.4.1 ending up clearing the whole framebuffer as a result. New code fix this weird logic by applying the clear on the bound framebuffer. Close #2236. * Address rip's comments * Fix AMD being broken once again
-rw-r--r--Ryujinx.Graphics.OpenGL/Pipeline.cs2
-rw-r--r--Ryujinx.Graphics.OpenGL/Window.cs20
2 files changed, 9 insertions, 13 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs
index fcb0fdf1..ed3507a3 100644
--- a/Ryujinx.Graphics.OpenGL/Pipeline.cs
+++ b/Ryujinx.Graphics.OpenGL/Pipeline.cs
@@ -1232,7 +1232,7 @@ namespace Ryujinx.Graphics.OpenGL
}
}
- private void RestoreComponentMask(int index)
+ public void RestoreComponentMask(int index)
{
// If the bound render target is bgra, swap the red and blue masks.
uint redMask = _fpIsBgra[index] == 0 ? 1u : 4u;
diff --git a/Ryujinx.Graphics.OpenGL/Window.cs b/Ryujinx.Graphics.OpenGL/Window.cs
index 5de2a645..b7525ae5 100644
--- a/Ryujinx.Graphics.OpenGL/Window.cs
+++ b/Ryujinx.Graphics.OpenGL/Window.cs
@@ -1,4 +1,3 @@
-using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.OpenGL.Image;
@@ -39,12 +38,8 @@ namespace Ryujinx.Graphics.OpenGL
private void CopyTextureToFrameBufferRGB(int drawFramebuffer, int readFramebuffer, TextureView view, ImageCrop crop)
{
- bool[] oldFramebufferColorWritemask = new bool[4];
-
(int oldDrawFramebufferHandle, int oldReadFramebufferHandle) = ((Pipeline)_renderer.Pipeline).GetBoundFramebuffers();
- GL.GetBoolean(GetIndexedPName.ColorWritemask, drawFramebuffer, oldFramebufferColorWritemask);
-
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, drawFramebuffer);
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, readFramebuffer);
@@ -124,13 +119,14 @@ namespace Ryujinx.Graphics.OpenGL
BlitFramebufferFilter.Linear);
// Remove Alpha channel
- GL.ColorMask(drawFramebuffer, false, false, false, true);
- GL.ClearBuffer(ClearBuffer.Color, drawFramebuffer, new float[] { 0.0f, 0.0f, 0.0f, 1.0f });
- GL.ColorMask(drawFramebuffer,
- oldFramebufferColorWritemask[0],
- oldFramebufferColorWritemask[1],
- oldFramebufferColorWritemask[2],
- oldFramebufferColorWritemask[3]);
+ GL.ColorMask(false, false, false, true);
+ GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+ GL.Clear(ClearBufferMask.ColorBufferBit);
+
+ for (int i = 0; i < Constants.MaxRenderTargets; i++)
+ {
+ ((Pipeline)_renderer.Pipeline).RestoreComponentMask(i);
+ }
GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, oldReadFramebufferHandle);
GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, oldDrawFramebufferHandle);