From 9205212d2e93de64d8c47880c40a0e7f1643949d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Molinari?= Date: Sat, 8 Mar 2025 17:12:34 +0100 Subject: [PATCH] mesa: Add CPU traces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A few function scope traces are added to texture management entry points, shader compilation, draw and 2D rect copy to give better context to driver traces. Signed-off-by: Loïc Molinari Reviewed-by: Alejandro Piñeiro Reviewed-by: Benjamin Lee Acked-by: Boris Brezillon Part-of: --- src/mesa/main/readpix.c | 3 +++ src/mesa/main/shaderapi.c | 2 ++ src/mesa/main/teximage.c | 9 +++++++++ src/mesa/main/texstorage.c | 3 +++ src/mesa/state_tracker/st_draw.c | 3 +++ src/util/format/u_format.c | 3 +++ 6 files changed, 23 insertions(+) diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index 32a70e4264a..37111431947 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -23,6 +23,7 @@ */ #include "util/glheader.h" +#include "util/perf/cpu_trace.h" #include "blend.h" #include "bufferobj.h" @@ -1046,6 +1047,8 @@ read_pixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, struct gl_renderbuffer *rb; struct gl_pixelstore_attrib clippedPacking; + MESA_TRACE_FUNC(); + GET_CURRENT_CONTEXT(ctx); FLUSH_VERTICES(ctx, 0, 0); diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index d79fdbd211b..06c705d961a 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1225,6 +1225,8 @@ _mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh) _mesa_log_direct(sh->Source); } + MESA_TRACE_FUNC(); + ensure_builtin_types(ctx); /* this call will set the shader->CompileStatus field to indicate if diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 3ff51ca7611..419bdf8ec2b 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -31,6 +31,7 @@ #include #include "util/glheader.h" +#include "util/perf/cpu_trace.h" #include "bufferobj.h" #include "context.h" #include "enums.h" @@ -3164,6 +3165,8 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims, mesa_format texFormat; bool dimensionsOK = true, sizeOK = true; + MESA_TRACE_FUNC(); + FLUSH_VERTICES(ctx, 0, 0); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) { @@ -3828,6 +3831,8 @@ texture_sub_image(struct gl_context *ctx, GLuint dims, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels) { + MESA_TRACE_FUNC(); + FLUSH_VERTICES(ctx, 0, 0); _mesa_update_pixel(ctx); @@ -4460,6 +4465,8 @@ copy_texture_sub_image(struct gl_context *ctx, GLuint dims, { struct gl_texture_image *texImage; + MESA_TRACE_FUNC(); + _mesa_lock_texture(ctx, texObj); texImage = _mesa_select_tex_image(texObj, target, level); @@ -4560,6 +4567,8 @@ copyteximage(struct gl_context *ctx, GLuint dims, struct gl_texture_object *texO struct gl_texture_image *texImage; mesa_format texFormat; + MESA_TRACE_FUNC(); + FLUSH_VERTICES(ctx, 0, 0); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c index 55746c08fec..f0c1801320e 100644 --- a/src/mesa/main/texstorage.c +++ b/src/mesa/main/texstorage.c @@ -28,6 +28,7 @@ */ #include "util/glheader.h" +#include "util/perf/cpu_trace.h" #include "context.h" #include "enums.h" @@ -535,6 +536,8 @@ texture_storage(struct gl_context *ctx, GLuint dims, (memObj ? "Mem" : ""); const char* suffix2 = attribs ? "Attribs" : ""; + MESA_TRACE_FUNC(); + assert(texObj); if (!no_error) { diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 290d4c14bc1..6df165c3723 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -62,6 +62,7 @@ #include "util/u_draw.h" #include "util/u_upload_mgr.h" #include "util/u_threaded_context.h" +#include "util/perf/cpu_trace.h" #include "draw/draw_context.h" #include "cso_cache/cso_context.h" @@ -117,6 +118,8 @@ st_draw_gallium(struct gl_context *ctx, const struct pipe_draw_start_count_bias *draws, unsigned num_draws) { + MESA_TRACE_FUNC(); + struct st_context *st = st_context(ctx); cso_draw_vbo(st->cso_context, info, drawid_offset, indirect, draws, num_draws); diff --git a/src/util/format/u_format.c b/src/util/format/u_format.c index db57f3081fd..c427e08e788 100644 --- a/src/util/format/u_format.c +++ b/src/util/format/u_format.c @@ -37,6 +37,7 @@ #include "util/format/u_format.h" #include "util/format/u_format_s3tc.h" #include "util/u_math.h" +#include "util/perf/cpu_trace.h" /** * Copy 2D rect from one place to another. @@ -56,6 +57,8 @@ util_copy_rect(void * dst_in, unsigned src_x, unsigned src_y) { + MESA_TRACE_SCOPE("%s width=%u height=%u", __func__, width, height); + uint8_t *dst = dst_in; const uint8_t *src = src_in; unsigned i;