Mesa (master): st/dri: Remove useless flush front.

Stephane Marchesin marcheu at kemper.freedesktop.org
Wed Jan 18 21:23:13 UTC 2012


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

Author: Stéphane Marchesin <marcheu at chromium.org>
Date:   Wed Jan 18 13:03:56 2012 -0800

st/dri: Remove useless flush front.

In the following scenario:
- CreateContext C1
- MakeCurrent C1
- DestroyContext C1 (does not actually destroy the first context, postponed
 until the next MakeCurrent)
 - CreateContext C2
 - MakeCurrent C2
MakeCurrent will call flush on a half destroyed context, leading to crashes.
Since the other paths (destroy and makecurrent) already flush the context,
there is no need to flush here, so we remove this useless flush front call.

This fixes GPU crashes with Chrome and gallium drivers.

---

 .../state_trackers/dri/common/dri_context.c        |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/dri/common/dri_context.c b/src/gallium/state_trackers/dri/common/dri_context.c
index b47d8d9..52c8f4a 100644
--- a/src/gallium/state_trackers/dri/common/dri_context.c
+++ b/src/gallium/state_trackers/dri/common/dri_context.c
@@ -166,7 +166,7 @@ dri_destroy_context(__DRIcontext * cPriv)
    FREE(ctx->optionCache.values);
 
    /* No particular reason to wait for command completion before
-    * destroying a context, but it is probably worthwhile flushing it
+    * destroying a context, but we flush the context here
     * to avoid having to add code elsewhere to cope with flushing a
     * partially destroyed context.
     */
@@ -188,7 +188,11 @@ dri_unbind_context(__DRIcontext * cPriv)
 
    if (--ctx->bind_count == 0) {
       if (ctx->st == ctx->stapi->get_current(ctx->stapi)) {
-         ctx->st->flush(ctx->st, ST_FLUSH_FRONT, NULL);
+         /* For conformance, unbind is supposed to flush the context.
+          * However, if we do it here we might end up flushing a partially
+          * destroyed context. Instead, we flush in dri_make_current and
+          * in dri_destroy_context which should cover all the cases.
+          */
          stapi->make_current(stapi, NULL, NULL, NULL);
       }
    }
@@ -207,6 +211,7 @@ dri_make_current(__DRIcontext * cPriv,
    struct dri_drawable *read = dri_drawable(driReadPriv);
    struct st_context_iface *old_st = ctx->stapi->get_current(ctx->stapi);
 
+   /* Flush the old context here so we don't have to flush on unbind() */
    if (old_st && old_st != ctx->st)
       old_st->flush(old_st, ST_FLUSH_FRONT, NULL);
 




More information about the mesa-commit mailing list