From 6fcac0f580786adbb71040dfc69b36bdbb6f94e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 5 Apr 2017 15:57:47 +0200 Subject: [PATCH] [core] always create a pixelbuffer surface in the EGL backend We need a surface to activate a context. Some implementation don't seem to error when passing EGL_NO_SURFACE, but it doesn't seem standards compliant. --- platform/linux/src/headless_backend_egl.cpp | 11 ++++++----- platform/linux/src/headless_display_egl.cpp | 4 ---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/platform/linux/src/headless_backend_egl.cpp b/platform/linux/src/headless_backend_egl.cpp index cfe82d3cc..d98b2edc0 100644 --- a/platform/linux/src/headless_backend_egl.cpp +++ b/platform/linux/src/headless_backend_egl.cpp @@ -14,11 +14,13 @@ struct EGLImpl : public HeadlessBackend::Impl { : glContext(glContext_), display(display_), config(config_) { -#if __ANDROID__ - // Create a pixel buffer surface (in conjunction with EGL_SURFACE_TYPE, EGL_PBUFFER_BIT). + // Create a dummy pbuffer. We will render to framebuffers anyway, but we need a pbuffer to + // activate the context. + // Note that to be able to create pbuffer surfaces, we need to choose a config that + // includes EGL_SURFACE_TYPE, EGL_PBUFFER_BIT in HeadlessDisplay. const EGLint surfAttribs[] = { - EGL_WIDTH, 512, - EGL_HEIGHT, 512, + EGL_WIDTH, 8, + EGL_HEIGHT, 8, EGL_LARGEST_PBUFFER, EGL_TRUE, EGL_NONE }; @@ -27,7 +29,6 @@ struct EGLImpl : public HeadlessBackend::Impl { if (glSurface == EGL_NO_SURFACE) { throw std::runtime_error("Could not create surface: " + std::to_string(eglGetError())); } -#endif // __ANDROID__ } ~EGLImpl() { diff --git a/platform/linux/src/headless_display_egl.cpp b/platform/linux/src/headless_display_egl.cpp index eddc05fea..03c8e16a5 100644 --- a/platform/linux/src/headless_display_egl.cpp +++ b/platform/linux/src/headless_display_egl.cpp @@ -32,11 +32,7 @@ HeadlessDisplay::Impl::Impl() { } const EGLint attribs[] = { -#if __ANDROID__ - // Android emulator requires a pixel buffer to generate renderable unit - // test results. EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, -#endif // __ANDROID__ EGL_NONE };