summaryrefslogtreecommitdiff
path: root/include/mbgl
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-02-08 17:53:05 +0100
committerKonstantin Käfer <mail@kkaefer.com>2018-02-08 17:53:05 +0100
commit153d8512b7c0bc5ee80e26c868fb52dd66ee62cc (patch)
tree821349520909225e8a2a138a500b0544970f870c /include/mbgl
parent4498917a3b9dbf6cc9728da01f479a027f27f902 (diff)
downloadqtlocation-mapboxgl-153d8512b7c0bc5ee80e26c868fb52dd66ee62cc.tar.gz
[core] allow disabling the use of extensions via GLContextModeupstream/glcontextmode
Diffstat (limited to 'include/mbgl')
-rw-r--r--include/mbgl/renderer/mode.hpp47
-rw-r--r--include/mbgl/renderer/renderer.hpp2
-rw-r--r--include/mbgl/renderer/renderer_backend.hpp4
3 files changed, 44 insertions, 9 deletions
diff --git a/include/mbgl/renderer/mode.hpp b/include/mbgl/renderer/mode.hpp
index 6ff42d8058..c5883b8b82 100644
--- a/include/mbgl/renderer/mode.hpp
+++ b/include/mbgl/renderer/mode.hpp
@@ -1,18 +1,51 @@
#pragma once
-#include <cstdint>
+#include <mbgl/util/util.hpp>
+#include <mbgl/util/traits.hpp>
namespace mbgl {
using EnumType = uint32_t;
-// We can avoid redundant GL calls when it is known that the GL context is not
-// being shared. In a shared GL context case, we need to make sure that the
-// correct GL configurations are in use - they might have changed between render
-// calls.
enum class GLContextMode : EnumType {
- Unique,
- Shared,
+ Automatic = 0,
+
+ // We can avoid redundant GL calls when it is known that the GL context is not being shared. In
+ // a shared GL context case, we need to make sure that the correct GL configurations are in use
+ // - they might have changed between render calls. If you're issuing other OpenGL calls in the
+ // same context (excluding uses of custom layers), then initialize the context with this flag set.
+ SharedState = 0b00000001,
+
+ // Vertex Array Objects bundle buffer state for faster binding and is available on most modern
+ // platforms. However, some older GPUs have bugs with this, and some devices don't support it
+ // altogether. Setting this flag allows testing without Vertex Array Objects.
+ DisableVAOExtension = 0b00000010,
+
+ // Some platforms support exporting compiled shader programs as binaries. This allows us to
+ // store them and reload the precompiled binary on subsequent loads, which typically speeds
+ // up initialization. However, some GPUs have trouble reloading binaries due driver bugs.
+ // You can explicitly disable program binaries by setting this flag.
+ DisableProgramBinariesExtension = 000000100,
};
+MBGL_CONSTEXPR GLContextMode operator|(GLContextMode lhs, GLContextMode rhs) {
+ return GLContextMode(mbgl::underlying_type(lhs) | mbgl::underlying_type(rhs));
+}
+
+MBGL_CONSTEXPR GLContextMode& operator|=(GLContextMode& lhs, GLContextMode rhs) {
+ return (lhs = GLContextMode(mbgl::underlying_type(lhs) | mbgl::underlying_type(rhs)));
+}
+
+MBGL_CONSTEXPR bool operator&(GLContextMode lhs, GLContextMode rhs) {
+ return mbgl::underlying_type(lhs) & mbgl::underlying_type(rhs);
+}
+
+MBGL_CONSTEXPR GLContextMode& operator&=(GLContextMode& lhs, GLContextMode rhs) {
+ return (lhs = GLContextMode(mbgl::underlying_type(lhs) & mbgl::underlying_type(rhs)));
+}
+
+MBGL_CONSTEXPR GLContextMode operator~(GLContextMode value) {
+ return GLContextMode(~mbgl::underlying_type(value));
+}
+
} // namespace mbgl
diff --git a/include/mbgl/renderer/renderer.hpp b/include/mbgl/renderer/renderer.hpp
index db28ee92fc..ab7f70bace 100644
--- a/include/mbgl/renderer/renderer.hpp
+++ b/include/mbgl/renderer/renderer.hpp
@@ -24,7 +24,7 @@ class UpdateParameters;
class Renderer {
public:
Renderer(RendererBackend&, float pixelRatio_, FileSource&, Scheduler&,
- GLContextMode = GLContextMode::Unique,
+ GLContextMode = GLContextMode::Automatic,
const optional<std::string> programCacheDir = {},
const optional<std::string> localFontFamily = {});
~Renderer();
diff --git a/include/mbgl/renderer/renderer_backend.hpp b/include/mbgl/renderer/renderer_backend.hpp
index b83c128169..4a4c41298a 100644
--- a/include/mbgl/renderer/renderer_backend.hpp
+++ b/include/mbgl/renderer/renderer_backend.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/renderer/backend_scope.hpp>
+#include <mbgl/renderer/mode.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/size.hpp>
#include <mbgl/util/util.hpp>
@@ -20,7 +21,7 @@ using FramebufferID = uint32_t;
// the actual rendering.
class RendererBackend {
public:
- RendererBackend();
+ RendererBackend(GLContextMode);
virtual ~RendererBackend();
// Returns the backend's context which manages OpenGL state.
@@ -81,6 +82,7 @@ protected:
private:
std::once_flag initialized;
+ const GLContextMode mode;
friend class BackendScope;
};