From c20032435dfd46a35cbb0a890a5b703789ea90f2 Mon Sep 17 00:00:00 2001 From: vasilito Date: Mon, 27 Jul 2026 09:59:59 +0900 Subject: [PATCH] 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. --- .../libs/mesa/source/src/egl/drivers/dri2/egl_dri2.h | 1 + .../source/src/egl/drivers/dri2/platform_redox.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/local/recipes/libs/mesa/source/src/egl/drivers/dri2/egl_dri2.h b/local/recipes/libs/mesa/source/src/egl/drivers/dri2/egl_dri2.h index 4d6df947d4..b075a65073 100644 --- a/local/recipes/libs/mesa/source/src/egl/drivers/dri2/egl_dri2.h +++ b/local/recipes/libs/mesa/source/src/egl/drivers/dri2/egl_dri2.h @@ -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; diff --git a/local/recipes/libs/mesa/source/src/egl/drivers/dri2/platform_redox.c b/local/recipes/libs/mesa/source/src/egl/drivers/dri2/platform_redox.c index 27298c157d..67b8c3543a 100644 --- a/local/recipes/libs/mesa/source/src/egl/drivers/dri2/platform_redox.c +++ b/local/recipes/libs/mesa/source/src/egl/drivers/dri2/platform_redox.c @@ -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; }