This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch devs/cedric/wl/gl-x11-dmabuf
in repository efl.
View the commit online.
commit 3018becd64d4697238671bfc08e11237561e9f04
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 29 09:33:41 2026 -0600
evas:gl_common: do not find a dmabuf image by its buffer address
The GL engines kept imported dmabuf images in a hash keyed by the
wl_buffer address and handed any hit back. An image can outlive its
wl_buffer, and libwayland and malloc often place the next wl_buffer at
the same address. The new buffer then got the old image, with the old
buffer's attributes and file descriptors.
Under Enlightenment this shows as a window that stays on an old frame
for good when its buffers are reallocated, or as one that is not drawn
at all, with eglCreateImage failing on every frame, when the old
descriptors are already closed. Closing one surface while opening the
next is enough, as menus do.
Keep the image only when it is the one being set and it holds the same
resource, attributes and scanout callback. Sharing an image between
objects saved nothing, as each bind imports the buffer again.
The EGL_WAYLAND_BUFFER_WL surfaces still use the hash.
The test is in Enlightenment, wl-dmabuf-reuse, as it needs a compositor
and a GPU.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../evas/engines/gl_common/evas_gl_native_dmabuf.c | 44 ++++++++++------------
1 file changed, 20 insertions(+), 24 deletions(-)
diff --git a/src/modules/evas/engines/gl_common/evas_gl_native_dmabuf.c b/src/modules/evas/engines/gl_common/evas_gl_native_dmabuf.c
index b671de354a..c162c776f1 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_native_dmabuf.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_native_dmabuf.c
@@ -222,16 +222,10 @@ _dmabuf_native_free_cb(void *image)
{
Evas_GL_Image *im = image;
Native *n;
- void *key;
if (!im) return;
if (!(n = im->native.data)) return;
- if (im->native.shared)
- {
- key = n->ns_data.wl_surface_dmabuf.resource;
- eina_hash_del(im->native.shared->native_wl_hash, &key, im);
- }
if (n->ns_data.wl_surface_dmabuf.image)
{
evas_gl_common_eglDestroyImage(im->native.disp,
@@ -270,27 +264,33 @@ evas_gl_common_dmabuf_test_image_new(Evas_Engine_GL_Context *gc,
NULL, 1, EVAS_COLORSPACE_ARGB8888);
}
-/* Returns the image that already holds this wl_buffer, if any. When it is
- * not im, it is referenced and im is freed. */
+/* Returns im when it already holds this very surface, NULL when it needs a
+ * new attach. Images are not shared by wl_buffer address: an image can
+ * outlive its wl_buffer, and the next one is often allocated at the same
+ * address. */
EMODAPI Evas_GL_Image *
evas_gl_common_dmabuf_native_lookup(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
const Evas_Native_Surface *ns)
{
- Evas_GL_Image *im2;
- void *key;
+ struct dmabuf_attributes *attr;
+ Native *n;
- if ((!gc) || (!ns)) return NULL;
- key = ns->data.wl_dmabuf.resource;
+ if ((!gc) || (!im) || (!ns)) return NULL;
+ if (im->native.func.free != _dmabuf_native_free_cb) return NULL;
+ n = im->native.data;
+ attr = ns->data.wl_dmabuf.attr;
+ if ((!n) || (!attr)) return NULL;
- im2 = eina_hash_find(gc->shared->native_wl_hash, &key);
- if (!im2) return NULL;
- if (im2 == im) return im;
- if (!im2->native.data) return NULL;
+ if (n->ns.data.wl_dmabuf.resource != ns->data.wl_dmabuf.resource)
+ return NULL;
+ if ((n->ns.data.wl_dmabuf.scanout.handler !=
+ ns->data.wl_dmabuf.scanout.handler) ||
+ (n->ns.data.wl_dmabuf.scanout.data != ns->data.wl_dmabuf.scanout.data))
+ return NULL;
+ if (memcmp(&n->ns_data.wl_surface_dmabuf.attr, attr, sizeof(*attr)))
+ return NULL;
- evas_gl_common_image_ref(im2);
- evas_gl_common_image_free(im);
-
- return im2;
+ return im;
}
/* Returns EINA_FALSE, leaving im untouched, when the attributes cannot be
@@ -302,7 +302,6 @@ evas_gl_common_dmabuf_native_attach(Evas_Engine_GL_Context *gc, Evas_GL_Image *i
{
struct dmabuf_attributes *attr;
Native *n;
- void *key;
if ((!gc) || (!im) || (!ns)) return EINA_FALSE;
attr = ns->data.wl_dmabuf.attr;
@@ -316,9 +315,6 @@ evas_gl_common_dmabuf_native_attach(Evas_Engine_GL_Context *gc, Evas_GL_Image *i
memcpy(&n->ns_data.wl_surface_dmabuf.attr, attr, sizeof(*attr));
n->ns_data.wl_surface_dmabuf.resource = ns->data.wl_dmabuf.resource;
- key = n->ns_data.wl_surface_dmabuf.resource;
- eina_hash_add(gc->shared->native_wl_hash, &key, im);
-
im->native.yinvert = 1;
im->native.loose = 0;
im->native.disp = disp;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.