diff options
author | Marcin Ślusarz <marcin.slusarz@intel.com> | 2021-04-16 19:07:15 +0200 |
---|---|---|
committer | Eric Engestrom <eric@engestrom.ch> | 2021-04-22 22:35:47 +0200 |
commit | ec959d85e92a948707fbc71100b893bcfe8e9405 (patch) | |
tree | 83756530759c4ee7709c2221581311f17f5c594c | |
parent | a205d583c4c4105c1d138da21565e7ea39673b57 (diff) |
gallium/u_threaded: offload begin/end_intel_perf_query
Fixes: 206495cac4e ("iris: Enable u_threaded_context")
Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9922>
(cherry picked from commit 59bbf885e97ab1cc17446ff6a46c4cda501cfd46)
-rw-r--r-- | .pick_status.json | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_threaded_context.c | 36 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_threaded_context_calls.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_performance_query.c | 21 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_context.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_performance_query.c | 4 | ||||
-rw-r--r-- | src/mesa/main/dd.h | 2 | ||||
-rw-r--r-- | src/mesa/main/performance_query.c | 11 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_perfquery.c | 6 |
9 files changed, 60 insertions, 27 deletions
diff --git a/.pick_status.json b/.pick_status.json index cb6cdc0e738..f477ac5db7d 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -256,7 +256,7 @@ "description": "gallium/u_threaded: offload begin/end_intel_perf_query", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "206495cac4e48b4dac8295a0c4182d186968eb97" }, diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 900b01fb316..d8d671b69ee 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -2996,6 +2996,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); } @@ -3028,24 +3029,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 @@ -3054,7 +3066,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); } @@ -3064,7 +3076,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); } @@ -3074,11 +3086,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, @@ -3088,8 +3100,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 60aaf3c00c9..abfed01118c 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 gen_perf_query_object *query; + bool begin_succeeded; }; static unsigned @@ -106,7 +107,7 @@ iris_begin_perf_query(struct pipe_context *pipe, struct pipe_query *q) struct gen_perf_query_object *obj = perf_query->query; struct gen_perf_context *perf_ctx = ice->perf_ctx; - return gen_perf_begin_query(perf_ctx, obj); + return (perf_query->begin_succeeded = gen_perf_begin_query(perf_ctx, obj)); } static void @@ -117,7 +118,8 @@ iris_end_perf_query(struct pipe_context *pipe, struct pipe_query *q) struct gen_perf_query_object *obj = perf_query->query; struct gen_perf_context *perf_ctx = ice->perf_ctx; - gen_perf_end_query(perf_ctx, obj); + if (perf_query->begin_succeeded) + gen_perf_end_query(perf_ctx, obj); } static void @@ -186,7 +188,8 @@ iris_wait_perf_query(struct pipe_context *pipe, struct pipe_query *q) struct gen_perf_query_object *obj = perf_query->query; struct gen_perf_context *perf_ctx = ice->perf_ctx; - gen_perf_wait_query(perf_ctx, obj, &ice->batches[IRIS_BATCH_RENDER]); + if (perf_query->begin_succeeded) + gen_perf_wait_query(perf_ctx, obj, &ice->batches[IRIS_BATCH_RENDER]); } static bool @@ -199,11 +202,13 @@ 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 gen_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, @@ -215,8 +220,12 @@ iris_get_perf_query_data(struct pipe_context *pipe, struct gen_perf_query_object *obj = perf_query->query; struct gen_perf_context *perf_ctx = ice->perf_ctx; - gen_perf_get_query_data(perf_ctx, obj, &ice->batches[IRIS_BATCH_RENDER], - data_size, data, bytes_written); + if (perf_query->begin_succeeded) { + gen_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 ce48a41396c..6ee1c969eb8 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, gen_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 * |