[Mesa-dev] Problem getting a 32-bit X11 visual when porting from GLX to EGL

Simon Farnsworth simon.farnsworth at onelan.co.uk
Wed Nov 6 07:27:36 PST 2013


Hello all,

I'm attempting to port our GLX based code to EGL/X11, as a first step towards 
being ready for Wayland, and I've hit a snag. We use an X11 compositor to get 
translucent windows blending one atop the other, and I carefully select a 32 
bit RGBA visual (ID 0x64 on my system) instead of a 24 bit RGB visual (IDs 
0x21 and 0x22 on my system) to make this work.

I've got the code working on EGL/X11, but I can't find an EGLConfig that's based 
on visual 0x64 - they're all based on 0x21 (TrueColor) and 0x22 (DirectColor).

Looking at 
http://cgit.freedesktop.org/mesa/mesa/tree/src/egl/drivers/dri2/platform_x11.c#n671 
suggests this is deliberate. I've tried the stupid patch below, but that makes 
all the TrueColor EGLConfigs into the RGBA visual 0x64, which is clearly not 
wanted based on the comment.

How should I proceed here? I can obviously go back to GLX, and migrate to EGL 
when I migrate to Wayland, but I'd prefer to move to EGL now while I'm still 
X11 based.

diff --git a/src/egl/drivers/dri2/platform_x11.c 
b/src/egl/drivers/dri2/platform_x11.c
index a518db1..18fb81d 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -649,6 +649,37 @@ dri2_add_configs_for_visuals(struct dri2_egl_display 
*dri2_dpy,
       EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
 
    while (d.rem > 0) {
+      if (d.data->depth != 32) {
+         xcb_depth_next(&d);
+         continue;
+      }
+      EGLBoolean class_added[6] = { 0, };
+
+      visuals = xcb_depth_visuals(d.data);
+      for (i = 0; i < xcb_depth_visuals_length(d.data); i++) {
+        if (class_added[visuals[i]._class])
+           continue;
+
+        class_added[visuals[i]._class] = EGL_TRUE;
+        for (j = 0; dri2_dpy->driver_configs[j]; j++) {
+            config_attrs[1] = visuals[i].visual_id;
+            config_attrs[3] = visuals[i]._class;
+
+            rgba_masks[0] = visuals[i].red_mask;
+            rgba_masks[1] = visuals[i].green_mask;
+            rgba_masks[2] = visuals[i].blue_mask;
+            rgba_masks[3] =
+               ~(rgba_masks[0] | rgba_masks[1] | rgba_masks[2]);
+           dri2_add_config(disp, dri2_dpy->driver_configs[j], id++,
+                           surface_type, config_attrs, rgba_masks);
+        }
+      }
+
+      xcb_depth_next(&d);
+   }
+
+   d = xcb_screen_allowed_depths_iterator(s.data);
+   while (d.rem > 0) {
       EGLBoolean class_added[6] = { 0, };
 
       visuals = xcb_depth_visuals(d.data);


-- 
Simon Farnsworth
Software Engineer
ONELAN Ltd
http://www.onelan.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131106/9416e144/attachment.pgp>


More information about the mesa-dev mailing list