From 7a27990faa557c5c93f52e5cb082d551ad119ed0 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Mon, 12 Mar 2018 01:04:52 -0300 Subject: Allow more than one process, free resources on process dispose, implement SvcExitThread --- Ryujinx.Graphics/Gal/IGalRenderer.cs | 1 + Ryujinx.Graphics/Gal/OpenGL/FrameBuffer.cs | 32 +++++++++++++++++++++------ Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs | 5 +++++ 3 files changed, 31 insertions(+), 7 deletions(-) (limited to 'Ryujinx.Graphics') diff --git a/Ryujinx.Graphics/Gal/IGalRenderer.cs b/Ryujinx.Graphics/Gal/IGalRenderer.cs index 83d2c699..aa4eac4e 100644 --- a/Ryujinx.Graphics/Gal/IGalRenderer.cs +++ b/Ryujinx.Graphics/Gal/IGalRenderer.cs @@ -8,6 +8,7 @@ namespace Ryujinx.Graphics.Gal void RunActions(); void InitializeFrameBuffer(); + void ResetFrameBuffer(); void Render(); void SetWindowSize(int Width, int Height); void SetFrameBuffer( diff --git a/Ryujinx.Graphics/Gal/OpenGL/FrameBuffer.cs b/Ryujinx.Graphics/Gal/OpenGL/FrameBuffer.cs index 7dc4bffe..b761811f 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/FrameBuffer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/FrameBuffer.cs @@ -24,6 +24,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL private byte* FbPtr; + private object FbPtrLock; + public FrameBuffer(int Width, int Height) { if (Width < 0) @@ -36,6 +38,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL throw new ArgumentOutOfRangeException(nameof(Height)); } + FbPtrLock = new object(); + TexWidth = Width; TexHeight = Height; @@ -152,7 +156,10 @@ namespace Ryujinx.Graphics.Gal.OpenGL throw new ArgumentOutOfRangeException(nameof(Height)); } - FbPtr = Fb; + lock (FbPtrLock) + { + FbPtr = Fb; + } if (Width != TexWidth || Height != TexHeight) @@ -178,17 +185,28 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.Uniform2(OffsetUniformLocation, Offs); } - public void Render() + public void Reset() { - if (FbPtr == null) + lock (FbPtrLock) { - return; + FbPtr = null; } + } - for (int Y = 0; Y < TexHeight; Y++) - for (int X = 0; X < TexWidth; X++) + public void Render() + { + lock (FbPtrLock) { - Pixels[X + Y * TexWidth] = *((int*)(FbPtr + GetSwizzleOffset(X, Y))); + if (FbPtr == null) + { + return; + } + + for (int Y = 0; Y < TexHeight; Y++) + for (int X = 0; X < TexWidth; X++) + { + Pixels[X + Y * TexWidth] = *((int*)(FbPtr + GetSwizzleOffset(X, Y))); + } } GL.BindTexture(TextureTarget.Texture2D, TexHandle); diff --git a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs index bdedfc1a..002e54da 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs @@ -43,6 +43,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL FbRenderer = new FrameBuffer(1280, 720); } + public void ResetFrameBuffer() + { + FbRenderer.Reset(); + } + public void QueueAction(Action ActionMthd) { ActionsQueue.Enqueue(ActionMthd); -- cgit v1.2.3