From 3a4920e92885ec99824c7e514ed1faa487d1ad98 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 11 Mar 2023 16:46:45 -0500 Subject: [PATCH] asahi: Add perf debug for generate_mipmap The current implementation leaves a lot of perf on the table, so call it out on ASAHI_MESA_DEBUG=perf to help debugging perf problems, especially if this ever happens in a real application (i.e. not a benchmark). Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/asahi/agx_pipe.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index d503625..1f06edd 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -28,6 +28,7 @@ #include "util/format/u_format.h" #include "util/half_float.h" #include "util/u_drm.h" +#include "util/u_gen_mipmap.h" #include "util/u_inlines.h" #include "util/u_memory.h" #include "util/u_screen.h" @@ -872,6 +873,27 @@ agx_transfer_unmap(struct pipe_context *pctx, struct pipe_transfer *transfer) FREE(transfer); } +static bool +agx_generate_mipmap(struct pipe_context *pctx, struct pipe_resource *prsrc, + enum pipe_format format, unsigned base_level, + unsigned last_level, unsigned first_layer, + unsigned last_layer) +{ + struct agx_resource *rsrc = agx_resource(prsrc); + + /* Generating a mipmap invalidates the written levels. Make that + * explicit so we don't reload the previous contents. + */ + for (unsigned l = base_level + 1; l <= last_level; ++l) + BITSET_CLEAR(rsrc->data_valid, l); + + /* For now we use util_gen_mipmap, but this has way too much overhead */ + perf_debug_ctx(agx_context(pctx), "Unoptimized mipmap generation"); + + return util_gen_mipmap(pctx, prsrc, format, base_level, last_level, + first_layer, last_layer, PIPE_TEX_FILTER_LINEAR); +} + /* * clear/copy */ @@ -1206,6 +1228,7 @@ agx_create_context(struct pipe_screen *screen, void *priv, unsigned flags) pctx->clear = agx_clear; pctx->resource_copy_region = util_resource_copy_region; pctx->blit = agx_blit; + pctx->generate_mipmap = agx_generate_mipmap; pctx->flush_resource = agx_flush_resource; pctx->buffer_map = u_transfer_helper_transfer_map; @@ -1335,6 +1358,7 @@ agx_get_param(struct pipe_screen *pscreen, enum pipe_cap param) return 1; case PIPE_CAP_OCCLUSION_QUERY: + case PIPE_CAP_GENERATE_MIPMAP: case PIPE_CAP_PRIMITIVE_RESTART: case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX: case PIPE_CAP_ANISOTROPIC_FILTER: -- 2.7.4