[Mesa-users] Mesa 17 Wayland EGL changes

Cédric Legrand legrand.cedric.01 at gmail.com
Mon Feb 13 10:59:01 UTC 2017


Hello,

I'm working on a Wayland compositor and the latest Mesa update broke my
work. After investigating, I found that I need to use the
EGL_WL_wayland_bind_display extension, otherwise my compositor crashes with
wl_shm reporting an invalid format. I'm not an OpenGL expert, but I spent
the last few days reading documentation, inspecting weston's source code
and googling with no luck.

Question 1: Is it necessary to have the extension? Why don't Mesa support
plain old wl_shm anymore? Unless I missed something, this means we can't
use OpenGL anymore for software rendering in Wayland, am I right?


At the moment, I'm trying to load an EGL window before falling back to a
non-opengl rendering mode in case of error. The problem here is that doing
so now crahes the whole compositor, and the only way I see to do this is
checking if the wl_drm interface is provided before trying to create the
window, meaning an other roundtrip.

Question 2: Shouldn't the window creation simply fail if wl_drm is not
available, letting me fallback to another rendering mode?


I implemented the EGL_WL_bind_wayland_display extension, but unfortunately
I am not able to get any output. The client gets the wl_drm interface (so
the display seems to be correctly bound), I am able to get the right buffer
size, but I am not able to get any output, my final drawing stays black. In
case it matters, I'm rendering to a standard X11 window at the moment.

Here is how I set the texture buffer:

bool set_wl_buffer(
    struct gles2_renderer* renderer,
    GLuint texture, // The texture associated to my surface
    struct wl_resource* buffer // The buffer as sent to the surface.attach
request
) {
    // Got with eglGetProcAddress("eglCreateImageKHR")
    EGLImageKHR* img = eglCreateImageKHR(
        renderer->display,
        EGL_NO_CONTEXT,
        EGL_WAYLAND_BUFFER_WL,
        buffer,
        NULL
    );
    if (img == EGL_NO_IMAGE_KHR) {
        return false;
    }

    glBindTexture(GL_TEXTURE_2D, texture);

    // Got with eglGetProcAddress("glEGLImageTargetTexture2DOES")
    eglImageTargetTexture2D(GL_TEXTURE_2D, img);
    return true;
}

I'm creating a texture for the surface once, only updating the buffer at
commit. After this piece of code, I'm rendering the texture as I would with
a "standard" one. The drawing part should work as expected, at least it
does in standard client applications both in Wayland and X11, and did
before the update. Of course, weston is working as expected on my system.

Question 3: Is it correct? Did I miss something?


I tried to give any detail that may be relevant, but if I forgot something,
just ask for it.
Thanks in advance,
Cédric Legrand
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-users/attachments/20170213/b71a5692/attachment.html>


More information about the mesa-users mailing list