[Mesa-dev] [PATCH 2/6] egl_dri2: Remove depth argument from dri2_add_config()

Kristian Høgsberg krh at bitplanet.net
Sun Sep 15 00:16:44 PDT 2013


All callers now use the more correct rgba mask mechanism for filtering
out mathcing DRI configs.  Even if depth and buffer size match, the
color component layout can be different, or in case or ARGB8888 and
ARGB2101010 the color components can even be different sizes.

Since anything that the depth check would reject is also rejected by
the rgba mask comparison, the depth parameter is redundant and not
specific enough.  We should probably have removed it when the rgba
masks argument was introduced, but better late than never.

Signed-off-by: Kristian Høgsberg <krh at bitplanet.net>
---
 src/egl/drivers/dri2/egl_dri2.c         | 12 +-----------
 src/egl/drivers/dri2/egl_dri2.h         |  2 +-
 src/egl/drivers/dri2/platform_android.c | 14 ++++++--------
 src/egl/drivers/dri2/platform_drm.c     |  2 +-
 src/egl/drivers/dri2/platform_wayland.c |  4 ++--
 src/egl/drivers/dri2/platform_x11.c     |  4 ++--
 6 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 04ab564..86cbb20 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -116,7 +116,7 @@ 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,
+		EGLint surface_type, const EGLint *attr_list,
 		const unsigned int *rgba_masks)
 {
    struct dri2_egl_config *conf;
@@ -200,16 +200,6 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
       for (i = 0; attr_list[i] != EGL_NONE; i += 2)
          _eglSetConfigKey(&base, attr_list[i], attr_list[i+1]);
 
-   /* Allow a 24-bit RGB visual to match a 32-bit RGBA EGLConfig.  Otherwise
-    * it will only match a 32-bit RGBA visual.  On a composited window manager
-    * on X11, this will make all of the EGLConfigs with destination alpha get
-    * blended by the compositor.  This is probably not what the application
-    * wants... especially on drivers that only have 32-bit RGBA EGLConfigs!
-    */
-   if (depth > 0 && depth != base.BufferSize
-       && !(depth == 24 && base.BufferSize == 32))
-      return NULL;
-
    if (rgba_masks && memcmp(rgba_masks, dri_masks, sizeof(dri_masks)))
       return NULL;
 
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index fba5f81..4a39efb 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -246,7 +246,7 @@ 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,
+		EGLint surface_type, const EGLint *attr_list,
 		const unsigned int *rgba_masks);
 
 _EGLImage *
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index ff41e83..2c20de7 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -547,14 +547,13 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
    const struct {
       int format;
-      int size;
       unsigned int rgba_masks[4];
    } visuals[] = {
-      { HAL_PIXEL_FORMAT_RGBA_8888, 32, { 0xff, 0xff00, 0xff0000, 0xff000000 } },
-      { HAL_PIXEL_FORMAT_RGBX_8888, 32, { 0xff, 0xff00, 0xff0000, 0x0 } },
-      { HAL_PIXEL_FORMAT_RGB_888,   24, { 0xff, 0xff00, 0xff0000, 0x0 } },
-      { HAL_PIXEL_FORMAT_RGB_565,   16, { 0xf800, 0x7e0, 0x1f, 0x0 } },
-      { HAL_PIXEL_FORMAT_BGRA_8888, 32, { 0xff0000, 0xff00, 0xff, 0xff000000 } },
+      { HAL_PIXEL_FORMAT_RGBA_8888, { 0xff, 0xff00, 0xff0000, 0xff000000 } },
+      { HAL_PIXEL_FORMAT_RGBX_8888, { 0xff, 0xff00, 0xff0000, 0x0 } },
+      { HAL_PIXEL_FORMAT_RGB_888,   { 0xff, 0xff00, 0xff0000, 0x0 } },
+      { HAL_PIXEL_FORMAT_RGB_565,   { 0xf800, 0x7e0, 0x1f, 0x0 } },
+      { HAL_PIXEL_FORMAT_BGRA_8888, { 0xff0000, 0xff00, 0xff, 0xff000000 } },
       { 0, 0, { 0, 0, 0, 0 } }
    };
    int count, i, j;
@@ -576,8 +575,7 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
             continue;
 
          dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[j],
-               count + 1, visuals[i].size, surface_type, NULL,
-               visuals[i].rgba_masks);
+               count + 1, surface_type, NULL, visuals[i].rgba_masks);
          if (dri2_conf) {
             dri2_conf->base.NativeVisualID = visuals[i].format;
             dri2_conf->base.NativeVisualType = visuals[i].format;
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 615648b..fb28bd9 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -478,7 +478,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, EGL_WINDOW_BIT, NULL, NULL);
+                      i + 1, EGL_WINDOW_BIT, NULL, NULL);
 
    drv->API.CreateWindowSurface = dri2_create_window_surface;
    drv->API.DestroySurface = dri2_destroy_surface;
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 1d417bb..6c33bba 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -814,9 +814,9 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
    for (i = 0; dri2_dpy->driver_configs[i]; i++) {
       config = dri2_dpy->driver_configs[i];
       if (dri2_dpy->formats & HAS_XRGB8888)
-	 dri2_add_config(disp, config, i + 1, 0, types, NULL, rgb_masks);
+	 dri2_add_config(disp, config, i + 1, types, NULL, rgb_masks);
       if (dri2_dpy->formats & HAS_ARGB8888)
-	 dri2_add_config(disp, config, i + 1, 0, types, NULL, argb_masks);
+	 dri2_add_config(disp, config, i + 1, types, NULL, argb_masks);
    }
 
    disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index d1ceb62..a518db1 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -666,7 +666,7 @@ dri2_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
             rgba_masks[2] = visuals[i].blue_mask;
             rgba_masks[3] = 0;
 	    dri2_add_config(disp, dri2_dpy->driver_configs[j], id++,
-			    0, surface_type, config_attrs, rgba_masks);
+			    surface_type, config_attrs, rgba_masks);
 
             /* Allow a 24-bit RGB visual to match a 32-bit RGBA EGLConfig.
              * Otherwise it will only match a 32-bit RGBA visual.  On a
@@ -679,7 +679,7 @@ dri2_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
                rgba_masks[3] =
                   ~(rgba_masks[0] | rgba_masks[1] | rgba_masks[2]);
                dri2_add_config(disp, dri2_dpy->driver_configs[j], id++,
-                               0, surface_type, config_attrs, rgba_masks);
+                               surface_type, config_attrs, rgba_masks);
             }
 	 }
       }
-- 
1.8.3.1



More information about the mesa-dev mailing list