Mesa (master): gallium/u_threaded: offload begin/end_intel_perf_query
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 22 11:29:01 UTC 2021
Module: Mesa
Branch: master
Commit: 59bbf885e97ab1cc17446ff6a46c4cda501cfd46
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=59bbf885e97ab1cc17446ff6a46c4cda501cfd46
Author: Marcin Ślusarz <marcin.slusarz at intel.com>
Date: Fri Apr 16 19:07:15 2021 +0200
gallium/u_threaded: offload begin/end_intel_perf_query
Fixes: 206495cac4e ("iris: Enable u_threaded_context")
Signed-off-by: Marcin Ślusarz <marcin.slusarz at intel.com>
Acked-by: Marek Olšák <marek.olsak at amd.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9922>
---
src/gallium/auxiliary/util/u_threaded_context.c | 36 ++++++++++++++--------
.../auxiliary/util/u_threaded_context_calls.h | 3 ++
src/gallium/drivers/iris/iris_performance_query.c | 21 +++++++++----
src/gallium/include/pipe/p_context.h | 2 +-
src/mesa/drivers/dri/i965/brw_performance_query.c | 4 ++-
src/mesa/main/dd.h | 2 +-
src/mesa/main/performance_query.c | 11 +++++--
src/mesa/state_tracker/st_cb_perfquery.c | 6 ++--
8 files changed, 59 insertions(+), 26 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index c2236b5a3ae..02da0160f52 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -2997,6 +2997,7 @@ tc_get_intel_perf_query_info(struct pipe_context *_pipe,
struct threaded_context *tc = threaded_context(_pipe);
struct pipe_context *pipe = tc->pipe;
+ tc_sync(tc); /* n_active vs begin/end_intel_perf_query */
pipe->get_intel_perf_query_info(pipe, query_index, name, data_size,
n_counters, n_active);
}
@@ -3029,24 +3030,35 @@ tc_new_intel_perf_query_obj(struct pipe_context *_pipe, unsigned query_index)
return pipe->new_intel_perf_query_obj(pipe, query_index);
}
+static void
+tc_call_begin_intel_perf_query(struct pipe_context *pipe, union tc_payload *payload)
+{
+ (void)pipe->begin_intel_perf_query(pipe, payload->query);
+}
+
static bool
tc_begin_intel_perf_query(struct pipe_context *_pipe, struct pipe_query *q)
{
struct threaded_context *tc = threaded_context(_pipe);
- struct pipe_context *pipe = tc->pipe;
- tc_sync(tc);
- return pipe->begin_intel_perf_query(pipe, q);
+ tc_add_small_call(tc, TC_CALL_begin_intel_perf_query)->query = q;
+
+ /* assume success, begin failure can be signaled from get_intel_perf_query_data */
+ return true;
+}
+
+static void
+tc_call_end_intel_perf_query(struct pipe_context *pipe, union tc_payload *payload)
+{
+ pipe->end_intel_perf_query(pipe, payload->query);
}
static void
tc_end_intel_perf_query(struct pipe_context *_pipe, struct pipe_query *q)
{
struct threaded_context *tc = threaded_context(_pipe);
- struct pipe_context *pipe = tc->pipe;
- tc_sync(tc);
- pipe->end_intel_perf_query(pipe, q);
+ tc_add_small_call(tc, TC_CALL_end_intel_perf_query)->query = q;
}
static void
@@ -3055,7 +3067,7 @@ tc_delete_intel_perf_query(struct pipe_context *_pipe, struct pipe_query *q)
struct threaded_context *tc = threaded_context(_pipe);
struct pipe_context *pipe = tc->pipe;
- tc_sync(tc);
+ tc_sync(tc); /* flush potentially pending begin/end_intel_perf_queries */
pipe->delete_intel_perf_query(pipe, q);
}
@@ -3065,7 +3077,7 @@ tc_wait_intel_perf_query(struct pipe_context *_pipe, struct pipe_query *q)
struct threaded_context *tc = threaded_context(_pipe);
struct pipe_context *pipe = tc->pipe;
- tc_sync(tc);
+ tc_sync(tc); /* flush potentially pending begin/end_intel_perf_queries */
pipe->wait_intel_perf_query(pipe, q);
}
@@ -3075,11 +3087,11 @@ tc_is_intel_perf_query_ready(struct pipe_context *_pipe, struct pipe_query *q)
struct threaded_context *tc = threaded_context(_pipe);
struct pipe_context *pipe = tc->pipe;
- tc_sync(tc);
+ tc_sync(tc); /* flush potentially pending begin/end_intel_perf_queries */
return pipe->is_intel_perf_query_ready(pipe, q);
}
-static void
+static bool
tc_get_intel_perf_query_data(struct pipe_context *_pipe,
struct pipe_query *q,
size_t data_size,
@@ -3089,8 +3101,8 @@ tc_get_intel_perf_query_data(struct pipe_context *_pipe,
struct threaded_context *tc = threaded_context(_pipe);
struct pipe_context *pipe = tc->pipe;
- tc_sync(tc);
- pipe->get_intel_perf_query_data(pipe, q, data_size, data, bytes_written);
+ tc_sync(tc); /* flush potentially pending begin/end_intel_perf_queries */
+ return pipe->get_intel_perf_query_data(pipe, q, data_size, data, bytes_written);
}
/********************************************************************
diff --git a/src/gallium/auxiliary/util/u_threaded_context_calls.h b/src/gallium/auxiliary/util/u_threaded_context_calls.h
index 062cdb3aae6..f1607edb4fa 100644
--- a/src/gallium/auxiliary/util/u_threaded_context_calls.h
+++ b/src/gallium/auxiliary/util/u_threaded_context_calls.h
@@ -78,3 +78,6 @@ CALL(delete_tcs_state)
CALL(delete_tes_state)
CALL(delete_vertex_elements_state)
CALL(delete_sampler_state)
+
+CALL(begin_intel_perf_query)
+CALL(end_intel_perf_query)
diff --git a/src/gallium/drivers/iris/iris_performance_query.c b/src/gallium/drivers/iris/iris_performance_query.c
index 39633c0cfa2..bc4a3abb191 100644
--- a/src/gallium/drivers/iris/iris_performance_query.c
+++ b/src/gallium/drivers/iris/iris_performance_query.c
@@ -28,6 +28,7 @@
struct iris_perf_query {
struct gl_perf_query_object base;
struct intel_perf_query_object *query;
+ bool begin_succeeded;
};
static unsigned
@@ -107,7 +108,7 @@ iris_begin_perf_query(struct pipe_context *pipe, struct pipe_query *q)
struct intel_perf_query_object *obj = perf_query->query;
struct intel_perf_context *perf_ctx = ice->perf_ctx;
- return intel_perf_begin_query(perf_ctx, obj);
+ return (perf_query->begin_succeeded = intel_perf_begin_query(perf_ctx, obj));
}
static void
@@ -118,7 +119,8 @@ iris_end_perf_query(struct pipe_context *pipe, struct pipe_query *q)
struct intel_perf_query_object *obj = perf_query->query;
struct intel_perf_context *perf_ctx = ice->perf_ctx;
- intel_perf_end_query(perf_ctx, obj);
+ if (perf_query->begin_succeeded)
+ intel_perf_end_query(perf_ctx, obj);
}
static void
@@ -188,7 +190,8 @@ iris_wait_perf_query(struct pipe_context *pipe, struct pipe_query *q)
struct intel_perf_query_object *obj = perf_query->query;
struct intel_perf_context *perf_ctx = ice->perf_ctx;
- intel_perf_wait_query(perf_ctx, obj, &ice->batches[IRIS_BATCH_RENDER]);
+ if (perf_query->begin_succeeded)
+ intel_perf_wait_query(perf_ctx, obj, &ice->batches[IRIS_BATCH_RENDER]);
}
static bool
@@ -201,12 +204,14 @@ iris_is_perf_query_ready(struct pipe_context *pipe, struct pipe_query *q)
if (perf_query->base.Ready)
return true;
+ if (!perf_query->begin_succeeded)
+ return true;
return intel_perf_is_query_ready(perf_ctx, obj,
&ice->batches[IRIS_BATCH_RENDER]);
}
-static void
+static bool
iris_get_perf_query_data(struct pipe_context *pipe,
struct pipe_query *q,
size_t data_size,
@@ -218,8 +223,12 @@ iris_get_perf_query_data(struct pipe_context *pipe,
struct intel_perf_query_object *obj = perf_query->query;
struct intel_perf_context *perf_ctx = ice->perf_ctx;
- intel_perf_get_query_data(perf_ctx, obj, &ice->batches[IRIS_BATCH_RENDER],
- data_size, data, bytes_written);
+ if (perf_query->begin_succeeded) {
+ intel_perf_get_query_data(perf_ctx, obj, &ice->batches[IRIS_BATCH_RENDER],
+ data_size, data, bytes_written);
+ }
+
+ return perf_query->begin_succeeded;
}
void
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index f0c94ed4c7f..13e704de0fb 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -271,7 +271,7 @@ struct pipe_context {
bool (*is_intel_perf_query_ready)(struct pipe_context *pipe, struct pipe_query *q);
- void (*get_intel_perf_query_data)(struct pipe_context *pipe,
+ bool (*get_intel_perf_query_data)(struct pipe_context *pipe,
struct pipe_query *q,
size_t data_size,
uint32_t *data,
diff --git a/src/mesa/drivers/dri/i965/brw_performance_query.c b/src/mesa/drivers/dri/i965/brw_performance_query.c
index 01b2113372e..00fb80453ed 100644
--- a/src/mesa/drivers/dri/i965/brw_performance_query.c
+++ b/src/mesa/drivers/dri/i965/brw_performance_query.c
@@ -300,7 +300,7 @@ brw_is_perf_query_ready(struct gl_context *ctx,
/**
* Driver hook for glGetPerfQueryDataINTEL().
*/
-static void
+static bool
brw_get_perf_query_data(struct gl_context *ctx,
struct gl_perf_query_object *o,
GLsizei data_size,
@@ -325,6 +325,8 @@ brw_get_perf_query_data(struct gl_context *ctx,
intel_perf_get_query_data(brw->perf_ctx, obj, &brw->batch,
data_size, data, bytes_written);
+
+ return true;
}
static struct gl_perf_query_object *
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 32ab2793f88..790cb596e84 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -951,7 +951,7 @@ struct dd_function_table {
struct gl_perf_query_object *obj);
bool (*IsPerfQueryReady)(struct gl_context *ctx,
struct gl_perf_query_object *obj);
- void (*GetPerfQueryData)(struct gl_context *ctx,
+ bool (*GetPerfQueryData)(struct gl_context *ctx,
struct gl_perf_query_object *obj,
GLsizei dataSize,
GLuint *data,
diff --git a/src/mesa/main/performance_query.c b/src/mesa/main/performance_query.c
index 3afee5c89b7..b3febdd57af 100644
--- a/src/mesa/main/performance_query.c
+++ b/src/mesa/main/performance_query.c
@@ -648,6 +648,13 @@ _mesa_GetPerfQueryDataINTEL(GLuint queryHandle, GLuint flags,
}
}
- if (obj->Ready)
- ctx->Driver.GetPerfQueryData(ctx, obj, dataSize, data, bytesWritten);
+ if (obj->Ready) {
+ if (!ctx->Driver.GetPerfQueryData(ctx, obj, dataSize, data, bytesWritten)) {
+ memset(data, 0, dataSize);
+ *bytesWritten = 0;
+
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetPerfQueryDataINTEL(deferred begin query failure)");
+ }
+ }
}
diff --git a/src/mesa/state_tracker/st_cb_perfquery.c b/src/mesa/state_tracker/st_cb_perfquery.c
index 1bafc272c2d..5117bb60f3b 100644
--- a/src/mesa/state_tracker/st_cb_perfquery.c
+++ b/src/mesa/state_tracker/st_cb_perfquery.c
@@ -184,7 +184,7 @@ st_IsPerfQueryReady(struct gl_context *ctx, struct gl_perf_query_object *o)
return pipe->is_intel_perf_query_ready(pipe, (struct pipe_query *)o);
}
-static void
+static bool
st_GetPerfQueryData(struct gl_context *ctx,
struct gl_perf_query_object *o,
GLsizei data_size,
@@ -200,8 +200,8 @@ st_GetPerfQueryData(struct gl_context *ctx,
*/
assert(o->Ready);
- pipe->get_intel_perf_query_data(pipe, (struct pipe_query *)o, data_size, data,
- bytes_written);
+ return pipe->get_intel_perf_query_data(pipe, (struct pipe_query *)o,
+ data_size, data, bytes_written);
}
static struct gl_perf_query_object *
More information about the mesa-commit
mailing list