From a3ba82885ca038fc1e51775cac7ce5ada3bad0e1 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 5 Jun 2020 15:13:32 +0200 Subject: 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 --- render/gles2/texture.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'render/gles2') 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; -- cgit v1.2.3