diff options
author | gdkchan <gab.dark.100@gmail.com> | 2021-01-26 18:44:07 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-27 08:44:07 +1100 |
commit | caf049ed15f1c22d55aacfab79019538b2587e11 (patch) | |
tree | 33bf4b410a901fd8de49b79b73161976453e4837 /Ryujinx.Graphics.OpenGL/Pipeline.cs | |
parent | d6bd0470fb0507cc9c6069e577ae2814e614265b (diff) |
Avoid some redundant GL calls (#1958)
Diffstat (limited to 'Ryujinx.Graphics.OpenGL/Pipeline.cs')
-rw-r--r-- | Ryujinx.Graphics.OpenGL/Pipeline.cs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs index b6a34e9c..f42187bd 100644 --- a/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.OpenGL private readonly uint[] _componentMasks; - private bool _scissor0Enable = false; + private uint _scissorEnables; private bool _tfEnabled; private TransformFeedbackPrimitiveType _tfTopology; @@ -883,25 +883,27 @@ namespace Ryujinx.Graphics.OpenGL ((Sampler)sampler).Bind(binding); } - public void SetScissorEnable(int index, bool enable) + public void SetScissor(int index, bool enable, int x, int y, int width, int height) { - if (enable) - { - GL.Enable(IndexedEnableCap.ScissorTest, index); - } - else + uint mask = 1u << index; + + if (!enable) { - GL.Disable(IndexedEnableCap.ScissorTest, index); + if ((_scissorEnables & mask) != 0) + { + _scissorEnables &= ~mask; + GL.Disable(IndexedEnableCap.ScissorTest, index); + } + + return; } - if (index == 0) + if ((_scissorEnables & mask) == 0) { - _scissor0Enable = enable; + _scissorEnables |= mask; + GL.Enable(IndexedEnableCap.ScissorTest, index); } - } - public void SetScissor(int index, int x, int y, int width, int height) - { GL.ScissorIndexed(index, x, y, width, height); } @@ -1241,7 +1243,7 @@ namespace Ryujinx.Graphics.OpenGL public void RestoreScissor0Enable() { - if (_scissor0Enable) + if ((_scissorEnables & 1u) != 0) { GL.Enable(IndexedEnableCap.ScissorTest, 0); } |