From f7d4ebbf86477a5788ef741b75507e5f898db559 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 27 Oct 2020 15:56:06 -0700 Subject: [PATCH] iris: add hooks to call INTEL_MEASURE These hooks were written in the initial IRIS_MEASURE implementation. Minor changes by Mark Janes to adapt to the INTEL_MEASURE reimplementation. Acked-by: Kenneth Graunke Part-of: --- src/gallium/drivers/iris/iris_batch.c | 10 +++++++++- src/gallium/drivers/iris/iris_blorp.c | 11 ++++++++++- src/gallium/drivers/iris/iris_context.c | 3 +++ src/gallium/drivers/iris/iris_fence.c | 4 ++++ src/gallium/drivers/iris/iris_resolve.c | 6 ++++-- src/gallium/drivers/iris/iris_screen.c | 2 ++ src/gallium/drivers/iris/iris_state.c | 4 ++++ 7 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c index 70f40bee1f9..8a87f5939cd 100644 --- a/src/gallium/drivers/iris/iris_batch.c +++ b/src/gallium/drivers/iris/iris_batch.c @@ -227,6 +227,8 @@ iris_init_batch(struct iris_context *ice, batch->decoder.max_vbo_decoded_lines = 32; } + iris_init_batch_measure(ice, batch); + iris_batch_reset(batch); } @@ -298,7 +300,8 @@ iris_use_pinned_bo(struct iris_batch *batch, return; } - if (bo != batch->bo) { + if (bo != batch->bo && + (!batch->measure || bo != batch->measure->bo)) { /* This is the first time our batch has seen this BO. Before we use it, * we may need to flush and synchronize with other batches. */ @@ -442,6 +445,9 @@ iris_batch_free(struct iris_batch *batch) iris_destroy_hw_context(bufmgr, batch->hw_ctx_id); + iris_destroy_batch_measure(batch->measure); + batch->measure = NULL; + _mesa_hash_table_destroy(batch->cache.render, NULL); if (INTEL_DEBUG) @@ -683,6 +689,8 @@ _iris_batch_flush(struct iris_batch *batch, const char *file, int line) if (iris_batch_bytes_used(batch) == 0) return; + iris_measure_batch_end(batch->ice, batch); + iris_finish_batch(batch); if (INTEL_DEBUG & (DEBUG_BATCH | DEBUG_SUBMIT | DEBUG_PIPE_CONTROL)) { diff --git a/src/gallium/drivers/iris/iris_blorp.c b/src/gallium/drivers/iris/iris_blorp.c index 38fb2a4508b..0dee4adf14c 100644 --- a/src/gallium/drivers/iris/iris_blorp.c +++ b/src/gallium/drivers/iris/iris_blorp.c @@ -379,7 +379,16 @@ iris_blorp_exec(struct blorp_batch *blorp_batch, static void blorp_measure_start(struct blorp_batch *blorp_batch, - const struct blorp_params *params) { } + const struct blorp_params *params) +{ + struct iris_context *ice = blorp_batch->blorp->driver_ctx; + struct iris_batch *batch = blorp_batch->driver_batch; + + if (batch->measure == NULL) + return; + + iris_measure_snapshot(ice, batch, params->snapshot_type, NULL, NULL, NULL); +} void genX(init_blorp)(struct iris_context *ice) diff --git a/src/gallium/drivers/iris/iris_context.c b/src/gallium/drivers/iris/iris_context.c index 80b666dc60d..bd236f3b282 100644 --- a/src/gallium/drivers/iris/iris_context.c +++ b/src/gallium/drivers/iris/iris_context.c @@ -240,6 +240,9 @@ iris_destroy_context(struct pipe_context *ctx) screen->vtbl.destroy_state(ice); iris_destroy_program_cache(ice); iris_destroy_border_color_pool(ice); + if (screen->measure.config) + iris_destroy_ctx_measure(ice); + u_upload_destroy(ice->state.surface_uploader); u_upload_destroy(ice->state.dynamic_uploader); u_upload_destroy(ice->query_buffer_uploader); diff --git a/src/gallium/drivers/iris/iris_fence.c b/src/gallium/drivers/iris/iris_fence.c index 75ef06117f7..bc04fdc48c4 100644 --- a/src/gallium/drivers/iris/iris_fence.c +++ b/src/gallium/drivers/iris/iris_fence.c @@ -248,6 +248,10 @@ iris_fence_flush(struct pipe_context *ctx, iris_batch_flush(&ice->batches[i]); } + if (flags & PIPE_FLUSH_END_OF_FRAME) { + iris_measure_frame_end(ice); + } + if (!out_fence) return; diff --git a/src/gallium/drivers/iris/iris_resolve.c b/src/gallium/drivers/iris/iris_resolve.c index c1512122b86..c66eddacf79 100644 --- a/src/gallium/drivers/iris/iris_resolve.c +++ b/src/gallium/drivers/iris/iris_resolve.c @@ -436,6 +436,8 @@ iris_mcs_partial_resolve(struct iris_context *ice, assert(isl_aux_usage_has_mcs(res->aux.usage)); + iris_batch_maybe_flush(batch, 1500); + struct blorp_surf surf; iris_blorp_surf_for_resource(&batch->screen->isl_dev, &surf, &res->base, res->aux.usage, 0, true); @@ -513,6 +515,8 @@ iris_hiz_exec(struct iris_context *ice, assert(op != ISL_AUX_OP_NONE); UNUSED const char *name = NULL; + iris_batch_maybe_flush(batch, 1500); + switch (op) { case ISL_AUX_OP_FULL_RESOLVE: name = "depth resolve"; @@ -552,8 +556,6 @@ iris_hiz_exec(struct iris_context *ice, assert(isl_aux_usage_has_hiz(res->aux.usage) && res->aux.bo); - iris_batch_maybe_flush(batch, 1500); - iris_batch_sync_region_start(batch); struct blorp_surf surf; diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index df7faf340ef..510618a8ed4 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -613,6 +613,7 @@ iris_get_timestamp(struct pipe_screen *pscreen) void iris_screen_destroy(struct iris_screen *screen) { + iris_destroy_screen_measure(screen); glsl_type_singleton_decref(); iris_bo_unreference(screen->workaround_bo); u_transfer_helper_destroy(screen->base.transfer_helper); @@ -850,6 +851,7 @@ iris_screen_create(int fd, const struct pipe_screen_config *config) iris_init_screen_fence_functions(pscreen); iris_init_screen_resource_functions(pscreen); + iris_init_screen_measure(screen); pscreen->destroy = iris_screen_unref; pscreen->get_name = iris_get_name; diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 33c5b2c523b..b5d985d9083 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -6691,6 +6691,8 @@ iris_upload_render_state(struct iris_context *ice, _iris_emit_lri(batch, _3DPRIM_INSTANCE_COUNT, draw->instance_count); } + iris_measure_snapshot(ice, batch, INTEL_SNAPSHOT_DRAW, draw, indirect, sc); + iris_emit_cmd(batch, GENX(3DPRIMITIVE), prim) { prim.VertexAccessType = draw->index_size > 0 ? RANDOM : SEQUENTIAL; prim.PredicateEnable = use_predicate; @@ -6932,6 +6934,8 @@ iris_upload_gpgpu_walker(struct iris_context *ice, const uint32_t right_mask = brw_cs_right_mask(group_size, simd_size); + iris_measure_snapshot(ice, batch, INTEL_SNAPSHOT_COMPUTE, NULL, NULL, NULL); + iris_emit_cmd(batch, GENX(GPGPU_WALKER), ggw) { ggw.IndirectParameterEnable = grid->indirect != NULL; ggw.SIMDSize = simd_size / 16;