zink: improve threadsafe qbo access
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 2 Aug 2021 16:01:54 +0000 (12:01 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 27 Aug 2021 14:26:50 +0000 (14:26 +0000)
these should be staging resources since they're being read from often,
and this allows dropping the UNSYNCHRONIZED flag from map since it should
be inferred

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12578>

src/gallium/drivers/zink/zink_query.c

index 8f9b123..5010517 100644 (file)
@@ -205,7 +205,7 @@ qbo_append(struct pipe_screen *screen, struct zink_query *query)
    if (!qbo)
       return false;
    qbo->buffer = pipe_buffer_create(screen, PIPE_BIND_QUERY_BUFFER,
-                                  PIPE_USAGE_STREAM,
+                                  PIPE_USAGE_STAGING,
                                   /* this is the maximum possible size of the results in a given buffer */
                                   NUM_QUERIES * get_num_results(query->type) * sizeof(uint64_t));
    if (!qbo->buffer)
@@ -213,7 +213,7 @@ qbo_append(struct pipe_screen *screen, struct zink_query *query)
    if (query->type == PIPE_QUERY_PRIMITIVES_GENERATED) {
       /* need separate xfb buffer */
       qbo->xfb_buffers[0] = pipe_buffer_create(screen, PIPE_BIND_QUERY_BUFFER,
-                                     PIPE_USAGE_STREAM,
+                                     PIPE_USAGE_STAGING,
                                      /* this is the maximum possible size of the results in a given buffer */
                                      NUM_QUERIES * get_num_results(query->type) * sizeof(uint64_t));
       if (!qbo->xfb_buffers[0])
@@ -223,7 +223,7 @@ qbo_append(struct pipe_screen *screen, struct zink_query *query)
       for (unsigned i = 0; i < ARRAY_SIZE(qbo->xfb_buffers); i++) {
          /* need separate xfb buffer */
          qbo->xfb_buffers[i] = pipe_buffer_create(screen, PIPE_BIND_QUERY_BUFFER,
-                                        PIPE_USAGE_STREAM,
+                                        PIPE_USAGE_STAGING,
                                         /* this is the maximum possible size of the results in a given buffer */
                                         NUM_QUERIES * get_num_results(query->type) * sizeof(uint64_t));
          if (!qbo->xfb_buffers[i])
@@ -441,7 +441,7 @@ get_query_result(struct pipe_context *pctx,
       flags |= PIPE_MAP_DONTBLOCK;
    if (query->base.flushed)
       /* this is not a context-safe operation; ensure map doesn't use slab alloc */
-      flags |= PIPE_MAP_THREAD_SAFE | PIPE_MAP_UNSYNCHRONIZED;
+      flags |= PIPE_MAP_THREAD_SAFE;
 
    util_query_clear_result(result, query->type);