From 7f9274035bad30980e03574c315904ab7a85fe83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 2 Apr 2019 14:11:37 +0200 Subject: [core] refactor program object creation --- bin/render.cpp | 2 + cmake/test.cmake | 1 + cmake/vendor.cmake | 2 +- include/mbgl/gfx/backend.hpp | 44 ++++++++++++++++++++++ include/mbgl/gfx/renderer_backend.hpp | 5 +++ include/mbgl/gl/renderer_backend.hpp | 3 -- platform/android/src/android_renderer_backend.cpp | 2 +- .../default/include/mbgl/gfx/headless_backend.hpp | 9 ++++- .../default/src/mbgl/gfx/headless_frontend.cpp | 6 +-- platform/default/src/mbgl/gl/headless_backend.cpp | 12 +++--- platform/glfw/glfw_backend.hpp | 7 ++++ platform/glfw/glfw_gl_backend.cpp | 12 ++++++ platform/glfw/glfw_view.cpp | 9 ++++- platform/glfw/glfw_view.hpp | 2 +- platform/glfw/main.cpp | 2 + platform/node/src/node_mapbox_gl_native.cpp | 13 +++++++ scripts/generate-shaders.js | 4 +- src/core-files.json | 2 +- src/mbgl/gfx/context.hpp | 14 +++---- src/mbgl/gfx/context_impl.hpp | 23 ----------- src/mbgl/gfx/types.hpp | 4 -- src/mbgl/gl/context.cpp | 2 +- src/mbgl/gl/renderer_backend.cpp | 32 +++++++--------- src/mbgl/programs/background_program.cpp | 4 -- src/mbgl/programs/circle_program.cpp | 3 -- src/mbgl/programs/clipping_mask_program.cpp | 3 -- src/mbgl/programs/collision_box_program.cpp | 4 -- src/mbgl/programs/debug_program.cpp | 3 -- src/mbgl/programs/fill_extrusion_program.cpp | 4 -- src/mbgl/programs/fill_program.cpp | 6 --- src/mbgl/programs/gl/background.cpp | 4 +- src/mbgl/programs/gl/background_pattern.cpp | 4 +- src/mbgl/programs/gl/circle.cpp | 4 +- src/mbgl/programs/gl/clipping_mask.cpp | 4 +- src/mbgl/programs/gl/collision_box.cpp | 4 +- src/mbgl/programs/gl/collision_circle.cpp | 4 +- src/mbgl/programs/gl/debug.cpp | 4 +- src/mbgl/programs/gl/fill.cpp | 4 +- src/mbgl/programs/gl/fill_extrusion.cpp | 4 +- src/mbgl/programs/gl/fill_extrusion_pattern.cpp | 4 +- src/mbgl/programs/gl/fill_outline.cpp | 4 +- src/mbgl/programs/gl/fill_outline_pattern.cpp | 4 +- src/mbgl/programs/gl/fill_pattern.cpp | 4 +- src/mbgl/programs/gl/heatmap.cpp | 4 +- src/mbgl/programs/gl/heatmap_texture.cpp | 4 +- src/mbgl/programs/gl/hillshade.cpp | 4 +- src/mbgl/programs/gl/hillshade_prepare.cpp | 4 +- src/mbgl/programs/gl/line.cpp | 4 +- src/mbgl/programs/gl/line_gradient.cpp | 4 +- src/mbgl/programs/gl/line_pattern.cpp | 4 +- src/mbgl/programs/gl/line_sdf.cpp | 4 +- src/mbgl/programs/gl/raster.cpp | 4 +- src/mbgl/programs/gl/symbol_icon.cpp | 4 +- src/mbgl/programs/gl/symbol_sdf_icon.cpp | 4 +- src/mbgl/programs/gl/symbol_sdf_text.cpp | 4 +- src/mbgl/programs/heatmap_program.cpp | 3 -- src/mbgl/programs/heatmap_texture_program.cpp | 3 -- src/mbgl/programs/hillshade_prepare_program.cpp | 3 -- src/mbgl/programs/hillshade_program.cpp | 3 -- src/mbgl/programs/line_program.cpp | 6 --- src/mbgl/programs/raster_program.cpp | 3 -- src/mbgl/programs/symbol_program.cpp | 5 --- test/api/custom_layer.test.cpp | 4 ++ test/gl/context.test.cpp | 4 ++ test/map/map.test.cpp | 4 ++ test/src/mbgl/test/test.cpp | 9 +++++ test/util/offscreen_texture.test.cpp | 8 ++++ 67 files changed, 216 insertions(+), 178 deletions(-) create mode 100644 include/mbgl/gfx/backend.hpp delete mode 100644 src/mbgl/gfx/context_impl.hpp diff --git a/bin/render.cpp b/bin/render.cpp index a29ecdf08a..85231c8cba 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -17,6 +18,7 @@ int main(int argc, char *argv[]) { args::ArgumentParser argumentParser("Mapbox GL render tool"); args::HelpFlag helpFlag(argumentParser, "help", "Display this help menu", {"help"}); + args::ValueFlag backendValue(argumentParser, "Backend", "Rendering backend", {"backend"}); args::ValueFlag tokenValue(argumentParser, "key", "Mapbox access token", {'t', "token"}); args::ValueFlag styleValue(argumentParser, "URL", "Map stylesheet", {'s', "style"}); args::ValueFlag outputValue(argumentParser, "file", "Output file name", {'o', "output"}); diff --git a/cmake/test.cmake b/cmake/test.cmake index 0614270089..16dc10f93d 100644 --- a/cmake/test.cmake +++ b/cmake/test.cmake @@ -26,6 +26,7 @@ target_include_directories(mbgl-test target_link_libraries(mbgl-test PRIVATE gtest + args mbgl-core shelf-pack-cpp unique_resource diff --git a/cmake/vendor.cmake b/cmake/vendor.cmake index 7aac53e4cb..0b2deeb552 100644 --- a/cmake/vendor.cmake +++ b/cmake/vendor.cmake @@ -27,8 +27,8 @@ include(${CMAKE_SOURCE_DIR}/vendor/unique_resource.cmake) include(${CMAKE_SOURCE_DIR}/vendor/variant.cmake) include(${CMAKE_SOURCE_DIR}/vendor/vector-tile.cmake) include(${CMAKE_SOURCE_DIR}/vendor/wagyu.cmake) +include(${CMAKE_SOURCE_DIR}/vendor/args.cmake) if(MBGL_PLATFORM STREQUAL "linux" OR MBGL_PLATFORM STREQUAL "macos") - include(${CMAKE_SOURCE_DIR}/vendor/args.cmake) include(${CMAKE_SOURCE_DIR}/vendor/glfw.cmake) endif() diff --git a/include/mbgl/gfx/backend.hpp b/include/mbgl/gfx/backend.hpp new file mode 100644 index 0000000000..eed63dfcba --- /dev/null +++ b/include/mbgl/gfx/backend.hpp @@ -0,0 +1,44 @@ +#pragma once + +#include +#include +#include + +namespace mbgl { +namespace gfx { + +class Backend { +public: + enum class Type : uint8_t { + OpenGL, + }; + + static constexpr Type DefaultType = Type::OpenGL; + + static void SetType(const Type value) { + if (Value(value) != value) { + abort(); // SetType must be called prior to any GetType calls. + } + } + + static Type GetType() { + return Value(DefaultType); + } + + template + static std::unique_ptr Create(Args... args) { + return Create(std::forward(args)...); + } + +private: + template + static std::unique_ptr Create(Args...); + + static Type Value(Type value) { + static const Type type = value; + return type; + } +}; + +} // namespace gfx +} // namespace mbgl diff --git a/include/mbgl/gfx/renderer_backend.hpp b/include/mbgl/gfx/renderer_backend.hpp index 29f6b43a8f..aa76d7e502 100644 --- a/include/mbgl/gfx/renderer_backend.hpp +++ b/include/mbgl/gfx/renderer_backend.hpp @@ -30,6 +30,11 @@ public: // Returns the device's context. Context& getContext(); + template + T& getContext() { + return static_cast(getContext()); + } + bool contextIsShared() const { return contextMode == ContextMode::Shared; } diff --git a/include/mbgl/gl/renderer_backend.hpp b/include/mbgl/gl/renderer_backend.hpp index ba87e4ce4f..cfa28ddaeb 100644 --- a/include/mbgl/gl/renderer_backend.hpp +++ b/include/mbgl/gl/renderer_backend.hpp @@ -17,9 +17,6 @@ public: RendererBackend(gfx::ContextMode); ~RendererBackend() override; - // Returns the backend's context which manages OpenGL state. - Context& getGLContext(); - // Called prior to rendering to update the internally assumed OpenGL state. virtual void updateAssumedState() = 0; diff --git a/platform/android/src/android_renderer_backend.cpp b/platform/android/src/android_renderer_backend.cpp index 3fba0b83da..e2d0648385 100755 --- a/platform/android/src/android_renderer_backend.cpp +++ b/platform/android/src/android_renderer_backend.cpp @@ -59,7 +59,7 @@ void AndroidRendererBackend::updateAssumedState() { void AndroidRendererBackend::markContextLost() { if (context) { - getGLContext().setCleanupOnDestruction(false); + getContext().setCleanupOnDestruction(false); } } diff --git a/platform/default/include/mbgl/gfx/headless_backend.hpp b/platform/default/include/mbgl/gfx/headless_backend.hpp index de9283dcdf..325422323a 100644 --- a/platform/default/include/mbgl/gfx/headless_backend.hpp +++ b/platform/default/include/mbgl/gfx/headless_backend.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -15,8 +16,12 @@ namespace gfx { class HeadlessBackend : public gfx::Renderable { public: // Factory. - static std::unique_ptr make(Size = { 256, 256 }, gfx::ContextMode = gfx::ContextMode::Unique); - + static std::unique_ptr + Create(const Size size = { 256, 256 }, + const gfx::ContextMode contextMode = gfx::ContextMode::Unique) { + return Backend::Create(size, contextMode); + } + virtual PremultipliedImage readStillImage() = 0; virtual RendererBackend* getRendererBackend() = 0; void setSize(Size); diff --git a/platform/default/src/mbgl/gfx/headless_frontend.cpp b/platform/default/src/mbgl/gfx/headless_frontend.cpp index 025abdd87a..0e97c40e49 100644 --- a/platform/default/src/mbgl/gfx/headless_frontend.cpp +++ b/platform/default/src/mbgl/gfx/headless_frontend.cpp @@ -23,9 +23,9 @@ HeadlessFrontend::HeadlessFrontend(Size size_, const gfx::ContextMode contextMode, const optional localFontFamily) : size(size_), - pixelRatio(pixelRatio_), - backend(gfx::HeadlessBackend::make( { static_cast(size.width * pixelRatio), - static_cast(size.height * pixelRatio) }, contextMode)), + pixelRatio(pixelRatio_), + backend(gfx::HeadlessBackend::Create({ static_cast(size.width * pixelRatio), + static_cast(size.height * pixelRatio) }, contextMode)), asyncInvalidate([this] { if (renderer && updateParameters) { gfx::BackendScope guard { *getBackend() }; diff --git a/platform/default/src/mbgl/gl/headless_backend.cpp b/platform/default/src/mbgl/gl/headless_backend.cpp index c81952fadc..732e4babae 100644 --- a/platform/default/src/mbgl/gl/headless_backend.cpp +++ b/platform/default/src/mbgl/gl/headless_backend.cpp @@ -79,20 +79,22 @@ void HeadlessBackend::updateAssumedState() { PremultipliedImage HeadlessBackend::readStillImage() { return static_cast(getContext()).readFramebuffer(size); } - + RendererBackend* HeadlessBackend::getRendererBackend() { return this; } } // namespace gl -#ifndef OVERRIDE_HEADLESS_BACKEND_FACTORY -// Default factory implementation. -std::unique_ptr gfx::HeadlessBackend::make(Size size, gfx::ContextMode contextMode) { +namespace gfx { + +template <> +std::unique_ptr +Backend::Create(const Size size, const gfx::ContextMode contextMode) { return std::make_unique(size, contextMode); } -#endif +} // namespace gfx } // namespace mbgl diff --git a/platform/glfw/glfw_backend.hpp b/platform/glfw/glfw_backend.hpp index 1a2c89ac7a..867e60d79e 100644 --- a/platform/glfw/glfw_backend.hpp +++ b/platform/glfw/glfw_backend.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include namespace mbgl { namespace gfx { @@ -8,6 +9,8 @@ class RendererBackend; } // namespace gfx } // namespace mbgl +struct GLFWwindow; + class GLFWBackend { public: explicit GLFWBackend() = default; @@ -15,6 +18,10 @@ public: GLFWBackend& operator=(const GLFWBackend&) = delete; virtual ~GLFWBackend() = default; + static std::unique_ptr Create(GLFWwindow* window, bool capFrameRate) { + return mbgl::gfx::Backend::Create(window, capFrameRate); + } + virtual mbgl::gfx::RendererBackend& getRendererBackend() = 0; virtual mbgl::Size getSize() const = 0; virtual void setSize(mbgl::Size) = 0; diff --git a/platform/glfw/glfw_gl_backend.cpp b/platform/glfw/glfw_gl_backend.cpp index 4d9d87dd72..d0975fc08f 100644 --- a/platform/glfw/glfw_gl_backend.cpp +++ b/platform/glfw/glfw_gl_backend.cpp @@ -72,3 +72,15 @@ void GLFWGLBackend::setSize(const mbgl::Size newSize) { void GLFWGLBackend::swap() { glfwSwapBuffers(window); } + +namespace mbgl { +namespace gfx { + +template <> +std::unique_ptr +Backend::Create(GLFWwindow* window, bool capFrameRate) { + return std::make_unique(window, capFrameRate); +} + +} // namespace gfx +} // namespace mbgl diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 91e2345bb6..82519e6ac2 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -1,5 +1,5 @@ #include "glfw_view.hpp" -#include "glfw_gl_backend.hpp" +#include "glfw_backend.hpp" #include "glfw_renderer_frontend.hpp" #include "ny_route.hpp" @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -76,6 +77,10 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); #endif + if (mbgl::gfx::Backend::GetType() != mbgl::gfx::Backend::Type::OpenGL) { + glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); + } + glfwWindowHint(GLFW_RED_BITS, 8); glfwWindowHint(GLFW_GREEN_BITS, 8); glfwWindowHint(GLFW_BLUE_BITS, 8); @@ -100,7 +105,7 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_) glfwGetWindowSize(window, &width, &height); - backend = std::make_unique(window, benchmark); + backend = GLFWBackend::Create(window, benchmark); pixelRatio = static_cast(backend->getSize().width) / width; diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp index 1f27bb4421..3322932dde 100644 --- a/platform/glfw/glfw_view.hpp +++ b/platform/glfw/glfw_view.hpp @@ -17,7 +17,7 @@ class RendererBackend; class GLFWView : public mbgl::MapObserver { public: - GLFWView(bool fullscreen = false, bool benchmark = false); + GLFWView(bool fullscreen, bool benchmark); ~GLFWView() override; float getPixelRatio() const; diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp index 04cff3962a..a5001d1204 100644 --- a/platform/glfw/main.cpp +++ b/platform/glfw/main.cpp @@ -2,6 +2,7 @@ #include "glfw_renderer_frontend.hpp" #include "settings_json.hpp" +#include #include #include #include @@ -42,6 +43,7 @@ int main(int argc, char *argv[]) { args::Flag benchmarkFlag(argumentParser, "benchmark", "Toggle benchmark", {'b', "benchmark"}); args::Flag offlineFlag(argumentParser, "offline", "Toggle offline", {'o', "offline"}); + args::ValueFlag backendValue(argumentParser, "Backend", "Rendering backend", {"backend"}); args::ValueFlag styleValue(argumentParser, "URL", "Map stylesheet", {'s', "style"}); args::ValueFlag cacheDBValue(argumentParser, "file", "Cache database file name", {'c', "cache"}); args::ValueFlag lonValue(argumentParser, "degrees", "Longitude", {'x', "lon"}); diff --git a/platform/node/src/node_mapbox_gl_native.cpp b/platform/node/src/node_mapbox_gl_native.cpp index 96e96e4298..9b4437b0aa 100644 --- a/platform/node/src/node_mapbox_gl_native.cpp +++ b/platform/node/src/node_mapbox_gl_native.cpp @@ -6,12 +6,23 @@ #pragma GCC diagnostic pop #include +#include #include "node_map.hpp" #include "node_logging.hpp" #include "node_request.hpp" #include "node_expression.hpp" + +void SetBackendType(const Nan::FunctionCallbackInfo& info) { + if (info.Length() < 1 || info[0]->IsUndefined()) { + return Nan::ThrowTypeError("Requires a render backend name"); + } + + const std::string backendName { *Nan::Utf8String(info[0]) }; + (void)backendName; +} + void RegisterModule(v8::Local target, v8::Local module) { // This has the effect of: // a) Ensuring that the static local variable is initialized before any thread contention. @@ -19,6 +30,8 @@ void RegisterModule(v8::Local target, v8::Local module) static mbgl::util::RunLoop nodeRunLoop; nodeRunLoop.stop(); + Nan::SetMethod(target, "setBackendType", SetBackendType); + node_mbgl::NodeMap::Init(target); node_mbgl::NodeRequest::Init(); node_mbgl::NodeExpression::Init(target); diff --git a/scripts/generate-shaders.js b/scripts/generate-shaders.js index 3fe6cafaf6..cb0c945f3c 100755 --- a/scripts/generate-shaders.js +++ b/scripts/generate-shaders.js @@ -178,8 +178,8 @@ constexpr const uint8_t ShaderSource<${ShaderName}Program>::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/core-files.json b/src/core-files.json index 05870661db..eb581f7959 100644 --- a/src/core-files.json +++ b/src/core-files.json @@ -321,6 +321,7 @@ "mbgl/actor/message.hpp": "include/mbgl/actor/message.hpp", "mbgl/actor/scheduler.hpp": "include/mbgl/actor/scheduler.hpp", "mbgl/annotation/annotation.hpp": "include/mbgl/annotation/annotation.hpp", + "mbgl/gfx/backend.hpp": "include/mbgl/gfx/backend.hpp", "mbgl/gfx/backend_scope.hpp": "include/mbgl/gfx/backend_scope.hpp", "mbgl/gfx/renderable.hpp": "include/mbgl/gfx/renderable.hpp", "mbgl/gfx/renderer_backend.hpp": "include/mbgl/gfx/renderer_backend.hpp", @@ -513,7 +514,6 @@ "mbgl/gfx/color_mode.hpp": "src/mbgl/gfx/color_mode.hpp", "mbgl/gfx/command_encoder.hpp": "src/mbgl/gfx/command_encoder.hpp", "mbgl/gfx/context.hpp": "src/mbgl/gfx/context.hpp", - "mbgl/gfx/context_impl.hpp": "src/mbgl/gfx/context_impl.hpp", "mbgl/gfx/cull_face_mode.hpp": "src/mbgl/gfx/cull_face_mode.hpp", "mbgl/gfx/debug_group.hpp": "src/mbgl/gfx/debug_group.hpp", "mbgl/gfx/depth_mode.hpp": "src/mbgl/gfx/depth_mode.hpp", diff --git a/src/mbgl/gfx/context.hpp b/src/mbgl/gfx/context.hpp index 118df30a26..53cd318642 100644 --- a/src/mbgl/gfx/context.hpp +++ b/src/mbgl/gfx/context.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -17,12 +18,11 @@ class OffscreenTexture; class Context { protected: - Context(ContextType type_, uint32_t maximumVertexBindingCount_) - : backend(type_), maximumVertexBindingCount(maximumVertexBindingCount_) { + Context(uint32_t maximumVertexBindingCount_) + : maximumVertexBindingCount(maximumVertexBindingCount_) { } public: - const ContextType backend; static constexpr const uint32_t minimumRequiredVertexBindingCount = 8; const uint32_t maximumVertexBindingCount; bool supportsHalfFloatTextures = false; @@ -80,11 +80,9 @@ protected: public: template - std::unique_ptr> createProgram(const ProgramParameters&); - -private: - template - std::unique_ptr> createProgram(const ProgramParameters&); + std::unique_ptr> createProgram(const ProgramParameters& programParameters) { + return Backend::Create, const ProgramParameters&>(programParameters); + } public: virtual std::unique_ptr createCommandEncoder() = 0; diff --git a/src/mbgl/gfx/context_impl.hpp b/src/mbgl/gfx/context_impl.hpp deleted file mode 100644 index 0145535bb3..0000000000 --- a/src/mbgl/gfx/context_impl.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include - -namespace mbgl { - -namespace gl { -class Context; -} // namespace gl - -namespace gfx { - -template -std::unique_ptr> Context::createProgram(const ProgramParameters& programParameters) { - if (backend == ContextType::OpenGL) { - return createProgram(programParameters); - } - assert(false); - return nullptr; -} - -} // namespace gfx -} // namespace mbgl diff --git a/src/mbgl/gfx/types.hpp b/src/mbgl/gfx/types.hpp index 24209c5cc5..cafb2f3f84 100644 --- a/src/mbgl/gfx/types.hpp +++ b/src/mbgl/gfx/types.hpp @@ -5,10 +5,6 @@ namespace mbgl { namespace gfx { -enum class ContextType : uint8_t { - OpenGL, -}; - enum class PrimitiveType : uint8_t { Point, Line, diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 436e1f6a61..626e1f4b66 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -50,7 +50,7 @@ static_assert(underlying_type(UniformDataType::Sampler2D) == GL_SAMPLER_2D, "Ope static_assert(underlying_type(UniformDataType::SamplerCube) == GL_SAMPLER_CUBE, "OpenGL type mismatch"); Context::Context(RendererBackend& backend_) - : gfx::Context(gfx::ContextType::OpenGL, [] { + : gfx::Context([] { GLint value; MBGL_CHECK_ERROR(glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value)); return value; diff --git a/src/mbgl/gl/renderer_backend.cpp b/src/mbgl/gl/renderer_backend.cpp index 9da6ceb589..fe0ca4b5b2 100644 --- a/src/mbgl/gl/renderer_backend.cpp +++ b/src/mbgl/gl/renderer_backend.cpp @@ -21,50 +21,46 @@ std::unique_ptr RendererBackend::createContext() { return std::move(result); } -gl::Context& RendererBackend::getGLContext() { - return static_cast(getContext()); -} - PremultipliedImage RendererBackend::readFramebuffer(const Size& size) { - return getGLContext().readFramebuffer(size); + return getContext().readFramebuffer(size); } void RendererBackend::assumeFramebufferBinding(const gl::FramebufferID fbo) { - getGLContext().bindFramebuffer.setCurrentValue(fbo); + getContext().bindFramebuffer.setCurrentValue(fbo); if (fbo != ImplicitFramebufferBinding) { - assert(gl::value::BindFramebuffer::Get() == getGLContext().bindFramebuffer.getCurrentValue()); + assert(gl::value::BindFramebuffer::Get() == getContext().bindFramebuffer.getCurrentValue()); } } void RendererBackend::assumeViewport(int32_t x, int32_t y, const Size& size) { - getGLContext().viewport.setCurrentValue({ x, y, size }); - assert(gl::value::Viewport::Get() == getGLContext().viewport.getCurrentValue()); + getContext().viewport.setCurrentValue({ x, y, size }); + assert(gl::value::Viewport::Get() == getContext().viewport.getCurrentValue()); } void RendererBackend::assumeScissorTest(bool enabled) { - getGLContext().scissorTest.setCurrentValue(enabled); - assert(gl::value::ScissorTest::Get() == getGLContext().scissorTest.getCurrentValue()); + getContext().scissorTest.setCurrentValue(enabled); + assert(gl::value::ScissorTest::Get() == getContext().scissorTest.getCurrentValue()); } bool RendererBackend::implicitFramebufferBound() { - return getGLContext().bindFramebuffer.getCurrentValue() == ImplicitFramebufferBinding; + return getContext().bindFramebuffer.getCurrentValue() == ImplicitFramebufferBinding; } void RendererBackend::setFramebufferBinding(const gl::FramebufferID fbo) { - getGLContext().bindFramebuffer = fbo; + getContext().bindFramebuffer = fbo; if (fbo != ImplicitFramebufferBinding) { - assert(gl::value::BindFramebuffer::Get() == getGLContext().bindFramebuffer.getCurrentValue()); + assert(gl::value::BindFramebuffer::Get() == getContext().bindFramebuffer.getCurrentValue()); } } void RendererBackend::setViewport(int32_t x, int32_t y, const Size& size) { - getGLContext().viewport = { x, y, size }; - assert(gl::value::Viewport::Get() == getGLContext().viewport.getCurrentValue()); + getContext().viewport = { x, y, size }; + assert(gl::value::Viewport::Get() == getContext().viewport.getCurrentValue()); } void RendererBackend::setScissorTest(bool enabled) { - getGLContext().scissorTest = enabled; - assert(gl::value::ScissorTest::Get() == getGLContext().scissorTest.getCurrentValue()); + getContext().scissorTest = enabled; + assert(gl::value::ScissorTest::Get() == getContext().scissorTest.getCurrentValue()); } RendererBackend::~RendererBackend() = default; diff --git a/src/mbgl/programs/background_program.cpp b/src/mbgl/programs/background_program.cpp index 772d481578..edabce8ee3 100644 --- a/src/mbgl/programs/background_program.cpp +++ b/src/mbgl/programs/background_program.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -7,9 +6,6 @@ namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - using namespace style; static_assert(sizeof(BackgroundLayoutVertex) == 4, "expected BackgroundLayoutVertex size"); diff --git a/src/mbgl/programs/circle_program.cpp b/src/mbgl/programs/circle_program.cpp index 577410d94e..99b47dd5c0 100644 --- a/src/mbgl/programs/circle_program.cpp +++ b/src/mbgl/programs/circle_program.cpp @@ -1,10 +1,7 @@ #include -#include namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - static_assert(sizeof(CircleLayoutVertex) == 4, "expected CircleLayoutVertex size"); } // namespace mbgl diff --git a/src/mbgl/programs/clipping_mask_program.cpp b/src/mbgl/programs/clipping_mask_program.cpp index 9b1a9ef4fc..aca7605037 100644 --- a/src/mbgl/programs/clipping_mask_program.cpp +++ b/src/mbgl/programs/clipping_mask_program.cpp @@ -1,8 +1,5 @@ #include -#include namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - } // namespace mbgl diff --git a/src/mbgl/programs/collision_box_program.cpp b/src/mbgl/programs/collision_box_program.cpp index 885894526e..584013640e 100644 --- a/src/mbgl/programs/collision_box_program.cpp +++ b/src/mbgl/programs/collision_box_program.cpp @@ -1,11 +1,7 @@ #include -#include namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - static_assert(sizeof(CollisionBoxProgram::LayoutVertex) == 24, "expected CollisionBoxVertex size"); } // namespace mbgl diff --git a/src/mbgl/programs/debug_program.cpp b/src/mbgl/programs/debug_program.cpp index 9b8df789e4..3396e74872 100644 --- a/src/mbgl/programs/debug_program.cpp +++ b/src/mbgl/programs/debug_program.cpp @@ -1,8 +1,5 @@ #include -#include namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - } // namespace mbgl diff --git a/src/mbgl/programs/fill_extrusion_program.cpp b/src/mbgl/programs/fill_extrusion_program.cpp index 09da6931b6..d22e911589 100644 --- a/src/mbgl/programs/fill_extrusion_program.cpp +++ b/src/mbgl/programs/fill_extrusion_program.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -8,9 +7,6 @@ namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - using namespace style; static_assert(sizeof(FillExtrusionLayoutVertex) == 12, "expected FillExtrusionLayoutVertex size"); diff --git a/src/mbgl/programs/fill_program.cpp b/src/mbgl/programs/fill_program.cpp index 703d61399f..f314fcc597 100644 --- a/src/mbgl/programs/fill_program.cpp +++ b/src/mbgl/programs/fill_program.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -7,11 +6,6 @@ namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - using namespace style; static_assert(sizeof(FillLayoutVertex) == 4, "expected FillLayoutVertex size"); diff --git a/src/mbgl/programs/gl/background.cpp b/src/mbgl/programs/gl/background.cpp index 78074d670f..f3d2cdfd90 100644 --- a/src/mbgl/programs/gl/background.cpp +++ b/src/mbgl/programs/gl/background.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/background_pattern.cpp b/src/mbgl/programs/gl/background_pattern.cpp index 04111c7abd..482814cbda 100644 --- a/src/mbgl/programs/gl/background_pattern.cpp +++ b/src/mbgl/programs/gl/background_pattern.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/circle.cpp b/src/mbgl/programs/gl/circle.cpp index 5cf7eef13c..bd86c0385a 100644 --- a/src/mbgl/programs/gl/circle.cpp +++ b/src/mbgl/programs/gl/circle.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/clipping_mask.cpp b/src/mbgl/programs/gl/clipping_mask.cpp index 1b6c7b51c5..2c53bc6070 100644 --- a/src/mbgl/programs/gl/clipping_mask.cpp +++ b/src/mbgl/programs/gl/clipping_mask.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/collision_box.cpp b/src/mbgl/programs/gl/collision_box.cpp index 89c4fe81ae..a3ad030f5c 100644 --- a/src/mbgl/programs/gl/collision_box.cpp +++ b/src/mbgl/programs/gl/collision_box.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/collision_circle.cpp b/src/mbgl/programs/gl/collision_circle.cpp index 96f5d68ce5..3878122f4b 100644 --- a/src/mbgl/programs/gl/collision_circle.cpp +++ b/src/mbgl/programs/gl/collision_circle.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/debug.cpp b/src/mbgl/programs/gl/debug.cpp index 2e5db36dac..9705fc4801 100644 --- a/src/mbgl/programs/gl/debug.cpp +++ b/src/mbgl/programs/gl/debug.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/fill.cpp b/src/mbgl/programs/gl/fill.cpp index 7a281c24ba..77c839850b 100644 --- a/src/mbgl/programs/gl/fill.cpp +++ b/src/mbgl/programs/gl/fill.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/fill_extrusion.cpp b/src/mbgl/programs/gl/fill_extrusion.cpp index d90988070a..87ef4858fc 100644 --- a/src/mbgl/programs/gl/fill_extrusion.cpp +++ b/src/mbgl/programs/gl/fill_extrusion.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/fill_extrusion_pattern.cpp b/src/mbgl/programs/gl/fill_extrusion_pattern.cpp index a6292b9fe1..1d330220e4 100644 --- a/src/mbgl/programs/gl/fill_extrusion_pattern.cpp +++ b/src/mbgl/programs/gl/fill_extrusion_pattern.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/fill_outline.cpp b/src/mbgl/programs/gl/fill_outline.cpp index 82d56710a7..efef689f91 100644 --- a/src/mbgl/programs/gl/fill_outline.cpp +++ b/src/mbgl/programs/gl/fill_outline.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/fill_outline_pattern.cpp b/src/mbgl/programs/gl/fill_outline_pattern.cpp index 7709991353..d526d5801d 100644 --- a/src/mbgl/programs/gl/fill_outline_pattern.cpp +++ b/src/mbgl/programs/gl/fill_outline_pattern.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/fill_pattern.cpp b/src/mbgl/programs/gl/fill_pattern.cpp index ff4f2045ac..0f62206f99 100644 --- a/src/mbgl/programs/gl/fill_pattern.cpp +++ b/src/mbgl/programs/gl/fill_pattern.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/heatmap.cpp b/src/mbgl/programs/gl/heatmap.cpp index 7685b568cb..41f804a37b 100644 --- a/src/mbgl/programs/gl/heatmap.cpp +++ b/src/mbgl/programs/gl/heatmap.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/heatmap_texture.cpp b/src/mbgl/programs/gl/heatmap_texture.cpp index 60ef68597d..a6583bfbb7 100644 --- a/src/mbgl/programs/gl/heatmap_texture.cpp +++ b/src/mbgl/programs/gl/heatmap_texture.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/hillshade.cpp b/src/mbgl/programs/gl/hillshade.cpp index f0579aaf8c..b0c2c95aa8 100644 --- a/src/mbgl/programs/gl/hillshade.cpp +++ b/src/mbgl/programs/gl/hillshade.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/hillshade_prepare.cpp b/src/mbgl/programs/gl/hillshade_prepare.cpp index f9cd84ca73..1aef64293b 100644 --- a/src/mbgl/programs/gl/hillshade_prepare.cpp +++ b/src/mbgl/programs/gl/hillshade_prepare.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/line.cpp b/src/mbgl/programs/gl/line.cpp index 9eea81f69b..58f626bf19 100644 --- a/src/mbgl/programs/gl/line.cpp +++ b/src/mbgl/programs/gl/line.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/line_gradient.cpp b/src/mbgl/programs/gl/line_gradient.cpp index 4e7ee93b92..c555b09932 100644 --- a/src/mbgl/programs/gl/line_gradient.cpp +++ b/src/mbgl/programs/gl/line_gradient.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/line_pattern.cpp b/src/mbgl/programs/gl/line_pattern.cpp index 24406abf3b..17ec324c11 100644 --- a/src/mbgl/programs/gl/line_pattern.cpp +++ b/src/mbgl/programs/gl/line_pattern.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/line_sdf.cpp b/src/mbgl/programs/gl/line_sdf.cpp index aa72823ae7..2d0a5faacd 100644 --- a/src/mbgl/programs/gl/line_sdf.cpp +++ b/src/mbgl/programs/gl/line_sdf.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/raster.cpp b/src/mbgl/programs/gl/raster.cpp index 98cfade1f5..f6ae3b5bc5 100644 --- a/src/mbgl/programs/gl/raster.cpp +++ b/src/mbgl/programs/gl/raster.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/symbol_icon.cpp b/src/mbgl/programs/gl/symbol_icon.cpp index cb896b4160..834bfc16d2 100644 --- a/src/mbgl/programs/gl/symbol_icon.cpp +++ b/src/mbgl/programs/gl/symbol_icon.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/symbol_sdf_icon.cpp b/src/mbgl/programs/gl/symbol_sdf_icon.cpp index a25754ffad..2daa1e860d 100644 --- a/src/mbgl/programs/gl/symbol_sdf_icon.cpp +++ b/src/mbgl/programs/gl/symbol_sdf_icon.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/gl/symbol_sdf_text.cpp b/src/mbgl/programs/gl/symbol_sdf_text.cpp index 9aec77043b..5750e7730c 100644 --- a/src/mbgl/programs/gl/symbol_sdf_text.cpp +++ b/src/mbgl/programs/gl/symbol_sdf_text.cpp @@ -29,8 +29,8 @@ constexpr const uint8_t ShaderSource::hash[8]; namespace gfx { template <> -std::unique_ptr> -Context::createProgram(const ProgramParameters& programParameters) { +std::unique_ptr> +Backend::Create(const ProgramParameters& programParameters) { return std::make_unique>(programParameters); } diff --git a/src/mbgl/programs/heatmap_program.cpp b/src/mbgl/programs/heatmap_program.cpp index 32c30ea313..67f84fbd52 100644 --- a/src/mbgl/programs/heatmap_program.cpp +++ b/src/mbgl/programs/heatmap_program.cpp @@ -1,10 +1,7 @@ #include -#include namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - static_assert(sizeof(HeatmapLayoutVertex) == 4, "expected HeatmapLayoutVertex size"); } // namespace mbgl diff --git a/src/mbgl/programs/heatmap_texture_program.cpp b/src/mbgl/programs/heatmap_texture_program.cpp index 04c5ff56a7..3b0e24eab8 100644 --- a/src/mbgl/programs/heatmap_texture_program.cpp +++ b/src/mbgl/programs/heatmap_texture_program.cpp @@ -1,10 +1,7 @@ #include -#include namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - static_assert(sizeof(HeatmapTextureLayoutVertex) == 4, "expected HeatmapTextureLayoutVertex size"); } // namespace mbgl diff --git a/src/mbgl/programs/hillshade_prepare_program.cpp b/src/mbgl/programs/hillshade_prepare_program.cpp index 5bbac9eaec..0c0446d3f5 100644 --- a/src/mbgl/programs/hillshade_prepare_program.cpp +++ b/src/mbgl/programs/hillshade_prepare_program.cpp @@ -1,10 +1,7 @@ #include -#include namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - static_assert(sizeof(HillshadePrepareLayoutVertex) == 8, "expected HillshadeLayoutVertex size"); } // namespace mbgl diff --git a/src/mbgl/programs/hillshade_program.cpp b/src/mbgl/programs/hillshade_program.cpp index 31673afcd4..f054ad4b74 100644 --- a/src/mbgl/programs/hillshade_program.cpp +++ b/src/mbgl/programs/hillshade_program.cpp @@ -1,10 +1,7 @@ #include -#include namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - static_assert(sizeof(HillshadeLayoutVertex) == 8, "expected HillshadeLayoutVertex size"); } // namespace mbgl diff --git a/src/mbgl/programs/line_program.cpp b/src/mbgl/programs/line_program.cpp index cab1e7e6fd..40b4617c77 100644 --- a/src/mbgl/programs/line_program.cpp +++ b/src/mbgl/programs/line_program.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -9,11 +8,6 @@ namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - using namespace style; static_assert(sizeof(LineLayoutVertex) == 12, "expected LineLayoutVertex size"); diff --git a/src/mbgl/programs/raster_program.cpp b/src/mbgl/programs/raster_program.cpp index f3b1052284..6906903e6b 100644 --- a/src/mbgl/programs/raster_program.cpp +++ b/src/mbgl/programs/raster_program.cpp @@ -1,10 +1,7 @@ #include -#include namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - static_assert(sizeof(RasterLayoutVertex) == 8, "expected RasterLayoutVertex size"); } // namespace mbgl diff --git a/src/mbgl/programs/symbol_program.cpp b/src/mbgl/programs/symbol_program.cpp index 8a7dccd55e..3633bd7c2a 100644 --- a/src/mbgl/programs/symbol_program.cpp +++ b/src/mbgl/programs/symbol_program.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -10,10 +9,6 @@ namespace mbgl { -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); -template std::unique_ptr> gfx::Context::createProgram(const ProgramParameters&); - using namespace style; static_assert(sizeof(SymbolLayoutVertex) == 16, "expected SymbolLayoutVertex size"); diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index 5afc4152ba..175d053f93 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -87,6 +87,10 @@ public: }; TEST(CustomLayer, Basic) { + if (gfx::Backend::GetType() != gfx::Backend::Type::OpenGL) { + return; + } + util::RunLoop loop; HeadlessFrontend frontend { 1 }; diff --git a/test/gl/context.test.cpp b/test/gl/context.test.cpp index 54b0c01d95..4b6bad6f65 100644 --- a/test/gl/context.test.cpp +++ b/test/gl/context.test.cpp @@ -85,6 +85,10 @@ struct Buffer { }; TEST(GLContextMode, Shared) { + if (gfx::Backend::GetType() != gfx::Backend::Type::OpenGL) { + return; + } + util::RunLoop loop; HeadlessFrontend frontend { 1, {}, gfx::ContextMode::Shared }; diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 42edaedf22..fd831a05b7 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -610,6 +610,10 @@ TEST(Map, AddLayer) { } TEST(Map, WithoutVAOExtension) { + if (gfx::Backend::GetType() != gfx::Backend::Type::OpenGL) { + return; + } + MapTest test { ":memory:", "test/fixtures/api/assets" }; gfx::BackendScope scope { *test.frontend.getBackend() }; diff --git a/test/src/mbgl/test/test.cpp b/test/src/mbgl/test/test.cpp index 1c77aae2a1..30df01c488 100644 --- a/test/src/mbgl/test/test.cpp +++ b/test/src/mbgl/test/test.cpp @@ -1,9 +1,12 @@ #include +#include #include #include #include +#include + namespace mbgl { int runTests(int argc, char *argv[]) { @@ -12,6 +15,12 @@ int runTests(int argc, char *argv[]) { #endif testing::InitGoogleTest(&argc, argv); + + args::ArgumentParser argumentParser("Unit tests"); + args::ValueFlag backendValue(argumentParser, "Backend", "Rendering backend", {"backend"}); + + argumentParser.ParseCLI(argc, argv); + return RUN_ALL_TESTS(); } diff --git a/test/util/offscreen_texture.test.cpp b/test/util/offscreen_texture.test.cpp index ef10984364..ae56b347a4 100644 --- a/test/util/offscreen_texture.test.cpp +++ b/test/util/offscreen_texture.test.cpp @@ -14,6 +14,10 @@ using namespace mbgl; using namespace mbgl::platform; TEST(OffscreenTexture, EmptyRed) { + if (gfx::Backend::GetType() != gfx::Backend::Type::OpenGL) { + return; + } + gl::HeadlessBackend backend({ 512, 256 }); gfx::BackendScope scope { backend }; @@ -76,6 +80,10 @@ struct Buffer { TEST(OffscreenTexture, RenderToTexture) { + if (gfx::Backend::GetType() != gfx::Backend::Type::OpenGL) { + return; + } + gl::HeadlessBackend backend({ 512, 256 }); gfx::BackendScope scope { backend }; auto& context = static_cast(backend.getContext()); -- cgit v1.2.1