egl_dri2: allow RGBA masks to be specified for matching
authorChia-I Wu <olvaffe@gmail.com>
Fri, 5 Aug 2011 05:36:14 +0000 (14:36 +0900)
committerChia-I Wu <olv@lunarg.com>
Sun, 28 Aug 2011 13:56:22 +0000 (21:56 +0800)
Add rgba_masks to dri2_add_config.  When it is non-NULL, the DRI config
is accepted only when the offsets and sizes of the its channels match
rgba_mask.

Reviewed-by: Chad Versace <chad@chad-versace.us>
src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/egl_dri2.h
src/egl/drivers/dri2/platform_drm.c
src/egl/drivers/dri2/platform_wayland.c
src/egl/drivers/dri2/platform_x11.c

index f09ae14f10c1f26a96c26d6dd9453fd379d23fa9..ba728a1583ba8331ba9c028e66b8496a17ae9162 100644 (file)
@@ -111,13 +111,15 @@ dri2_match_config(const _EGLConfig *conf, const _EGLConfig *criteria)
 
 struct dri2_egl_config *
 dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
-               int depth, EGLint surface_type, const EGLint *attr_list)
+               int depth, EGLint surface_type, const EGLint *attr_list,
+               const unsigned int *rgba_masks)
 {
    struct dri2_egl_config *conf;
    struct dri2_egl_display *dri2_dpy;
    _EGLConfig base;
    unsigned int attrib, value, double_buffer;
    EGLint key, bind_to_texture_rgb, bind_to_texture_rgba;
+   unsigned int dri_masks[4] = { 0, 0, 0, 0 };
    _EGLConfig *matching_config;
    EGLint num_configs = 0;
    EGLint config_id;
@@ -165,6 +167,22 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
         double_buffer = value;
         break;
 
+      case __DRI_ATTRIB_RED_MASK:
+         dri_masks[0] = value;
+         break;
+
+      case __DRI_ATTRIB_GREEN_MASK:
+         dri_masks[1] = value;
+         break;
+
+      case __DRI_ATTRIB_BLUE_MASK:
+         dri_masks[2] = value;
+         break;
+
+      case __DRI_ATTRIB_ALPHA_MASK:
+         dri_masks[3] = value;
+         break;
+
       default:
         key = dri2_to_egl_attribute_map[attrib];
         if (key != 0)
@@ -180,6 +198,9 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
    if (depth > 0 && depth != base.BufferSize)
       return NULL;
 
+   if (rgba_masks && memcmp(rgba_masks, dri_masks, sizeof(dri_masks)))
+      return NULL;
+
    base.NativeRenderable = EGL_TRUE;
 
    base.SurfaceType = surface_type;
index db93eec14ba4c3ed333ba8320f27c99e39e0661f..be272f9bb25c39ee1378f1fbb7429cbd97c1ee5a 100644 (file)
@@ -208,7 +208,8 @@ dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data);
 
 struct dri2_egl_config *
 dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
-               int depth, EGLint surface_type, const EGLint *attr_list);
+               int depth, EGLint surface_type, const EGLint *attr_list,
+               const unsigned int *rgba_masks);
 
 _EGLImage *
 dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
index 04b10e279ec6bb497c0f531e5dcb82c0822d9e28..e2c8dab16bc869b86cd904a633e5afaf8e6ae352 100644 (file)
@@ -150,7 +150,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
 
    for (i = 0; dri2_dpy->driver_configs[i]; i++)
       dri2_add_config(disp, dri2_dpy->driver_configs[i],
-                      i + 1, 0, 0, NULL);
+                      i + 1, 0, 0, NULL, NULL);
 
    drv->API.CreateImageKHR = dri2_drm_create_image_khr;
 
index c4fa126951bca89f44e080e34d3dcf0db20e5804..92657fc6d8acdc1ea00ab1b80026df23470bb186 100644 (file)
@@ -836,7 +836,7 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
 
    for (i = 0; dri2_dpy->driver_configs[i]; i++)
       dri2_add_config(disp, dri2_dpy->driver_configs[i], i + 1, 0,
-                     EGL_WINDOW_BIT | EGL_PIXMAP_BIT, NULL);
+                     EGL_WINDOW_BIT | EGL_PIXMAP_BIT, NULL, NULL);
 
 
    disp->Extensions.KHR_image_pixmap = EGL_TRUE;
index f27bf176fb6de70775ac578af1fcdb68f932cb68..8dd231a7ad59da0006d4782abd003425547841c1 100644 (file)
@@ -642,7 +642,7 @@ dri2_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
             config_attrs[3] = visuals[i]._class;
 
            dri2_add_config(disp, dri2_dpy->driver_configs[j], id++,
-                           d.data->depth, surface_type, config_attrs);
+                           d.data->depth, surface_type, config_attrs, NULL);
         }
       }