From 6d104edb5d84f1b30c5dc6ce31cddd88854052b2 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 22 Jun 2014 21:42:29 -0700 Subject: [PATCH] Make sure not to leak any enabled vertex arrays. When returning to EmuScreen, we need to reset any enabled vertex arrays or we could crash in EmuScreen. Also, when starting a frame / dirting the shader, make sure also to toggle the vertex arrays. --- Core/System.cpp | 2 ++ GPU/GLES/GLES_GPU.cpp | 5 +++++ GPU/GLES/GLES_GPU.h | 1 + GPU/GLES/ShaderManager.cpp | 2 +- GPU/GPUCommon.h | 1 + GPU/GPUInterface.h | 1 + 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Core/System.cpp b/Core/System.cpp index 1aa60db0e1..8117e11c1b 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -454,6 +454,8 @@ void PSP_RunLoopUntil(u64 globalticks) { } else { mipsr4k.RunLoopUntil(globalticks); } + + gpu->CleanupBeforeUI(); } void PSP_RunLoopFor(int cycles) { diff --git a/GPU/GLES/GLES_GPU.cpp b/GPU/GLES/GLES_GPU.cpp index 67bc89d96e..885e004bbb 100644 --- a/GPU/GLES/GLES_GPU.cpp +++ b/GPU/GLES/GLES_GPU.cpp @@ -2104,6 +2104,11 @@ void GLES_GPU::ClearShaderCache() { shaderManager_->ClearCache(true); } +void GLES_GPU::CleanupBeforeUI() { + // Clear any enabled vertex arrays. + shaderManager_->DirtyLastShader(); +} + std::vector GLES_GPU::GetFramebufferList() { return framebufferManager_.GetFramebufferList(); } diff --git a/GPU/GLES/GLES_GPU.h b/GPU/GLES/GLES_GPU.h index 4e904215ad..c43ddf658a 100644 --- a/GPU/GLES/GLES_GPU.h +++ b/GPU/GLES/GLES_GPU.h @@ -59,6 +59,7 @@ public: // Called by the window system if the window size changed. This will be reflected in PSPCoreParam.pixel*. virtual void Resized(); virtual void ClearShaderCache(); + virtual void CleanupBeforeUI(); virtual bool DecodeTexture(u8* dest, GPUgstate state) { return textureCache_.DecodeTexture(dest, state); } diff --git a/GPU/GLES/ShaderManager.cpp b/GPU/GLES/ShaderManager.cpp index e103430b5f..a7232cb934 100644 --- a/GPU/GLES/ShaderManager.cpp +++ b/GPU/GLES/ShaderManager.cpp @@ -662,7 +662,7 @@ void ShaderManager::DirtyShader() { // Forget the last shader ID lastFSID_.clear(); lastVSID_.clear(); - lastShader_ = 0; + DirtyLastShader(); globalDirty_ = 0xFFFFFFFF; shaderSwitchDirty_ = 0; } diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 7ec808f531..ca3715b445 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -118,6 +118,7 @@ public: return std::vector(); } virtual void ClearShaderCache() {} + virtual void CleanupBeforeUI() {} protected: // To avoid virtual calls to PreExecuteOp(). diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index b6b418ca4a..cd5969a147 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -269,6 +269,7 @@ public: // Called by the window system if the window size changed. This will be reflected in PSPCoreParam.pixel*. virtual void Resized() = 0; virtual void ClearShaderCache() = 0; + virtual void CleanupBeforeUI() = 0; virtual bool FramebufferDirty() = 0; virtual bool FramebufferReallyDirty() = 0; virtual bool BusyDrawing() = 0;