From 61fa43619334ac68c66d45d38aaf681f2a21fa96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 18 Mar 2015 15:37:06 +0100 Subject: [PATCH] coalesce buffer deletions and run them in bulk during rendering On iOS, the main thread does framebuffer operations just before it requests a rerender of the view contents. This means that GL operations on the Map thread will interfere with that and cause a crash. While most GL operations happen throughout rendering (which is synchronized with the main thread), deletion of shared_ptrs release in turn their OpenGL objects. This may happen at any time and isn't synced with rendering. This patch changes this so instead of deleting all objects immediately, we are collecting all abandoned IDs and delete them in bulk once the main thread has given us permission to use OpenGL calls (i.e. during render()). --- include/mbgl/map/map.hpp | 10 +++--- src/mbgl/geometry/buffer.hpp | 3 +- src/mbgl/geometry/line_atlas.cpp | 6 ++-- src/mbgl/geometry/sprite_atlas.cpp | 4 +-- src/mbgl/geometry/vao.cpp | 3 +- src/mbgl/map/environment.cpp | 55 ++++++++++++++++++++++++++++-- src/mbgl/map/environment.hpp | 42 ++++++++++++++++++----- src/mbgl/map/map.cpp | 23 +++++++++++-- src/mbgl/map/tile_data.cpp | 2 +- src/mbgl/util/texture_pool.cpp | 15 +++----- 10 files changed, 127 insertions(+), 36 deletions(-) diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 86c89f769..06ae39d87 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -37,6 +37,7 @@ class GlyphAtlas; class SpriteAtlas; class LineAtlas; class Environment; +class EnvironmentScope; class AnnotationManager; class Map : private util::noncopyable { @@ -192,6 +193,7 @@ private: Mode mode = Mode::None; const std::unique_ptr env; + std::unique_ptr scope; View &view; private: @@ -223,13 +225,13 @@ private: FileSource& fileSource; util::ptr