diff options
Diffstat (limited to 'Ryujinx.Graphics.OpenGL')
| -rw-r--r-- | Ryujinx.Graphics.OpenGL/Pipeline.cs | 34 | ||||
| -rw-r--r-- | Ryujinx.Graphics.OpenGL/Renderer.cs | 6 | ||||
| -rw-r--r-- | Ryujinx.Graphics.OpenGL/TextureCopy.cs | 11 | ||||
| -rw-r--r-- | Ryujinx.Graphics.OpenGL/Window.cs | 12 |
4 files changed, 58 insertions, 5 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Pipeline.cs b/Ryujinx.Graphics.OpenGL/Pipeline.cs index c2a42370..f01e7c7a 100644 --- a/Ryujinx.Graphics.OpenGL/Pipeline.cs +++ b/Ryujinx.Graphics.OpenGL/Pipeline.cs @@ -31,10 +31,14 @@ namespace Ryujinx.Graphics.OpenGL private uint[] _componentMasks; + private readonly bool[] _scissorEnable; + internal Pipeline() { _clipOrigin = ClipOrigin.LowerLeft; _clipDepthMode = ClipDepthMode.NegativeOneToOne; + + _scissorEnable = new bool[8]; } public void Barrier() @@ -674,6 +678,25 @@ namespace Ryujinx.Graphics.OpenGL } } + public void SetScissorEnable(int index, bool enable) + { + if (enable) + { + GL.Enable(IndexedEnableCap.ScissorTest, index); + } + else + { + GL.Disable(IndexedEnableCap.ScissorTest, index); + } + + _scissorEnable[index] = enable; + } + + public void SetScissor(int index, int x, int y, int width, int height) + { + GL.ScissorIndexed(index, x, y, width, height); + } + public void SetStencilTest(StencilTestDescriptor stencilTest) { if (!stencilTest.TestEnable) @@ -928,6 +951,17 @@ namespace Ryujinx.Graphics.OpenGL } } + public void RestoreScissorEnable() + { + for (int index = 0; index < 8; index++) + { + if (_scissorEnable[index]) + { + GL.Enable(IndexedEnableCap.ScissorTest, index); + } + } + } + public void Dispose() { _framebuffer?.Dispose(); diff --git a/Ryujinx.Graphics.OpenGL/Renderer.cs b/Ryujinx.Graphics.OpenGL/Renderer.cs index 6ff3c36c..cf2adc45 100644 --- a/Ryujinx.Graphics.OpenGL/Renderer.cs +++ b/Ryujinx.Graphics.OpenGL/Renderer.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.OpenGL { public sealed class Renderer : IRenderer { - private Pipeline _pipeline; + private readonly Pipeline _pipeline; public IPipeline Pipeline => _pipeline; @@ -31,9 +31,9 @@ namespace Ryujinx.Graphics.OpenGL _counters = new Counters(); - _window = new Window(); + _window = new Window(this); - TextureCopy = new TextureCopy(); + TextureCopy = new TextureCopy(this); } public IShader CompileShader(ShaderProgram shader) diff --git a/Ryujinx.Graphics.OpenGL/TextureCopy.cs b/Ryujinx.Graphics.OpenGL/TextureCopy.cs index 27f1fd56..ac9459d4 100644 --- a/Ryujinx.Graphics.OpenGL/TextureCopy.cs +++ b/Ryujinx.Graphics.OpenGL/TextureCopy.cs @@ -6,9 +6,16 @@ namespace Ryujinx.Graphics.OpenGL { class TextureCopy : IDisposable { + private readonly Renderer _renderer; + private int _srcFramebuffer; private int _dstFramebuffer; + public TextureCopy(Renderer renderer) + { + _renderer = renderer; + } + public void Copy( TextureView src, TextureView dst, @@ -34,6 +41,8 @@ namespace Ryujinx.Graphics.OpenGL GL.ReadBuffer(ReadBufferMode.ColorAttachment0); GL.DrawBuffer(DrawBufferMode.ColorAttachment0); + GL.Disable(EnableCap.ScissorTest); + GL.BlitFramebuffer( srcRegion.X1, srcRegion.Y1, @@ -48,6 +57,8 @@ namespace Ryujinx.Graphics.OpenGL GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, oldReadFramebufferHandle); GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, oldDrawFramebufferHandle); + + ((Pipeline)_renderer.Pipeline).RestoreScissorEnable(); } private static void Attach(FramebufferTarget target, Format format, int handle) diff --git a/Ryujinx.Graphics.OpenGL/Window.cs b/Ryujinx.Graphics.OpenGL/Window.cs index 2689a7c4..c9b7daeb 100644 --- a/Ryujinx.Graphics.OpenGL/Window.cs +++ b/Ryujinx.Graphics.OpenGL/Window.cs @@ -9,13 +9,17 @@ namespace Ryujinx.Graphics.OpenGL private const int NativeWidth = 1280; private const int NativeHeight = 720; + private readonly Renderer _renderer; + private int _width; private int _height; private int _copyFramebufferHandle; - public Window() + public Window(Renderer renderer) { + _renderer = renderer; + _width = NativeWidth; _height = NativeHeight; } @@ -35,13 +39,13 @@ namespace Ryujinx.Graphics.OpenGL _height = height; } - private void CopyTextureToFrameBufferRGB(int drawFramebuffer, int readFramebuffer, TextureView view, ImageCrop crop) { bool[] oldFramebufferColorWritemask = new bool[4]; int oldReadFramebufferHandle = GL.GetInteger(GetPName.ReadFramebufferBinding); int oldDrawFramebufferHandle = GL.GetInteger(GetPName.DrawFramebufferBinding); + GL.GetBoolean(GetIndexedPName.ColorWritemask, drawFramebuffer, oldFramebufferColorWritemask); GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, drawFramebuffer); @@ -55,6 +59,8 @@ namespace Ryujinx.Graphics.OpenGL GL.ReadBuffer(ReadBufferMode.ColorAttachment0); + GL.Disable(EnableCap.ScissorTest); + GL.Clear(ClearBufferMask.ColorBufferBit); int srcX0, srcX1, srcY0, srcY1; @@ -119,6 +125,8 @@ namespace Ryujinx.Graphics.OpenGL GL.BindFramebuffer(FramebufferTarget.ReadFramebuffer, oldReadFramebufferHandle); GL.BindFramebuffer(FramebufferTarget.DrawFramebuffer, oldDrawFramebufferHandle); + + ((Pipeline)_renderer.Pipeline).RestoreScissorEnable(); } private int GetCopyFramebufferHandleLazy() |
