summaryrefslogtreecommitdiff
path: root/boilerplate
diff options
context:
space:
mode:
authorBryce Harrington <bryce@osg.samsung.com>2017-09-13 12:35:27 -0700
committerBryce Harrington <bryce@osg.samsung.com>2017-09-13 15:18:04 -0700
commit8ff3019f51bd40c23d8a0dd5e51ce3fab6442d6e (patch)
treed1134f7f14dc337b04e32a83537851d8c53193b0 /boilerplate
parentd1f941d7ee06340c155158b32bec28fc2e1a4264 (diff)
gl: Add support for OpenGL ES 3.0
This improves the OpenGL ES support to extend it to version 3.0. A number of new features are available in glesv3 including creation of multi-sampled renderbuffers. These renderbuffers can be blitted to single sample textures (but not the other way around). Other features such as PBO for image uploading, are left as followon work. For this preliminary implementation, glesv3 backends always create renderbuffers, which can be set as single sample or multisample. The renderbuffer's content is blitted to the texture only when used as a source or a mask. Images uploaded to a texture stay there until the surface is used as a rendering target, at which point its painted to the renderbuffer. This patch is heavily based off of Henry Song's initial GLESv3 patch 6f7f3795 from his cairogles fork of Cairo, and incorporates subsequent fixes and pertinent refactorings from his trunk and review feedback from Uli. This implements the *functional* support for glesv3, excluding the various optimization work to utilize its features. Rendering and performance should not be expected to improve notably from pure glesv2. As the GL backend for Cairo remains "experimental", these changes should likewise be considered as such. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Diffstat (limited to 'boilerplate')
-rw-r--r--boilerplate/Makefile.win32.features12
-rw-r--r--boilerplate/cairo-boilerplate-egl.c30
2 files changed, 34 insertions, 8 deletions
diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features
index e60a95ba6..abb198dee 100644
--- a/boilerplate/Makefile.win32.features
+++ b/boilerplate/Makefile.win32.features
@@ -247,6 +247,18 @@ enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glesv2_cxx_sources)
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glesv2_sources)
endif
+unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_glesv3_headers)
+all_cairo_boilerplate_headers += $(cairo_boilerplate_glesv3_headers)
+all_cairo_boilerplate_private += $(cairo_boilerplate_glesv3_private)
+all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glesv3_cxx_sources)
+all_cairo_boilerplate_sources += $(cairo_boilerplate_glesv3_sources)
+ifeq ($(CAIRO_HAS_GLESV3_SURFACE),1)
+enabled_cairo_boilerplate_headers += $(cairo_boilerplate_glesv3_headers)
+enabled_cairo_boilerplate_private += $(cairo_boilerplate_glesv3_private)
+enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_glesv3_cxx_sources)
+enabled_cairo_boilerplate_sources += $(cairo_boilerplate_glesv3_sources)
+endif
+
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_cogl_headers)
all_cairo_boilerplate_headers += $(cairo_boilerplate_cogl_headers)
all_cairo_boilerplate_private += $(cairo_boilerplate_cogl_private)
diff --git a/boilerplate/cairo-boilerplate-egl.c b/boilerplate/cairo-boilerplate-egl.c
index 99bee64cf..c44441cc5 100644
--- a/boilerplate/cairo-boilerplate-egl.c
+++ b/boilerplate/cairo-boilerplate-egl.c
@@ -33,10 +33,13 @@
#include "cairo-boilerplate-private.h"
#include <cairo-gl.h>
-#if CAIRO_HAS_GL_SURFACE
-#include <GL/gl.h>
+#if CAIRO_HAS_GLESV3_SURFACE
+#include <GLES3/gl3.h>
+#include <EGL/eglext.h>
#elif CAIRO_HAS_GLESV2_SURFACE
#include <GLES2/gl2.h>
+#elif CAIRO_HAS_GL_SURFACE
+#include <GL/gl.h>
#endif
static const cairo_user_data_key_t gl_closure_key;
@@ -85,15 +88,19 @@ _cairo_boilerplate_egl_create_surface (const char *name,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
-#if CAIRO_HAS_GL_SURFACE
- EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+#if CAIRO_HAS_GLESV3_SURFACE
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
#elif CAIRO_HAS_GLESV2_SURFACE
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+#elif CAIRO_HAS_GL_SURFACE
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
#endif
EGL_NONE
};
const EGLint ctx_attribs[] = {
-#if CAIRO_HAS_GLESV2_SURFACE
+#if CAIRO_HAS_GLESV3_SURFACE
+ EGL_CONTEXT_CLIENT_VERSION, 3,
+#elif CAIRO_HAS_GLESV2_SURFACE
EGL_CONTEXT_CLIENT_VERSION, 2,
#endif
EGL_NONE
@@ -110,15 +117,22 @@ _cairo_boilerplate_egl_create_surface (const char *name,
}
eglChooseConfig (gltc->dpy, config_attribs, &config, 1, &numConfigs);
+#if CAIRO_HAS_GLESV3_SURFACE && CAIRO_HAS_GLESV2_SURFACE
+ if (numConfigs == 0) {
+ /* retry with ES2_BIT */
+ config_attribs[11] = ES2_BIT; /* FIXME: Ick */
+ eglChooseConfig (gltc->dpy, config_attribs, &config, 1, &numConfigs);
+ }
+#endif
if (numConfigs == 0) {
free (gltc);
return NULL;
}
-#if CAIRO_HAS_GL_SURFACE
- eglBindAPI (EGL_OPENGL_API);
-#elif CAIRO_HAS_GLESV2_SURFACE
+#if CAIRO_HAS_GLESV3_SURFACE || CAIRO_HAS_GLESV2_SURFACE
eglBindAPI (EGL_OPENGL_ES_API);
+#elif CAIRO_HAS_GL_SURFACE
+ eglBindAPI (EGL_OPENGL_API);
#endif
gltc->ctx = eglCreateContext (gltc->dpy, config, EGL_NO_CONTEXT,