aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-11-10 09:38:37 -0500
committerGitHub <noreply@github.com>2018-11-10 09:38:37 -0500
commit3181c4bec06d2fe51da052c0a08c8287725ec900 (patch)
tree23076b31c8760cda651fdce364376f757afbc2b3
parentca570fa63cb187ba078d95e0973da8562687673f (diff)
parent09550032b7e897755be30c6339f97489b07570ff (diff)
Merge pull request #1356 from emersion/egl-renderable-type
render: correctly set EGL_RENDERABLE_TYPE
-rw-r--r--backend/headless/backend.c7
-rw-r--r--backend/x11/backend.c11
-rw-r--r--render/wlr_renderer.c25
3 files changed, 37 insertions, 6 deletions
diff --git a/backend/headless/backend.c b/backend/headless/backend.c
index cbc158f3..c0fc6022 100644
--- a/backend/headless/backend.c
+++ b/backend/headless/backend.c
@@ -103,10 +103,9 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display,
static const EGLint config_attribs[] = {
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
EGL_ALPHA_SIZE, 0,
- EGL_BLUE_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_RED_SIZE, 8,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_BLUE_SIZE, 1,
+ EGL_GREEN_SIZE, 1,
+ EGL_RED_SIZE, 1,
EGL_NONE,
};
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 7053e2f0..c0a11fbb 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -282,8 +282,17 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
create_renderer_func = wlr_renderer_autocreate;
}
+ static EGLint config_attribs[] = {
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+ EGL_RED_SIZE, 1,
+ EGL_GREEN_SIZE, 1,
+ EGL_BLUE_SIZE, 1,
+ EGL_ALPHA_SIZE, 0,
+ EGL_NONE,
+ };
+
x11->renderer = create_renderer_func(&x11->egl, EGL_PLATFORM_X11_KHR,
- x11->xlib_conn, NULL, x11->screen->root_visual);
+ x11->xlib_conn, config_attribs, x11->screen->root_visual);
if (x11->renderer == NULL) {
wlr_log(WLR_ERROR, "Failed to create renderer");
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index 10dc6db2..ca1a337d 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -198,7 +198,30 @@ void wlr_renderer_init_wl_display(struct wlr_renderer *r,
struct wlr_renderer *wlr_renderer_autocreate(struct wlr_egl *egl,
EGLenum platform, void *remote_display, EGLint *config_attribs,
EGLint visual_id) {
- if (!wlr_egl_init(egl, platform, remote_display, config_attribs, visual_id)) {
+ // Append GLES2-specific bits to the provided EGL config attributes
+ EGLint gles2_config_attribs[] = {
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_NONE,
+ };
+
+ size_t config_attribs_len = 0; // not including terminating EGL_NONE
+ while (config_attribs != NULL &&
+ config_attribs[config_attribs_len] != EGL_NONE) {
+ ++config_attribs_len;
+ }
+
+ size_t all_config_attribs_len = config_attribs_len +
+ sizeof(gles2_config_attribs) / sizeof(gles2_config_attribs[0]);
+ EGLint all_config_attribs[all_config_attribs_len];
+ if (config_attribs_len > 0) {
+ memcpy(all_config_attribs, config_attribs,
+ config_attribs_len * sizeof(EGLint));
+ }
+ memcpy(&all_config_attribs[config_attribs_len], gles2_config_attribs,
+ sizeof(gles2_config_attribs));
+
+ if (!wlr_egl_init(egl, platform, remote_display, all_config_attribs,
+ visual_id)) {
wlr_log(WLR_ERROR, "Could not initialize EGL");
return NULL;
}