st/dri: Find out if the drawable is a pixmap
authorJakob Bornecrantz <jakob@vmware.com>
Sat, 22 Aug 2009 01:12:21 +0000 (02:12 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Sat, 22 Aug 2009 01:16:02 +0000 (02:16 +0100)
Part of this code is disabled since no performance gains
where detected with it enabled.

This code only detects if it is a pixmap that it is
rendering to on the st/xorg DDX since it sets the fake
front to the same handle as front.

src/gallium/state_trackers/dri/dri_drawable.c
src/gallium/state_trackers/dri/dri_drawable.h

index 16dab62ccbca5d7c5bb332dae36380ab4b308fc2..2d5510a6fc83629a4c556c224d8b6f4d57ffd320 100644 (file)
@@ -87,6 +87,35 @@ dri_surface_from_handle(struct drm_api *api,
    return surface;
 }
 
+/**
+ * Pixmaps have will have the same name of fake front and front.
+ */
+static boolean
+dri2_check_if_pixmap(__DRIbuffer *buffers, int count)
+{
+   boolean found = FALSE;
+   boolean is_pixmap = FALSE;
+   unsigned name;
+   int i;
+
+   for (i = 0; i < count; i++) {
+      switch (buffers[i].attachment) {
+      case __DRI_BUFFER_FRONT_LEFT:
+      case __DRI_BUFFER_FAKE_FRONT_LEFT:
+         if (found) {
+            is_pixmap = buffers[i].name == name;
+         } else {
+            name = buffers[i].name;
+            found = TRUE;
+         }
+      default:
+        continue;
+      }
+   }
+
+   return is_pixmap;
+}
+
 /**
  * This will be called a drawable is known to have been resized.
  */
@@ -145,6 +174,8 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv)
       memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count);
    }
 
+   drawable->is_pixmap = dri2_check_if_pixmap(buffers, count);
+
    for (i = 0; i < count; i++) {
       enum pipe_format format = 0;
       int index = 0;
@@ -234,6 +265,12 @@ dri_flush_frontbuffer(struct pipe_screen *screen,
       return;
    }
 
+#if 0
+   /* TODO if rendering to pixmaps is slow enable this code. */
+   if (drawable->is_pixmap)
+      return;
+#endif
+
    (*dri_screen->dri2.loader->flushFrontBuffer)(dri_drawable,
                                                dri_drawable->loaderPrivate);
 }
index dfd0b8766d2206edc3795408fba899f1e94a2b45..eaf0b954bd48ab9264b3597d7ea98c3e0f356f64 100644 (file)
@@ -46,6 +46,8 @@ struct dri_drawable
    unsigned attachments[8];
    unsigned num_attachments;
 
+   boolean is_pixmap;
+
    __DRIbuffer old[8];
    unsigned old_num;
    unsigned old_w;