diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-06-09 10:19:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-09 10:19:40 -0700 |
commit | 9a1f0e2d5fe56870f3bd7d12113742766e89f4e6 (patch) | |
tree | 090ee2c01093858d485fdfcdeb8a60736894dec1 | |
parent | 9179b438a596943f78dd2f7c27086c3116b26b01 (diff) | |
parent | f1a62a3200ef78e2d70035862c9b5a86bae27e21 (diff) |
Merge pull request #1052 from VincentVanlaer/egl-damage-khr
Split eglSwapBuffersWithDamage feature detection
-rw-r--r-- | include/wlr/render/egl.h | 13 | ||||
-rw-r--r-- | render/egl.c | 45 | ||||
-rw-r--r-- | render/gles2/texture.c | 2 |
3 files changed, 31 insertions, 29 deletions
diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index 55086755..0f591d60 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -16,12 +16,13 @@ struct wlr_egl { const char *exts_str; struct { - bool bind_wayland_display; - bool buffer_age; - bool dmabuf_import_modifiers; - bool dmabuf_import; - bool image_base; - bool swap_buffers_with_damage; + bool bind_wayland_display_wl; + bool buffer_age_ext; + bool image_dmabuf_import_modifiers_ext; + bool image_dmabuf_import_ext; + bool image_base_khr; + bool swap_buffers_with_damage_ext; + bool swap_buffers_with_damage_khr; } exts; struct wl_display *wl_display; diff --git a/render/egl.c b/render/egl.c index eafaebd7..450562db 100644 --- a/render/egl.c +++ b/render/egl.c @@ -77,7 +77,7 @@ static bool check_egl_ext(const char *exts, const char *ext) { static void print_dmabuf_formats(struct wlr_egl *egl) { /* Avoid log msg if extension is not present */ - if (!egl->exts.dmabuf_import_modifiers) { + if (!egl->exts.image_dmabuf_import_modifiers_ext) { return; } @@ -146,26 +146,27 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, wlr_log(L_INFO, "Supported EGL extensions: %s", egl->exts_str); wlr_log(L_INFO, "EGL vendor: %s", eglQueryString(egl->display, EGL_VENDOR)); - egl->exts.image_base = + egl->exts.image_base_khr = check_egl_ext(egl->exts_str, "EGL_KHR_image_base") && eglCreateImageKHR && eglDestroyImageKHR; - egl->exts.buffer_age = + egl->exts.buffer_age_ext = check_egl_ext(egl->exts_str, "EGL_EXT_buffer_age"); - egl->exts.swap_buffers_with_damage = + egl->exts.swap_buffers_with_damage_ext = (check_egl_ext(egl->exts_str, "EGL_EXT_swap_buffers_with_damage") && - eglSwapBuffersWithDamageEXT) || + eglSwapBuffersWithDamageEXT); + egl->exts.swap_buffers_with_damage_khr = (check_egl_ext(egl->exts_str, "EGL_KHR_swap_buffers_with_damage") && eglSwapBuffersWithDamageKHR); - egl->exts.dmabuf_import = + egl->exts.image_dmabuf_import_ext = check_egl_ext(egl->exts_str, "EGL_EXT_image_dma_buf_import"); - egl->exts.dmabuf_import_modifiers = + egl->exts.image_dmabuf_import_modifiers_ext = check_egl_ext(egl->exts_str, "EGL_EXT_image_dma_buf_import_modifiers") && eglQueryDmaBufFormatsEXT && eglQueryDmaBufModifiersEXT; print_dmabuf_formats(egl); - egl->exts.bind_wayland_display = + egl->exts.bind_wayland_display_wl = check_egl_ext(egl->exts_str, "EGL_WL_bind_wayland_display") && eglBindWaylandDisplayWL && eglUnbindWaylandDisplayWL && eglQueryWaylandBufferWL; @@ -234,7 +235,7 @@ void wlr_egl_finish(struct wlr_egl *egl) { eglMakeCurrent(egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (egl->wl_display) { - assert(egl->exts.bind_wayland_display); + assert(egl->exts.bind_wayland_display_wl); eglUnbindWaylandDisplayWL(egl->display, egl->wl_display); } @@ -244,7 +245,7 @@ void wlr_egl_finish(struct wlr_egl *egl) { } bool wlr_egl_bind_display(struct wlr_egl *egl, struct wl_display *local_display) { - if (!egl->exts.bind_wayland_display) { + if (!egl->exts.bind_wayland_display_wl) { return false; } @@ -257,7 +258,7 @@ bool wlr_egl_bind_display(struct wlr_egl *egl, struct wl_display *local_display) } bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImage image) { - if (!egl->exts.image_base) { + if (!egl->exts.image_base_khr) { return false; } if (!image) { @@ -278,7 +279,7 @@ EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window) { } static int egl_get_buffer_age(struct wlr_egl *egl, EGLSurface surface) { - if (!egl->exts.buffer_age) { + if (!egl->exts.buffer_age_ext) { return -1; } @@ -313,7 +314,8 @@ bool wlr_egl_is_current(struct wlr_egl *egl) { bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface, pixman_region32_t *damage) { EGLBoolean ret; - if (damage != NULL && egl->exts.swap_buffers_with_damage) { + if (damage != NULL && (egl->exts.swap_buffers_with_damage_ext || + egl->exts.swap_buffers_with_damage_khr)) { int nrects; pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects); @@ -325,8 +327,7 @@ bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface, egl_damage[4*i + 3] = rects[i].y2 - rects[i].y1; } - assert(eglSwapBuffersWithDamageEXT || eglSwapBuffersWithDamageKHR); - if (eglSwapBuffersWithDamageEXT) { + if (egl->exts.swap_buffers_with_damage_ext) { ret = eglSwapBuffersWithDamageEXT(egl->display, surface, egl_damage, nrects); } else { @@ -347,7 +348,7 @@ bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface, EGLImageKHR wlr_egl_create_image_from_wl_drm(struct wlr_egl *egl, struct wl_resource *data, EGLint *fmt, int *width, int *height, bool *inverted_y) { - if (!egl->exts.bind_wayland_display || !egl->exts.image_base) { + if (!egl->exts.bind_wayland_display_wl || !egl->exts.image_base_khr) { return NULL; } @@ -376,13 +377,13 @@ EGLImageKHR wlr_egl_create_image_from_wl_drm(struct wlr_egl *egl, EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl, struct wlr_dmabuf_attributes *attributes) { - if (!egl->exts.image_base) { + if (!egl->exts.image_base_khr) { return NULL; } bool has_modifier = false; if (attributes->modifier != DRM_FORMAT_MOD_INVALID) { - if (!egl->exts.dmabuf_import_modifiers) { + if (!egl->exts.image_dmabuf_import_modifiers_ext) { return NULL; } has_modifier = true; @@ -454,8 +455,8 @@ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl, int wlr_egl_get_dmabuf_formats(struct wlr_egl *egl, int **formats) { - if (!egl->exts.dmabuf_import || - !egl->exts.dmabuf_import_modifiers) { + if (!egl->exts.image_dmabuf_import_ext || + !egl->exts.image_dmabuf_import_modifiers_ext) { wlr_log(L_DEBUG, "dmabuf extension not present"); return -1; } @@ -482,8 +483,8 @@ int wlr_egl_get_dmabuf_formats(struct wlr_egl *egl, int wlr_egl_get_dmabuf_modifiers(struct wlr_egl *egl, int format, uint64_t **modifiers) { - if (!egl->exts.dmabuf_import || - !egl->exts.dmabuf_import_modifiers) { + if (!egl->exts.image_dmabuf_import_ext || + !egl->exts.image_dmabuf_import_modifiers_ext) { wlr_log(L_DEBUG, "dmabuf extension not present"); return -1; } diff --git a/render/gles2/texture.c b/render/gles2/texture.c index ca1398e8..da98a523 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -210,7 +210,7 @@ struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl, return NULL; } - if (!egl->exts.dmabuf_import) { + if (!egl->exts.image_dmabuf_import_ext) { wlr_log(L_ERROR, "Cannot create DMA-BUF texture: EGL extension " "unavailable"); return NULL; |