aboutsummaryrefslogtreecommitdiff
path: root/render/gles2
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-06-05 15:13:32 +0200
committerSimon Ser <contact@emersion.fr>2020-06-06 08:59:38 +0200
commita3ba82885ca038fc1e51775cac7ce5ada3bad0e1 (patch)
treebd2f21968b175932a772f3f45bd80c2525b8ed58 /render/gles2
parent363bf44a353ca0ce7e9d48476fb187d8da037483 (diff)
render: choose DMA-BUF texture target via eglQueryDmaBufModifiersEXT
EGL_EXT_image_dma_buf_import_modifiers tells us whether we should use GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES. Using the right texture target can fix some failures and/or improve performance on some drivers. This does the same as a Weston commit [1]. [1]: https://gitlab.freedesktop.org/wayland/weston/commit/40c519a3e613 Closes: https://github.com/swaywm/wlroots/issues/2173
Diffstat (limited to 'render/gles2')
-rw-r--r--render/gles2/texture.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 64a0d9f1..0187a462 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -273,26 +273,28 @@ struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl,
wlr_texture_init(&texture->wlr_texture, &texture_impl,
attribs->width, attribs->height);
texture->egl = egl;
- texture->target = GL_TEXTURE_EXTERNAL_OES;
texture->has_alpha = true;
texture->wl_format = 0xFFFFFFFF; // texture can't be written anyways
texture->inverted_y =
(attribs->flags & WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT) != 0;
- texture->image = wlr_egl_create_image_from_dmabuf(egl, attribs);
+ bool external_only;
+ texture->image =
+ wlr_egl_create_image_from_dmabuf(egl, attribs, &external_only);
if (texture->image == EGL_NO_IMAGE_KHR) {
wlr_log(WLR_ERROR, "Failed to create EGL image from DMA-BUF");
free(texture);
return NULL;
}
+ texture->target = external_only ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D;
+
PUSH_GLES2_DEBUG;
glGenTextures(1, &texture->tex);
- glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture->tex);
- gles2_procs.glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES,
- texture->image);
- glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
+ glBindTexture(texture->target, texture->tex);
+ gles2_procs.glEGLImageTargetTexture2DOES(texture->target, texture->image);
+ glBindTexture(texture->target, 0);
POP_GLES2_DEBUG;