diff options
author | riperiperi <rhy3756547@hotmail.com> | 2021-03-08 00:12:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 11:12:19 +1100 |
commit | da283ff3c37629769324926e24a7b203f9901890 (patch) | |
tree | ace9d66ea1ba0bda82ca48723a99a4e8aab42ee4 /Ryujinx.Graphics.OpenGL/Pipeline.cs | |
parent | a539303e7165cf524dc5b5750da49cb4bd4be6d6 (diff) |
Flip component mask if target is BGRA. (#2087)
* Flip component mask if target is BGRA.
* Make mask selection less ugly.
Diffstat (limited to 'Ryujinx.Graphics.OpenGL/Pipeline.cs')
-rw-r--r-- | Ryujinx.Graphics.OpenGL/Pipeline.cs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs index f42187bd..28478a72 100644 --- a/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -862,7 +862,14 @@ namespace Ryujinx.Graphics.OpenGL _framebuffer.AttachColor(index, color); - _fpIsBgra[index] = color != null && color.Format.IsBgra8() ? 1 : 0; + int isBgra = color != null && color.Format.IsBgra8() ? 1 : 0; + + if (_fpIsBgra[index] != isBgra) + { + _fpIsBgra[index] = isBgra; + + RestoreComponentMask(index); + } } UpdateFpIsBgra(); @@ -1233,11 +1240,15 @@ namespace Ryujinx.Graphics.OpenGL private void RestoreComponentMask(int index) { + // If the bound render target is bgra, swap the red and blue masks. + uint redMask = _fpIsBgra[index] == 0 ? 1u : 4u; + uint blueMask = _fpIsBgra[index] == 0 ? 4u : 1u; + GL.ColorMask( index, - (_componentMasks[index] & 1u) != 0, + (_componentMasks[index] & redMask) != 0, (_componentMasks[index] & 2u) != 0, - (_componentMasks[index] & 4u) != 0, + (_componentMasks[index] & blueMask) != 0, (_componentMasks[index] & 8u) != 0); } |