[Mesa-dev] [PATCH 10/13] gallium/radeon: subclass and handle threaded_query

Marek Olšák maraeo at gmail.com
Wed May 10 22:45:43 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/drivers/radeon/r600_query.c | 14 ++++++++++----
 src/gallium/drivers/radeon/r600_query.h |  5 ++---
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c
index cbf4bba..dac9b9c 100644
--- a/src/gallium/drivers/radeon/r600_query.c
+++ b/src/gallium/drivers/radeon/r600_query.c
@@ -347,21 +347,23 @@ static bool r600_query_sw_get_result(struct r600_common_context *rctx,
 
 	switch (query->b.type) {
 	case PIPE_QUERY_TIMESTAMP_DISJOINT:
 		/* Convert from cycles per millisecond to cycles per second (Hz). */
 		result->timestamp_disjoint.frequency =
 			(uint64_t)rctx->screen->info.clock_crystal_freq * 1000;
 		result->timestamp_disjoint.disjoint = false;
 		return true;
 	case PIPE_QUERY_GPU_FINISHED: {
 		struct pipe_screen *screen = rctx->b.screen;
-		result->b = screen->fence_finish(screen, &rctx->b, query->fence,
+		struct pipe_context *ctx = rquery->b.flushed ? NULL : &rctx->b;
+
+		result->b = screen->fence_finish(screen, ctx, query->fence,
 						 wait ? PIPE_TIMEOUT_INFINITE : 0);
 		return result->b;
 	}
 
 	case R600_QUERY_CS_THREAD_BUSY:
 		result->u64 = (query->end_result - query->begin_result) * 100 /
 			      (query->end_time - query->begin_time);
 		return true;
 	case R600_QUERY_GPIN_ASIC_ID:
 		result->u32 = 0;
@@ -1205,26 +1207,30 @@ bool r600_query_hw_get_result(struct r600_common_context *rctx,
 			      struct r600_query *rquery,
 			      bool wait, union pipe_query_result *result)
 {
 	struct r600_common_screen *rscreen = rctx->screen;
 	struct r600_query_hw *query = (struct r600_query_hw *)rquery;
 	struct r600_query_buffer *qbuf;
 
 	query->ops->clear_result(query, result);
 
 	for (qbuf = &query->buffer; qbuf; qbuf = qbuf->previous) {
+		unsigned usage = PIPE_TRANSFER_READ |
+				 (wait ? 0 : PIPE_TRANSFER_DONTBLOCK);
 		unsigned results_base = 0;
 		void *map;
 
-		map = r600_buffer_map_sync_with_rings(rctx, qbuf->buf,
-						      PIPE_TRANSFER_READ |
-						      (wait ? 0 : PIPE_TRANSFER_DONTBLOCK));
+		if (rquery->b.flushed)
+			map = rctx->ws->buffer_map(qbuf->buf->buf, NULL, usage);
+		else
+			map = r600_buffer_map_sync_with_rings(rctx, qbuf->buf, usage);
+
 		if (!map)
 			return false;
 
 		while (results_base != qbuf->results_end) {
 			query->ops->add_result(rscreen, query, map + results_base,
 					       result);
 			results_base += query->result_size;
 		}
 	}
 
diff --git a/src/gallium/drivers/radeon/r600_query.h b/src/gallium/drivers/radeon/r600_query.h
index 05aceb7..485bb61 100644
--- a/src/gallium/drivers/radeon/r600_query.h
+++ b/src/gallium/drivers/radeon/r600_query.h
@@ -21,23 +21,21 @@
  * SOFTWARE.
  *
  * Authors:
  *  Nicolai Hähnle <nicolai.haehnle at amd.com>
  *
  */
 
 #ifndef R600_QUERY_H
 #define R600_QUERY_H
 
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-#include "util/list.h"
+#include "util/u_threaded_context.h"
 
 struct pipe_context;
 struct pipe_query;
 struct pipe_resource;
 
 struct r600_common_context;
 struct r600_common_screen;
 struct r600_query;
 struct r600_query_hw;
 struct r600_resource;
@@ -122,20 +120,21 @@ struct r600_query_ops {
 			   union pipe_query_result *result);
 	void (*get_result_resource)(struct r600_common_context *,
 				    struct r600_query *, bool wait,
 				    enum pipe_query_value_type result_type,
 				    int index,
 				    struct pipe_resource *resource,
 				    unsigned offset);
 };
 
 struct r600_query {
+	struct threaded_query b;
 	struct r600_query_ops *ops;
 
 	/* The type of query */
 	unsigned type;
 };
 
 enum {
 	R600_QUERY_HW_FLAG_NO_START = (1 << 0),
 	/* gap */
 	/* whether begin_query doesn't clear the result */
-- 
2.7.4



More information about the mesa-dev mailing list