diff --git a/GPU/GLES/DepalettizeShaderGLES.cpp b/GPU/GLES/DepalettizeShaderGLES.cpp index 77614c93df..f2b32c7678 100644 --- a/GPU/GLES/DepalettizeShaderGLES.cpp +++ b/GPU/GLES/DepalettizeShaderGLES.cpp @@ -70,6 +70,10 @@ DepalShaderCacheGLES::~DepalShaderCacheGLES() { Clear(); } +void DepalShaderCacheGLES::DeviceRestore(Draw::DrawContext *draw) { + render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); +} + bool DepalShaderCacheGLES::CreateVertexShader() { std::string src(useGL3_ ? depalVShader300 : depalVShader100); vertexShader_ = render_->CreateShader(GL_VERTEX_SHADER, src, "depal"); diff --git a/GPU/GLES/DepalettizeShaderGLES.h b/GPU/GLES/DepalettizeShaderGLES.h index 6fd9749fec..e183ba22b0 100644 --- a/GPU/GLES/DepalettizeShaderGLES.h +++ b/GPU/GLES/DepalettizeShaderGLES.h @@ -54,6 +54,11 @@ public: std::vector DebugGetShaderIDs(DebugShaderType type); std::string DebugGetShaderString(std::string id, DebugShaderType type, DebugShaderStringType stringType); + void DeviceLost() { + Clear(); + } + void DeviceRestore(Draw::DrawContext *draw); + private: bool CreateVertexShader(); diff --git a/GPU/GLES/FragmentTestCacheGLES.cpp b/GPU/GLES/FragmentTestCacheGLES.cpp index 0ad098a499..ea482896a7 100644 --- a/GPU/GLES/FragmentTestCacheGLES.cpp +++ b/GPU/GLES/FragmentTestCacheGLES.cpp @@ -35,6 +35,10 @@ FragmentTestCacheGLES::~FragmentTestCacheGLES() { Clear(); } +void FragmentTestCacheGLES::DeviceRestore(Draw::DrawContext *draw) { + render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); +} + void FragmentTestCacheGLES::BindTestTexture(int slot) { if (!g_Config.bFragmentTestCache) { return; diff --git a/GPU/GLES/FragmentTestCacheGLES.h b/GPU/GLES/FragmentTestCacheGLES.h index 043b236fe6..da7f1c78b8 100644 --- a/GPU/GLES/FragmentTestCacheGLES.h +++ b/GPU/GLES/FragmentTestCacheGLES.h @@ -67,6 +67,10 @@ public: void BindTestTexture(int slot); + void DeviceLost() { + Clear(false); + } + void DeviceRestore(Draw::DrawContext *draw); void Clear(bool deleteThem = true); void Decimate(); diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index 0b3e14489d..1dd7611211 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -58,7 +58,7 @@ GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw) GLRenderManager *render = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); - shaderManagerGL_ = new ShaderManagerGLES(render); + shaderManagerGL_ = new ShaderManagerGLES(draw); framebufferManagerGL_ = new FramebufferManagerGLES(draw, render); framebufferManager_ = framebufferManagerGL_; textureCacheGL_ = new TextureCacheGLES(draw); @@ -331,11 +331,10 @@ void GPU_GLES::DeviceLost() { // Simply drop all caches and textures. // FBOs appear to survive? Or no? // TransformDraw has registered as a GfxResourceHolder. - drawEngine_.ClearInputLayoutMap(); - shaderManagerGL_->ClearCache(false); + shaderManagerGL_->DeviceLost(); textureCacheGL_->DeviceLost(); - fragmentTestCache_.Clear(false); - depalShaderCache_.Clear(); + fragmentTestCache_.DeviceLost(); + depalShaderCache_.DeviceLost(); drawEngine_.DeviceLost(); framebufferManagerGL_->DeviceLost(); // Don't even try to access the lost device. @@ -349,9 +348,12 @@ void GPU_GLES::DeviceRestore() { UpdateCmdInfo(); UpdateVsyncInterval(true); + shaderManagerGL_->DeviceRestore(draw_); textureCacheGL_->DeviceRestore(draw_); framebufferManagerGL_->DeviceRestore(draw_); drawEngine_.DeviceRestore(draw_); + fragmentTestCache_.DeviceRestore(draw_); + depalShaderCache_.DeviceRestore(draw_); } void GPU_GLES::Reinitialize() { diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 63bf981bcc..e9ed8a58d6 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -574,8 +574,9 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid) { } } -ShaderManagerGLES::ShaderManagerGLES(GLRenderManager *render) - : render_(render), lastShader_(nullptr), shaderSwitchDirtyUniforms_(0), diskCacheDirty_(false), fsCache_(16), vsCache_(16) { +ShaderManagerGLES::ShaderManagerGLES(Draw::DrawContext *draw) + : lastShader_(nullptr), shaderSwitchDirtyUniforms_(0), diskCacheDirty_(false), fsCache_(16), vsCache_(16) { + render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); codeBuffer_ = new char[16384]; lastFSID_.set_invalid(); lastVSID_.set_invalid(); @@ -607,6 +608,14 @@ void ShaderManagerGLES::ClearCache(bool deleteThem) { Clear(); } +void ShaderManagerGLES::DeviceLost() { + Clear(); +} + +void ShaderManagerGLES::DeviceRestore(Draw::DrawContext *draw) { + render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); +} + void ShaderManagerGLES::DirtyShader() { // Forget the last shader ID lastFSID_.set_invalid(); diff --git a/GPU/GLES/ShaderManagerGLES.h b/GPU/GLES/ShaderManagerGLES.h index c9ca56f15a..33d187301b 100644 --- a/GPU/GLES/ShaderManagerGLES.h +++ b/GPU/GLES/ShaderManagerGLES.h @@ -152,7 +152,7 @@ private: class ShaderManagerGLES : public ShaderManagerCommon { public: - ShaderManagerGLES(GLRenderManager *render); + ShaderManagerGLES(Draw::DrawContext *draw); ~ShaderManagerGLES(); void ClearCache(bool deleteThem); // TODO: deleteThem currently not respected @@ -162,6 +162,9 @@ public: Shader *ApplyVertexShader(int prim, u32 vertType, VShaderID *VSID); LinkedShader *ApplyFragmentShader(VShaderID VSID, Shader *vs, u32 vertType, int prim); + void DeviceLost(); + void DeviceRestore(Draw::DrawContext *draw); + void DirtyShader(); void DirtyLastShader() override; // disables vertex arrays