1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-10 10:21:43 +00:00

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
This commit is contained in:
Mary 2021-06-01 09:29:01 +02:00 committed by GitHub
parent 79b3243f54
commit 7527c5b906
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 13 deletions

View file

@ -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;

View file

@ -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);