summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-11-02 16:46:59 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-11-02 17:34:03 +0200
commitd1723ce0403d8d2858c070f1ef732c8608915683 (patch)
treebdb3b2cfa5021500d0b89401fb65d0791c767ead
parent87449f08c592a73ecd67de2768b1c1be0abc552f (diff)
downloadqtlocation-mapboxgl-upstream/travis-updates.tar.gz
[linux] Refactor Headless EGL with latest headless displayupstream/travis-updates
- s/HeadlessView/HeadlessBackend/g - Use EGL_DEFAULT_DISPLAY
m---------.mason0
-rw-r--r--.travis.yml6
-rw-r--r--include/mbgl/gl/implementation.hpp2
-rw-r--r--include/mbgl/platform/default/headless_backend.hpp13
-rw-r--r--include/mbgl/platform/default/headless_display.hpp9
-rw-r--r--platform/default/headless_backend_egl.cpp79
-rw-r--r--platform/default/headless_backend_glx.cpp67
-rw-r--r--platform/default/headless_display.cpp21
-rw-r--r--platform/linux/config.cmake1
-rwxr-xr-xscripts/travis_setup.sh4
10 files changed, 22 insertions, 180 deletions
diff --git a/.mason b/.mason
-Subproject 48ea4761bd386f9113397a4366d63e83e358664
+Subproject 4bbaa3c2e331fcfd818116d5003493fb7fdf771
diff --git a/.travis.yml b/.travis.yml
index 6c749acfdf..428db242ac 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,14 +6,14 @@ addons_shortcuts:
addons_clang35: &clang35
apt:
sources: [ 'ubuntu-toolchain-r-test', 'george-edison55-precise-backports' ]
- packages: [ 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'cmake', 'cmake-data',
- 'mesa-utils', 'libxi-dev', 'libglu1-mesa-dev', 'x11proto-randr-dev', 'x11proto-xext-dev', 'libxrandr-dev',
+ packages: [ 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.8v4', 'cmake', 'cmake-data',
+ 'mesa-utils', 'libxi-dev', 'libegl1-mesa-dev', 'libgbm-dev', 'x11proto-randr-dev', 'x11proto-xext-dev', 'libxrandr-dev',
'x11proto-xf86vidmode-dev', 'libxxf86vm-dev', 'libxcursor-dev', 'libxinerama-dev' ]
addons_gcc5: &gcc5
apt:
sources: [ 'ubuntu-toolchain-r-test', 'george-edison55-precise-backports' ]
packages: [ 'gdb', 'g++-5', 'gcc-5', 'cmake', 'cmake-data',
- 'mesa-utils', 'libxi-dev', 'libglu1-mesa-dev', 'x11proto-randr-dev', 'x11proto-xext-dev', 'libxrandr-dev',
+ 'mesa-utils', 'libxi-dev', 'libegl1-mesa-dev', 'libgbm-dev', 'x11proto-randr-dev', 'x11proto-xext-dev', 'libxrandr-dev',
'x11proto-xf86vidmode-dev', 'libxxf86vm-dev', 'libxcursor-dev', 'libxinerama-dev' ]
addons_qt4: &qt4
apt:
diff --git a/include/mbgl/gl/implementation.hpp b/include/mbgl/gl/implementation.hpp
index 4e3a3e51c7..7275d22ea6 100644
--- a/include/mbgl/gl/implementation.hpp
+++ b/include/mbgl/gl/implementation.hpp
@@ -10,5 +10,5 @@
#define MBGL_USE_CGL 1
#endif
#else
- #define MBGL_USE_GLX 1
+ #define MBGL_USE_EGL 1
#endif
diff --git a/include/mbgl/platform/default/headless_backend.hpp b/include/mbgl/platform/default/headless_backend.hpp
index 6b096b694f..f7e8ee7295 100644
--- a/include/mbgl/platform/default/headless_backend.hpp
+++ b/include/mbgl/platform/default/headless_backend.hpp
@@ -6,12 +6,6 @@
class QGLWidget;
#elif MBGL_USE_CGL
#include <OpenGL/OpenGL.h>
-#elif MBGL_USE_GLX
-#define MBGL_USE_EGL 1
-struct gbm_device {};
-typedef void* EGLContext;
-typedef void* EGLDisplay;
-typedef void* EGLConfig;
#endif
#include <mbgl/map/backend.hpp>
@@ -60,13 +54,8 @@ private:
CGLContextObj glContext = nullptr;
#endif
-#if MBGL_USE_EAGL
- void *glContext = nullptr;
-#endif
#if MBGL_USE_EGL
- EGLDisplay dpy;
- EGLContext glContext = nullptr;
- EGLConfig config;
+ void *glContext = nullptr;
#endif
std::function<void(MapChange)> mapChangeCallback;
diff --git a/include/mbgl/platform/default/headless_display.hpp b/include/mbgl/platform/default/headless_display.hpp
index 45646d754a..e0fc8e17ea 100644
--- a/include/mbgl/platform/default/headless_display.hpp
+++ b/include/mbgl/platform/default/headless_display.hpp
@@ -4,9 +4,10 @@
#if MBGL_USE_CGL
#include <OpenGL/OpenGL.h>
-#elif MBGL_USE_GLX
-typedef struct _XDisplay Display;
-typedef struct __GLXFBConfigRec* GLXFBConfig;
+#endif
+
+#if MBGL_USE_EGL
+#include <EGL/egl.h>
#endif
namespace mbgl {
@@ -21,8 +22,6 @@ public:
#endif
#if MBGL_USE_EGL
- int fd;
- struct gbm_device *gbm = nullptr;
EGLDisplay dpy = 0;
EGLConfig config = 0;
#endif
diff --git a/platform/default/headless_backend_egl.cpp b/platform/default/headless_backend_egl.cpp
index ee1c875531..bed6129f0e 100644
--- a/platform/default/headless_backend_egl.cpp
+++ b/platform/default/headless_backend_egl.cpp
@@ -12,13 +12,13 @@
namespace mbgl {
-gl::glProc HeadlessView::initializeExtension(const char* name) {
+gl::glProc HeadlessBackend::initializeExtension(const char* name) {
return eglGetProcAddress(name);
}
-void HeadlessView::createContext() {
- dpy = display->dpy;
- config = display->config;
+void HeadlessBackend::createContext() {
+ auto dpy = display->dpy;
+ auto config = display->config;
assert(dpy != EGL_NO_DISPLAY);
assert(glContext == EGL_NO_CONTEXT);
@@ -34,8 +34,9 @@ void HeadlessView::createContext() {
}
}
-void HeadlessView::destroyContext() {
+void HeadlessBackend::destroyContext() {
if (glContext) {
+ auto dpy = display->dpy;
if (!eglDestroyContext(dpy, glContext)) {
throw std::runtime_error("Failed to destroy context.");
}
@@ -44,75 +45,15 @@ void HeadlessView::destroyContext() {
}
}
-void HeadlessView::resizeFramebuffer() {
- const unsigned int w = dimensions[0] * pixelRatio;
- const unsigned int h = dimensions[1] * pixelRatio;
-
- // Create depth/stencil buffer
- MBGL_CHECK_ERROR(glGenRenderbuffersEXT(1, &fboDepthStencil));
- MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fboDepthStencil));
- MBGL_CHECK_ERROR(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, w, h));
- MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0));
-
- MBGL_CHECK_ERROR(glGenRenderbuffersEXT(1, &fboColor));
- MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fboColor));
- MBGL_CHECK_ERROR(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, w, h));
- MBGL_CHECK_ERROR(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0));
-
- MBGL_CHECK_ERROR(glGenFramebuffersEXT(1, &fbo));
- MBGL_CHECK_ERROR(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo));
-
- MBGL_CHECK_ERROR(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, fboColor));
- MBGL_CHECK_ERROR(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER_EXT, fboDepthStencil));
-
- GLenum status = MBGL_CHECK_ERROR(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
-
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- std::string error("Couldn't create framebuffer: ");
- switch (status) {
- case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: (error += "incomplete attachment"); break;
- case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: error += "incomplete missing attachment"; break;
- case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: error += "incomplete dimensions"; break;
- case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: error += "incomplete formats"; break;
- case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: error += "incomplete draw buffer"; break;
- case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: error += "incomplete read buffer"; break;
- case GL_FRAMEBUFFER_UNSUPPORTED: error += "unsupported"; break;
- default: error += "other"; break;
- }
- throw std::runtime_error(error);
- }
-
- MBGL_CHECK_ERROR(glViewport(0, 0, w, h));
-}
-
-void HeadlessView::clearBuffers() {
- assert(active);
-
- MBGL_CHECK_ERROR(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
-
- if (fbo) {
- MBGL_CHECK_ERROR(glDeleteFramebuffersEXT(1, &fbo));
- fbo = 0;
- }
-
- if (fboColor) {
- MBGL_CHECK_ERROR(glDeleteRenderbuffersEXT(1, &fboColor));
- fboColor = 0;
- }
-
- if (fboDepthStencil) {
- MBGL_CHECK_ERROR(glDeleteRenderbuffersEXT(1, &fboDepthStencil));
- fboDepthStencil = 0;
- }
-}
-
-void HeadlessView::activateContext() {
+void HeadlessBackend::activateContext() {
+ auto dpy = display->dpy;
if (!eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, glContext)) {
throw std::runtime_error("Switching OpenGL context failed.\n");
}
}
-void HeadlessView::deactivateContext() {
+void HeadlessBackend::deactivateContext() {
+ auto dpy = display->dpy;
if (!eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
throw std::runtime_error("Removing OpenGL context failed.\n");
}
diff --git a/platform/default/headless_backend_glx.cpp b/platform/default/headless_backend_glx.cpp
deleted file mode 100644
index bbfd19345b..0000000000
--- a/platform/default/headless_backend_glx.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-#include <mbgl/platform/default/headless_backend.hpp>
-#include <mbgl/platform/default/headless_display.hpp>
-
-#include <mbgl/platform/log.hpp>
-
-// #include <cassert>
-
-#include <GL/glx.h>
-
-namespace mbgl {
-
-gl::glProc HeadlessBackend::initializeExtension(const char* name) {
- return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name));
-}
-
-void HeadlessBackend::createContext() {
- xDisplay = display->xDisplay;
- fbConfigs = display->fbConfigs;
-
- if (!glContext) {
- // Try to create a legacy context
- glContext = glXCreateNewContext(xDisplay, fbConfigs[0], GLX_RGBA_TYPE, None, True);
- if (glContext) {
- if (!glXIsDirect(xDisplay, glContext)) {
- Log::Error(Event::OpenGL, "failed to create direct OpenGL Legacy context");
- glXDestroyContext(xDisplay, glContext);
- glContext = nullptr;
- }
- }
- }
-
- if (glContext == nullptr) {
- throw std::runtime_error("Error creating GL context object.");
- }
-
- // Create a dummy pbuffer. We will render to framebuffers anyway, but we need a pbuffer to
- // activate the context.
- int pbufferAttributes[] = {
- GLX_PBUFFER_WIDTH, 8,
- GLX_PBUFFER_HEIGHT, 8,
- None
- };
- glxPbuffer = glXCreatePbuffer(xDisplay, fbConfigs[0], pbufferAttributes);
-}
-
-void HeadlessBackend::destroyContext() {
- if (glxPbuffer) {
- glXDestroyPbuffer(xDisplay, glxPbuffer);
- glxPbuffer = 0;
- }
-
- glXDestroyContext(xDisplay, glContext);
-}
-
-void HeadlessBackend::activateContext() {
- if (!glXMakeContextCurrent(xDisplay, glxPbuffer, glxPbuffer, glContext)) {
- throw std::runtime_error("Switching OpenGL context failed.\n");
- }
-}
-
-void HeadlessBackend::deactivateContext() {
- if (!glXMakeContextCurrent(xDisplay, 0, 0, nullptr)) {
- throw std::runtime_error("Removing OpenGL context failed.\n");
- }
-}
-
-} // namespace mbgl
diff --git a/platform/default/headless_display.cpp b/platform/default/headless_display.cpp
index a4517327cb..4d7ef5c933 100644
--- a/platform/default/headless_display.cpp
+++ b/platform/default/headless_display.cpp
@@ -4,7 +4,6 @@
#include <mbgl/util/string.hpp>
#include <EGL/egl.h>
#include <fcntl.h>
-#include <gbm.h>
#include <unistd.h>
#endif
@@ -34,22 +33,7 @@ HeadlessDisplay::HeadlessDisplay() {
}
#endif
#if MBGL_USE_EGL
- for (int i = 128; i < (128 + 16); i++) {
- auto device_name = std::string{ "/dev/dri/renderD" } + mbgl::util::toString(i);
- fd = open(device_name.c_str(), O_RDWR);
- if (fd > 0)
- break;
- }
- if (fd < 0) {
- throw std::runtime_error("Couldn't open drm device.");
- }
-
- gbm = gbm_create_device(fd);
- if (gbm == NULL) {
- throw std::runtime_error("Couldn't create gbm device.");
- }
-
- dpy = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(gbm));
+ dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (dpy == EGL_NO_DISPLAY) {
throw std::runtime_error("eglGetDisplay() failed.");
}
@@ -79,11 +63,8 @@ HeadlessDisplay::~HeadlessDisplay() {
#if MBGL_USE_CGL
CGLDestroyPixelFormat(pixelFormat);
#endif
-
#if MBGL_USE_EGL
eglTerminate(dpy);
- gbm_device_destroy(gbm);
- close(fd);
#endif
}
diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake
index c39a3da806..61ffdc008f 100644
--- a/platform/linux/config.cmake
+++ b/platform/linux/config.cmake
@@ -41,7 +41,6 @@ macro(mbgl_platform_core)
PRIVATE platform/default/webp_reader.cpp
# Headless view
- PRIVATE platform/default/headless_backend_glx.cpp
PRIVATE platform/default/headless_backend_egl.cpp
PRIVATE platform/default/headless_backend.cpp
PRIVATE platform/default/headless_display.cpp
diff --git a/scripts/travis_setup.sh b/scripts/travis_setup.sh
index ae8dda46b5..8b573c4d5d 100755
--- a/scripts/travis_setup.sh
+++ b/scripts/travis_setup.sh
@@ -49,8 +49,8 @@ touch package.json
# Install and set up to load a more recent version of mesa
mapbox_time "install_mesa" \
-mason install mesa 11.2.2
-export LD_LIBRARY_PATH="`mason prefix mesa 11.2.2`/lib:${LD_LIBRARY_PATH:-}"
+mason install mesa 12.0.3
+export LD_LIBRARY_PATH="`mason prefix mesa 12.0.3`/lib:${LD_LIBRARY_PATH:-}"
# Install and set up to load awscli
pip install --user awscli