st/dri: Fix frontbuffer rendering with DRI2
authorJakob Bornecrantz <jakob@vmware.com>
Sat, 22 Aug 2009 01:11:58 +0000 (02:11 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Sat, 22 Aug 2009 01:16:01 +0000 (02:16 +0100)
src/gallium/state_trackers/dri/dri_drawable.c

index 0a952f7b2840ae4b7089866a15b3a7311c481d5b..16dab62ccbca5d7c5bb332dae36380ab4b308fc2 100644 (file)
 
 #include "util/u_memory.h"
 
-static void
-dri_copy_to_front(__DRIdrawablePrivate * dPriv,
-                 struct pipe_surface *from,
-                 int x, int y, unsigned w, unsigned h)
-{
-   /* TODO send a message to the Xserver to copy to the real front buffer */
-}
-
 static struct pipe_surface *
 dri_surface_from_handle(struct drm_api *api,
                        struct pipe_screen *screen,
@@ -159,9 +151,7 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv)
 
       switch (buffers[i].attachment) {
       case __DRI_BUFFER_FRONT_LEFT:
-        index = ST_SURFACE_FRONT_LEFT;
-        format = drawable->color_format;
-        break;
+        continue;
       case __DRI_BUFFER_FAKE_FRONT_LEFT:
         index = ST_SURFACE_FRONT_LEFT;
         format = drawable->color_format;
@@ -233,8 +223,19 @@ dri_flush_frontbuffer(struct pipe_screen *screen,
                      struct pipe_surface *surf, void *context_private)
 {
    struct dri_context *ctx = (struct dri_context *)context_private;
+   struct dri_drawable *drawable = dri_drawable(ctx->dPriv);
+   __DRIdrawable *dri_drawable = ctx->dPriv;
+   __DRIscreen *dri_screen = ctx->sPriv;
 
-   dri_copy_to_front(ctx->dPriv, surf, 0, 0, surf->width, surf->height);
+   /* XXX Does this function get called with DRI1? */
+
+   if (ctx->dPriv == NULL) {
+      debug_printf("%s: no drawable bound to context\n", __func__);
+      return;
+   }
+
+   (*dri_screen->dri2.loader->flushFrontBuffer)(dri_drawable,
+                                               dri_drawable->loaderPrivate);
 }
 
 /**
@@ -312,12 +313,11 @@ dri_create_buffer(__DRIscreenPrivate * sPriv,
    dPriv->driverPrivate = (void *)drawable;
 
    /* setup dri2 buffers information */
+   /* TODO incase of double buffer visual, delay fake creation */
    i = 0;
    drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-#if 0
-   /* TODO incase of double buffer visual, delay fake creation */
    drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT;
-#endif
+
    if (visual->doubleBufferMode)
       drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT;
    if (visual->depthBits)