st/dri: disallow recursion in dri_flush
authorMarek Olšák <maraeo@gmail.com>
Mon, 21 Jan 2013 15:19:41 +0000 (16:19 +0100)
committerMarek Olšák <maraeo@gmail.com>
Thu, 24 Jan 2013 17:22:14 +0000 (18:22 +0100)
ST_FLUSH_FRONT may call driThrottle, which is implemented with dri_flush.
This prevents double flush as well as fence leaks caused by a recursion
in the middle of throttling.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58839

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/state_trackers/dri/common/dri_drawable.c
src/gallium/state_trackers/dri/common/dri_drawable.h

index d817a8c217898d39b230101f1978e21cc099af62..87ab76467c775f85b8a55d6c7dffad7c3b901519 100644 (file)
@@ -423,7 +423,14 @@ dri_flush(__DRIcontext *cPriv,
       return;
    }
 
-   if (!drawable) {
+   if (drawable) {
+      /* prevent recursion */
+      if (drawable->flushing)
+         return;
+
+      drawable->flushing = TRUE;
+   }
+   else {
       flags &= ~__DRI2_FLUSH_DRAWABLE;
    }
 
@@ -478,6 +485,10 @@ dri_flush(__DRIcontext *cPriv,
    else if (flags & (__DRI2_FLUSH_DRAWABLE | __DRI2_FLUSH_CONTEXT)) {
       ctx->st->flush(ctx->st, flush_flags, NULL);
    }
+
+   if (drawable) {
+      drawable->flushing = FALSE;
+   }
 }
 
 /**
index caa1faa08f4e19f79c582606b8173f647cc297de..56f8a4073a3d34d12620fb52ed63a8c010522647 100644 (file)
@@ -65,6 +65,7 @@ struct dri_drawable
    unsigned int head;
    unsigned int tail;
    unsigned int desired_fences;
+   boolean flushing; /* prevents recursion in dri_flush */
 
    /* used only by DRISW */
    struct pipe_surface *drisw_surface;