From efb5aef9353e1ad775edd0156cc4c76cf4649cd2 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 12 Nov 2022 21:22:00 -0500 Subject: [PATCH] asahi: Implement perf_debug Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/agx_device.h | 1 + src/gallium/drivers/asahi/agx_batch.c | 8 ++++++-- src/gallium/drivers/asahi/agx_pipe.c | 1 + src/gallium/drivers/asahi/agx_state.h | 11 ++++++++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/asahi/lib/agx_device.h b/src/asahi/lib/agx_device.h index c537d1cace3..53d035e94a9 100644 --- a/src/asahi/lib/agx_device.h +++ b/src/asahi/lib/agx_device.h @@ -39,6 +39,7 @@ enum agx_dbg { AGX_DBG_NO16 = BITFIELD_BIT(2), AGX_DBG_DIRTY = BITFIELD_BIT(3), AGX_DBG_PRECOMPILE = BITFIELD_BIT(4), + AGX_DBG_PERF = BITFIELD_BIT(5), }; struct agx_device { diff --git a/src/gallium/drivers/asahi/agx_batch.c b/src/gallium/drivers/asahi/agx_batch.c index a7147e099cf..549f928c21b 100644 --- a/src/gallium/drivers/asahi/agx_batch.c +++ b/src/gallium/drivers/asahi/agx_batch.c @@ -12,8 +12,10 @@ agx_flush_readers(struct agx_context *ctx, struct agx_resource *rsrc, const char if (ctx->batch) { struct agx_batch *batch = ctx->batch; - if (agx_batch_uses_bo(batch, rsrc->bo)) + if (agx_batch_uses_bo(batch, rsrc->bo)) { + perf_debug_ctx(ctx, "Flush reader due to: %s\n", reason); agx_flush_batch(ctx, batch); + } } } @@ -22,8 +24,10 @@ agx_flush_writer(struct agx_context *ctx, struct agx_resource *rsrc, const char { struct hash_entry *ent = _mesa_hash_table_search(ctx->writer, rsrc); - if (ent) + if (ent) { + perf_debug_ctx(ctx, "Flush writer due to: %s\n", reason); agx_flush_batch(ctx, ent->data); + } } void diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index e6f61e47bc9..7daca7a6f41 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -71,6 +71,7 @@ static const struct debug_named_value agx_debug_options[] = { {"trace", AGX_DBG_TRACE, "Trace the command stream"}, {"deqp", AGX_DBG_DEQP, "Hacks for dEQP"}, {"no16", AGX_DBG_NO16, "Disable 16-bit support"}, + {"perf", AGX_DBG_PERF, "Print performance warnings"}, #ifndef NDEBUG {"dirty", AGX_DBG_DIRTY, "Disable dirty tracking"}, #endif diff --git a/src/gallium/drivers/asahi/agx_state.h b/src/gallium/drivers/asahi/agx_state.h index 3b9562ed16a..e4dd62df4c6 100644 --- a/src/gallium/drivers/asahi/agx_state.h +++ b/src/gallium/drivers/asahi/agx_state.h @@ -272,6 +272,15 @@ agx_device(struct pipe_screen *p) return &(agx_screen(p)->dev); } +#define perf_debug(dev, ...) \ + do { \ + if (unlikely((dev)->debug & AGX_DBG_PERF)) \ + mesa_logw(__VA_ARGS__); \ + } while(0) + +#define perf_debug_ctx(ctx, ...) \ + perf_debug(agx_device((ctx)->base.screen), __VA_ARGS__); + struct agx_resource { struct pipe_resource base; uint64_t modifier; @@ -420,7 +429,7 @@ void agx_internal_shaders(struct agx_device *dev); static void agx_flush_all(struct agx_context *ctx, const char *reason) { - //printf("Flushing due to: %s\n", reason); + perf_debug_ctx(ctx, "Flushing due to: %s\n", reason); ctx->base.flush(&ctx->base, NULL, 0); }