diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 101e11f4d..fbe7b39a6 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -61,6 +61,11 @@ void Context::setDirtyState() { void Context::performCleanup() { for (GLuint id : abandonedPrograms) { + for (const auto& p : abandonedPrograms) { + if (program == p) { + program.setDirty(); + } + } MBGL_CHECK_ERROR(glDeleteProgram(id)); } abandonedPrograms.clear(); @@ -71,21 +76,43 @@ void Context::performCleanup() { abandonedShaders.clear(); if (!abandonedBuffers.empty()) { + for (const auto& b : abandonedBuffers) { + if (vertexBuffer == b) { + vertexBuffer.setDirty(); + } else if (elementBuffer == b) { + elementBuffer.setDirty(); + } + } MBGL_CHECK_ERROR(glDeleteBuffers(int(abandonedBuffers.size()), abandonedBuffers.data())); abandonedBuffers.clear(); } if (!abandonedTextures.empty()) { + for (const auto& t : abandonedTextures) { + if (activeTexture == t) { + activeTexture.setDirty(); + } + } MBGL_CHECK_ERROR(glDeleteTextures(int(abandonedTextures.size()), abandonedTextures.data())); abandonedTextures.clear(); } if (!abandonedVAOs.empty()) { + for (const auto& v : abandonedVAOs) { + if (vertexArrayObject == v) { + vertexArrayObject.setDirty(); + } + } MBGL_CHECK_ERROR(gl::DeleteVertexArrays(int(abandonedVAOs.size()), abandonedVAOs.data())); abandonedVAOs.clear(); } if (!abandonedFBOs.empty()) { + for (const auto& f : abandonedFBOs) { + if (bindFramebuffer == f) { + bindFramebuffer.setDirty(); + } + } MBGL_CHECK_ERROR(glDeleteFramebuffers(int(abandonedFBOs.size()), abandonedFBOs.data())); abandonedFBOs.clear(); } diff --git a/src/mbgl/gl/state.hpp b/src/mbgl/gl/state.hpp index c7a7d74c6..dbb005e77 100644 --- a/src/mbgl/gl/state.hpp +++ b/src/mbgl/gl/state.hpp @@ -41,6 +41,10 @@ public: } } + bool operator==(const typename T::Type& value) const { + return !(*this != value); + } + bool operator!=(const typename T::Type& value) const { return dirty || currentValue != value; }