Module: Mesa
Branch: master
Commit: 4f0563a6584dd83462d5cf35a7a1ebc4a4d6378f
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f0563a6584dd83462d5cf35a7a1ebc4a4d6378f

Author: Marek Olšák <[email protected]>
Date:   Mon Jan 21 16:19:41 2013 +0100

st/dri: disallow recursion in dri_flush

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 <[email protected]>
Tested-by: Michel Dänzer <[email protected]>

---

 .../state_trackers/dri/common/dri_drawable.c       |   13 ++++++++++++-
 .../state_trackers/dri/common/dri_drawable.h       |    1 +
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c 
b/src/gallium/state_trackers/dri/common/dri_drawable.c
index d817a8c..87ab764 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.c
@@ -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;
+   }
 }
 
 /**
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.h 
b/src/gallium/state_trackers/dri/common/dri_drawable.h
index caa1faa..56f8a40 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.h
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.h
@@ -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;

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to