st/dri: Don't request a fake front if the server adds one automatically.
authorThomas Hellstrom <thellstrom@vmware.com>
Mon, 18 Jan 2010 12:33:08 +0000 (13:33 +0100)
committerThomas Hellstrom <thellstrom@vmware.com>
Mon, 18 Jan 2010 12:39:25 +0000 (13:39 +0100)
We use the presence of the getBuffersWithFormat extension function to
detect whether the server automatically adds a front.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
src/gallium/state_trackers/dri/dri_drawable.c
src/gallium/state_trackers/dri/dri_screen.c
src/gallium/state_trackers/dri/dri_screen.h

index 3c17ccde0abad34d8971c072d22f6a729da93fe9..0a8c1cd36184cf59d0ce80ed810e409f15ce53b2 100644 (file)
@@ -123,11 +123,12 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv)
 
    struct dri_drawable *drawable = dri_drawable(dPriv);
    struct pipe_surface *surface = NULL;
-   struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen;
+   struct dri_screen *st_screen = dri_screen(drawable->sPriv);
+   struct pipe_screen *screen = st_screen->pipe_screen;
    __DRIbuffer *buffers = NULL;
    __DRIscreen *dri_screen = drawable->sPriv;
    __DRIdrawable *dri_drawable = drawable->dPriv;
-   struct drm_api *api = ((struct dri_screen*)(dri_screen->private))->api;
+   struct drm_api *api = st_screen->api;
    boolean have_depth = FALSE;
    int i, count;
 
@@ -180,7 +181,8 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv)
 
       switch (buffers[i].attachment) {
       case __DRI_BUFFER_FRONT_LEFT:
-        continue;
+        if (!st_screen->auto_fake_front)
+           continue;
       case __DRI_BUFFER_FAKE_FRONT_LEFT:
         index = ST_SURFACE_FRONT_LEFT;
         format = drawable->color_format;
@@ -365,8 +367,8 @@ dri_create_buffer(__DRIscreenPrivate * sPriv,
    /* TODO incase of double buffer visual, delay fake creation */
    i = 0;
    drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-   drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT;
-
+   if (!screen->auto_fake_front)
+      drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT;
    if (visual->doubleBufferMode)
       drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT;
    if (visual->depthBits && visual->stencilBits)
index cb864d45d51a6895d1f316d2d4a02695b6da5cdb..11ea28bcbe8312e74031fcca3c73318f9b75c38a 100644 (file)
@@ -289,6 +289,8 @@ dri_init_screen2(__DRIscreenPrivate * sPriv)
 {
    struct dri_screen *screen;
    struct drm_create_screen_arg arg;
+   const __DRIdri2LoaderExtension *dri2_ext =
+     sPriv->dri2.loader;
 
    screen = CALLOC_STRUCT(dri_screen);
    if (!screen)
@@ -313,6 +315,9 @@ dri_init_screen2(__DRIscreenPrivate * sPriv)
    driParseOptionInfo(&screen->optionCache,
                      __driConfigOptions, __driNConfigOptions);
 
+   screen->auto_fake_front = dri2_ext->base.version >= 3 &&
+      dri2_ext->getBuffersWithFormat != NULL;
+
    return dri_fill_in_modes(screen, 32);
  fail:
    return NULL;
index f6c56d0f0c5ccfeaccc624a10ba3febb2fe5367d..10319f808b7fd55117d08ea05fb4ef38eee6fe02 100644 (file)
@@ -59,6 +59,7 @@ struct dri_screen
    struct pipe_screen *pipe_screen;
    boolean d_depth_bits_last;
    boolean sd_depth_bits_last;
+   boolean auto_fake_front;
 };
 
 /** cast wrapper */