EGL: creating image from X11 pixmap (sometimes) very slow
obiwac
obiwac at gmail.com
Mon Jan 24 12:33:54 UTC 2022
Hey!
Truly, idk if this is the right sort of place to ask, but it seems to
be the most appropriate (I was redirected here from the dead
dri-egl at lists.freedesktop.org mailing list). Feel free to point me
somewhere else if this isn't where I should be asking this question!
I'm working on an X11 compositor using EGL, and I'm creating an
EGLImage from a native pixmap something like this:
xcb_pixmap_t pixmap = xcb_generate_id(connection);
xcb_void_cookie_t cookie =
xcb_composite_name_window_pixmap_checked(connection, win, pixmap);
if (xcb_request_check(connection, cookie)) {
goto error;
}
EGLImage image = eglCreateImageKHR(egl_display, EGL_NO_CONTEXT,
EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer) (intptr_t) pixmap, NULL);
(Using the EGL_KHR_image_pixmap extension:
https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_image_base.txt)
Which I'm then binding to a texture a little something like this:
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture);
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, image);
(Using the OES_EGL_image_external extension:
https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external.txt)
(Naturally my actual code isn't actually generating a new texture each
time; I'm showing it as such in the interest of simplicity.)
I'm doing it with OES_EGL_image_external because
EGL_BIND_TO_TEXTURE_RGB(A) seems to have been deprecated by NVIDIA
(?): https://forums.developer.nvidia.com/t/egl-bind-to-texture-rgba-attribute-always-false/58676
This isn't reflected in the Khronos EGL registry for whatever reason
so I'm unsure.
Anyway, this all works fine & dandy, except that eglCreateImageKHR is
sometimes *really* slow.
Like, it works fine mostly, but with some windows (especially GLX
windows), there's often times a multi-frame delay.
Since AFAICT image creation can only be done on the main OpenGL
thread, it slows down all the other animations and whatnot of my
compositor, which is very much unideal.
I've tried churning my way through the source code of various
compositors (well, I couldn't really find many which used EGL
specifically, but GLX has a similar problem with glXBindTexImageEXT),
and, aside from the ones which are too opaque for me to understand, I
don't really see how they're doing things much differently.
Obviously however it's something I'm doing wrong/missing, because
those other compositors are perfectly speedy.
I'd be very grateful if somebody could shed a little light on this issue!
Have a wonderful day!
More information about the dri-devel
mailing list