[Mesa-dev] [PATCH v2 09/26] gallium/u_threaded: mark queries flushed only for non-deferred flushes

Nicolai Hähnle nhaehnle at gmail.com
Mon Nov 6 10:23:40 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

The driver uses (and must use) the flushed flag of queries as a hint that
it does not have to check for synchronization with currently queued up
commands. Deferred flushes do not actually flush queued up commands, so
we must not set the flushed flag for them.

Found by inspection.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
---
 src/gallium/auxiliary/util/u_threaded_context.c | 8 +++++---
 src/gallium/auxiliary/util/u_threaded_context.h | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index 7e28b87a7ff..24fab7f5cb6 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -1783,23 +1783,25 @@ tc_create_video_buffer(struct pipe_context *_pipe,
  */
 
 static void
 tc_flush(struct pipe_context *_pipe, struct pipe_fence_handle **fence,
          unsigned flags)
 {
    struct threaded_context *tc = threaded_context(_pipe);
    struct pipe_context *pipe = tc->pipe;
    struct threaded_query *tq, *tmp;
 
-   LIST_FOR_EACH_ENTRY_SAFE(tq, tmp, &tc->unflushed_queries, head_unflushed) {
-      tq->flushed = true;
-      LIST_DEL(&tq->head_unflushed);
+   if (!(flags & PIPE_FLUSH_DEFERRED)) {
+      LIST_FOR_EACH_ENTRY_SAFE(tq, tmp, &tc->unflushed_queries, head_unflushed) {
+         tq->flushed = true;
+         LIST_DEL(&tq->head_unflushed);
+      }
    }
 
    /* TODO: deferred flushes? */
    tc_sync_msg(tc, flags & PIPE_FLUSH_END_OF_FRAME ? "end of frame" :
                    flags & PIPE_FLUSH_DEFERRED ? "deferred fence" : "normal");
    pipe->flush(pipe, fence, flags);
 }
 
 /* This is actually variable-sized, because indirect isn't allocated if it's
  * not needed. */
diff --git a/src/gallium/auxiliary/util/u_threaded_context.h b/src/gallium/auxiliary/util/u_threaded_context.h
index 8977b03cd20..57805ee4a1e 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.h
+++ b/src/gallium/auxiliary/util/u_threaded_context.h
@@ -251,21 +251,21 @@ struct threaded_transfer {
 
    /* Offset into the staging buffer, because the backing buffer is
     * sub-allocated. */
    unsigned offset;
 };
 
 struct threaded_query {
    /* The query is added to the list in end_query and removed in flush. */
    struct list_head head_unflushed;
 
-   /* Whether pipe->flush has been called after end_query. */
+   /* Whether pipe->flush has been called in non-deferred mode after end_query. */
    bool flushed;
 };
 
 /* This is the second half of tc_call containing call data.
  * Most calls will typecast this to the type they need, typically larger
  * than 8 bytes.
  */
 union tc_payload {
    struct pipe_query *query;
    struct pipe_resource *resource;
-- 
2.11.0



More information about the mesa-dev mailing list