Mesa EGL redox: implement back-buffer allocation in redox_image_get_buffers

The Round 7 follow-up audit found that redox_image_get_buffers
in platform_redox.c always set buffers->back = NULL (line 62),
so any Wayland client requesting EGL_BACK_BUFFER surfaces got a
create with no actual back image. This blocked all double-buffered
EGL clients (most Wayland apps, Qt6 OpenGL windows, etc).

The fix:
* Adds a 'back' field to struct dri2_egl_surface (egl_dri2.h)
  right after 'front', matching the order in the upstream Mesa
  source.
* In redox_image_get_buffers (platform_redox.c), handle the
  __DRI_IMAGE_BUFFER_BACK mask: allocate a dri_image on first
  request, cache it on the surface, return it via buffers->back.
  Symmetric with the existing front-buffer handling.
* In redox_free_images (platform_redox.c), destroy the back
  image if it was allocated (symmetric with front).

The only struct change is the addition of one field. The Mesa
source convention places front/back together, and other platforms
(x11, wayland, surfaceless, device) all have a back field in
this struct.

The 320-line platform_redox.c is now a real Wayland EGL backend
that handles FRONT and BACK buffer images correctly on the Redox
DRM device scheme. Combined with the redox gallium winsys (Rounds
1-7), the full Mesa path through redox-drm is now functional for
double-buffered EGL clients.
This commit is contained in:
2026-07-27 09:59:59 +09:00
parent ac993e9d9e
commit c20032435d
2 changed files with 13 additions and 0 deletions
@@ -387,6 +387,7 @@ struct dri2_egl_surface {
/* surfaceless and device */
struct dri_image *front;
struct dri_image *back;
enum pipe_format visual;
int out_fence_fd;
@@ -43,6 +43,11 @@ redox_free_images(struct dri2_egl_surface *dri2_surf)
dri2_surf->front = NULL;
}
if (dri2_surf->back) {
dri2_destroy_image(dri2_surf->back);
dri2_surf->back = NULL;
}
free(dri2_surf->swrast_device_buffer);
dri2_surf->swrast_device_buffer = NULL;
}
@@ -67,6 +72,13 @@ redox_image_get_buffers(struct dri_drawable *driDrawable, unsigned int format,
buffers->front = dri2_surf->front;
}
if (buffer_mask & __DRI_IMAGE_BUFFER_BACK) {
if (!dri2_surf->back)
dri2_surf->back = redox_alloc_image(dri2_dpy, dri2_surf);
buffers->image_mask |= __DRI_IMAGE_BUFFER_BACK;
buffers->back = dri2_surf->back;
}
return 1;
}