Skip to content

cogl: Rebind the EGL image when handling damage

Neil Roberts requested to merge bpeel/mutter:egl-rebind-image into main

When Cogl gained support for importing pixmaps, I think there was a misunderstanding that there is a difference in how it works in GLX and EGL where GLX needs to rebind the pixmap in order to guarantee that changes are reflected in the texture after it detects damage, whereas with EGL it doesn’t. The GLX spec makes it pretty clear that it does need to rebind whereas the EGL spec is a bit harder to follow. As a fallout from Mesa MR 12869, it seems like the compositor really does need to rebind the image to comply with the spec. Notably, in OES_EGL_image_external there is:

Binding (or re-binding if already bound) an external texture by calling BindTexture after all modifications are complete guarantees that sampling done in future draw calls will return values corresponding to the values in the buffer at or after the time that BindTexture is called.

So this commit changes the x11_damage_notify handler for EGL to lazily queue a rebind like GLX does. The code that binds the image while allocating the texture has been moved into a reusable helper function.

It seems like there is a bit of a layering violation when accessing the GL driver internals from the EGL winsys code, but I noticed that the GLX code also includes the driver GL headers and otherwise it seems pretty tricky to do properly.

Merge request reports