From 25818d5e6f8852b1163a25a98b22271c856d426d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Fri, 15 Mar 2019 14:10:25 +0100 Subject: [core] expose vertex binding count in gfx::Context --- src/mbgl/gfx/context.hpp | 6 +++++- src/mbgl/gl/context.cpp | 2 +- src/mbgl/gl/context.hpp | 4 +--- src/mbgl/renderer/render_layer.cpp | 13 +++++-------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/mbgl/gfx/context.hpp b/src/mbgl/gfx/context.hpp index 90b62c94a4..3653eeebe1 100644 --- a/src/mbgl/gfx/context.hpp +++ b/src/mbgl/gfx/context.hpp @@ -17,10 +17,14 @@ namespace gfx { class Context { protected: - Context(ContextType type_) : backend(type_) { + Context(ContextType type_, uint32_t maximumVertexBindingCount_) + : backend(type_), maximumVertexBindingCount(maximumVertexBindingCount_) { } +public: const ContextType backend; + static constexpr const uint32_t minimumRequiredVertexBindingCount = 8; + const uint32_t maximumVertexBindingCount; public: Context(Context&&) = delete; diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 5193381251..1f780331c2 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -67,7 +67,7 @@ static_assert(underlying_type(UniformDataType::SamplerCube) == GL_SAMPLER_CUBE, static_assert(std::is_same::value, "OpenGL type mismatch"); Context::Context() - : gfx::Context(gfx::ContextType::OpenGL), maximumVertexBindingCount([] { + : gfx::Context(gfx::ContextType::OpenGL, [] { GLint value; MBGL_CHECK_ERROR(glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value)); return value; diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index fe09390cc6..754b29c03e 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -172,9 +172,7 @@ public: #endif // MBGL_USE_GLES2 bool supportsHalfFloatTextures = false; - const uint32_t maximumVertexBindingCount; - static constexpr const uint32_t minimumRequiredVertexBindingCount = 8; - + private: State stencilFunc; State stencilMask; diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp index 0bec14a0da..803b5b2190 100644 --- a/src/mbgl/renderer/render_layer.cpp +++ b/src/mbgl/renderer/render_layer.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include namespace mbgl { @@ -99,25 +99,22 @@ void RenderLayer::checkRenderability(const PaintParameters& parameters, return; } - // TODO: remove cast - auto& glContext = reinterpret_cast(parameters.context); - - if (activeBindingCount > glContext.maximumVertexBindingCount) { + if (activeBindingCount > parameters.context.maximumVertexBindingCount) { Log::Error(Event::OpenGL, "The layer '%s' uses more data-driven properties than the current device " "supports, and will have rendering errors. To ensure compatibility with this " "device, use %d fewer data driven properties in this layer.", getID().c_str(), - activeBindingCount - glContext.minimumRequiredVertexBindingCount); + activeBindingCount - parameters.context.minimumRequiredVertexBindingCount); hasRenderFailures = true; - } else if (activeBindingCount > glContext.minimumRequiredVertexBindingCount) { + } else if (activeBindingCount > parameters.context.minimumRequiredVertexBindingCount) { Log::Warning(Event::OpenGL, "The layer '%s' uses more data-driven properties than some devices may support. " "Though it will render correctly on this device, it may have rendering errors " "on other devices. To ensure compatibility with all devices, use %d fewer " "data-driven properties in this layer.", getID().c_str(), - activeBindingCount - glContext.minimumRequiredVertexBindingCount); + activeBindingCount - parameters.context.minimumRequiredVertexBindingCount); hasRenderFailures = true; } } -- cgit v1.2.1