st/dri: Only create new textures if drawable has changed
authorJakob Bornecrantz <jakob@vmware.com>
Mon, 18 May 2009 01:50:15 +0000 (02:50 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Mon, 18 May 2009 19:54:09 +0000 (20:54 +0100)
src/gallium/state_trackers/dri/dri_drawable.c
src/gallium/state_trackers/dri/dri_drawable.h

index 15a2088df5105410f5a12c8902ef71fef3035279..865cc8d0b6c8acdd367046cb3e07c6b628db48c9 100644 (file)
@@ -138,6 +138,18 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv)
    dri_drawable->pBackClipRects[0].x2 = dri_drawable->w;
    dri_drawable->pBackClipRects[0].y2 = dri_drawable->h;
 
+   if (drawable->old_num == count &&
+       drawable->old_w == dri_drawable->w &&
+       drawable->old_h == dri_drawable->h &&
+       memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0) {
+       return;
+   } else {
+      drawable->old_num = count;
+      drawable->old_w = dri_drawable->w;
+      drawable->old_h = dri_drawable->h;
+      memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count);
+   }
+
    for (i = 0; i < count; i++) {
       enum pipe_format format = 0;
       int index = 0;
index 78a66624aaf2a711b22374020af5f3a0473e41ed..0f654d804a7dceb4582c757bd636a2e2df647aee 100644 (file)
@@ -46,6 +46,11 @@ struct dri_drawable
    unsigned attachments[8];
    unsigned num_attachments;
 
+   __DRIbuffer old[8];
+   unsigned old_num;
+   unsigned old_w;
+   unsigned old_h;
+
    /* gallium */
    struct st_framebuffer *stfb;
    struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX];