mesa/nir: Add some perfetto traces
authorRob Clark <robdclark@chromium.org>
Thu, 16 Mar 2023 18:30:21 +0000 (11:30 -0700)
committerMarge Bot <emma+marge@anholt.net>
Mon, 24 Apr 2023 22:42:04 +0000 (22:42 +0000)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22646>

12 files changed:
src/compiler/glsl/gl_nir_link_varyings.c
src/compiler/glsl/gl_nir_linker.c
src/compiler/glsl/glsl_to_nir.cpp
src/gallium/auxiliary/nir/tgsi_to_nir.c
src/mesa/main/shaderapi.c
src/mesa/program/link_program.cpp
src/mesa/state_tracker/st_glsl_to_ir.cpp
src/mesa/state_tracker/st_glsl_to_nir.cpp
src/mesa/state_tracker/st_nir.h
src/mesa/state_tracker/st_nir_builtins.c
src/mesa/state_tracker/st_program.c
src/mesa/state_tracker/st_shader_cache.c

index 6539759..2f2722c 100644 (file)
@@ -33,6 +33,7 @@
 #include "main/mtypes.h"
 #include "util/hash_table.h"
 #include "util/u_math.h"
+#include "util/perf/cpu_trace.h"
 
 #include "nir.h"
 #include "nir_builder.h"
@@ -3154,6 +3155,8 @@ gl_nir_link_varyings(const struct gl_constants *consts,
 
    unsigned first, last;
 
+   MESA_TRACE_FUNC();
+
    first = MESA_SHADER_STAGES;
    last = 0;
 
index 0066a87..92debe1 100644 (file)
@@ -30,6 +30,7 @@
 #include "main/shaderobj.h"
 #include "ir_uniform.h" /* for gl_uniform_storage */
 #include "util/glheader.h"
+#include "util/perf/cpu_trace.h"
 
 /**
  * This file included general link methods, using NIR, instead of IR as
@@ -41,6 +42,8 @@ gl_nir_opts(nir_shader *nir)
 {
    bool progress;
 
+   MESA_TRACE_FUNC();
+
    do {
       progress = false;
 
@@ -122,6 +125,8 @@ gl_nir_opts(nir_shader *nir)
 static void
 gl_nir_link_opts(nir_shader *producer, nir_shader *consumer)
 {
+   MESA_TRACE_FUNC();
+
    if (producer->options->lower_to_scalar) {
       NIR_PASS_V(producer, nir_lower_io_to_scalar_early, nir_var_shader_out);
       NIR_PASS_V(consumer, nir_lower_io_to_scalar_early, nir_var_shader_in);
@@ -761,6 +766,8 @@ gl_nir_link_spirv(const struct gl_constants *consts,
    struct gl_linked_shader *linked_shader[MESA_SHADER_STAGES];
    unsigned num_shaders = 0;
 
+   MESA_TRACE_FUNC();
+
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
       if (prog->_LinkedShaders[i])
          linked_shader[num_shaders++] = prog->_LinkedShaders[i];
@@ -925,6 +932,8 @@ gl_nir_link_glsl(const struct gl_constants *consts,
    if (prog->NumShaders == 0)
       return true;
 
+   MESA_TRACE_FUNC();
+
    if (!gl_nir_link_varyings(consts, exts, api, prog))
       return false;
 
index 7886a90..1cc3477 100644 (file)
@@ -40,6 +40,7 @@
 #include "main/mtypes.h"
 #include "main/shaderobj.h"
 #include "util/u_math.h"
+#include "util/perf/cpu_trace.h"
 
 /*
  * pass to lower GLSL IR to NIR
@@ -207,6 +208,8 @@ glsl_to_nir(const struct gl_constants *consts,
    const struct gl_shader_compiler_options *gl_options =
       &consts->ShaderCompilerOptions[stage];
 
+   MESA_TRACE_FUNC();
+
    /* glsl_to_nir can only handle converting certain function paramaters
     * to NIR. If we find something we can't handle then we get the GLSL IR
     * opts to remove it before we continue on.
index 6b046a8..579a62b 100644 (file)
@@ -26,6 +26,7 @@
 #include "util/u_debug.h"
 #include "util/disk_cache.h"
 #include "util/u_memory.h"
+#include "util/perf/cpu_trace.h"
 #include "util/ralloc.h"
 #include "pipe/p_screen.h"
 
@@ -2575,6 +2576,8 @@ ttn_finalize_nir(struct ttn_compile *c, struct pipe_screen *screen)
 {
    struct nir_shader *nir = c->build.shader;
 
+   MESA_TRACE_FUNC();
+
    NIR_PASS_V(nir, nir_lower_vars_to_ssa);
    NIR_PASS_V(nir, nir_lower_regs_to_ssa);
 
index 5e1f112..9c76520 100644 (file)
@@ -63,6 +63,7 @@
 #include "util/crc32.h"
 #include "util/os_file.h"
 #include "util/list.h"
+#include "util/perf/cpu_trace.h"
 #include "util/u_process.h"
 #include "util/u_string.h"
 #include "api_exec_decl.h"
@@ -1304,6 +1305,8 @@ link_program(struct gl_context *ctx, struct gl_shader_program *shProg,
    if (!shProg)
       return;
 
+   MESA_TRACE_FUNC();
+
    if (!no_error) {
       /* From the ARB_transform_feedback2 specification:
        * "The error INVALID_OPERATION is generated by LinkProgram if <program>
index aae2cf3..011fb17 100644 (file)
@@ -31,6 +31,7 @@
 #include "compiler/glsl/linker.h"
 #include "compiler/glsl/program.h"
 #include "compiler/glsl/shader_cache.h"
+#include "util/perf/cpu_trace.h"
 
 #include "state_tracker/st_glsl_to_ir.h"
 
@@ -45,6 +46,8 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
    unsigned int i;
    bool spirv = false;
 
+   MESA_TRACE_FUNC();
+
    _mesa_clear_shader_program_data(ctx, prog);
 
    prog->data = _mesa_create_shader_program_data();
index 8322836..a7364f3 100644 (file)
@@ -44,6 +44,8 @@ link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
       return GL_TRUE;
    }
 
+   MESA_TRACE_FUNC();
+
    assert(prog->data->LinkStatus);
 
    /* Skip the GLSL steps when using SPIR-V. */
@@ -103,6 +105,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
 {
    struct pipe_context *pctx = st_context(ctx)->pipe;
 
+   MESA_TRACE_FUNC();
+
    GLboolean ret = link_shader(ctx, prog);
     
    if (pctx->link_shader) {
index ed2ef5c..4779b16 100644 (file)
@@ -712,6 +712,8 @@ st_link_nir(struct gl_context *ctx,
    struct gl_linked_shader *linked_shader[MESA_SHADER_STAGES];
    unsigned num_shaders = 0;
 
+   MESA_TRACE_FUNC();
+
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
       if (shader_program->_LinkedShaders[i])
          linked_shader[num_shaders++] = shader_program->_LinkedShaders[i];
@@ -1056,6 +1058,8 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
 {
    struct pipe_screen *screen = st->screen;
 
+   MESA_TRACE_FUNC();
+
    NIR_PASS_V(nir, nir_split_var_copies);
    NIR_PASS_V(nir, nir_lower_var_copies);
 
index cc603a9..13628cc 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "st_context.h"
 #include "compiler/shader_enums.h"
+#include "util/perf/cpu_trace.h"
 
 #ifdef __cplusplus
 extern "C" {
index 54bfb0d..ba403c8 100644 (file)
@@ -35,6 +35,8 @@ st_nir_finish_builtin_nir(struct st_context *st, nir_shader *nir)
    struct pipe_screen *screen = st->screen;
    gl_shader_stage stage = nir->info.stage;
 
+   MESA_TRACE_FUNC();
+
    nir->info.separate_shader = true;
    if (stage == MESA_SHADER_FRAGMENT)
       nir->info.fs.untyped_color_outputs = true;
index f2fa219..855cec4 100644 (file)
@@ -684,6 +684,8 @@ st_create_common_variant(struct st_context *st,
                          struct gl_program *prog,
                          const struct st_common_variant_key *key)
 {
+   MESA_TRACE_FUNC();
+
    struct st_common_variant *v = CALLOC_STRUCT(st_common_variant);
    struct pipe_shader_state state = {0};
 
@@ -896,6 +898,8 @@ st_create_fp_variant(struct st_context *st,
    if (!variant)
       return NULL;
 
+   MESA_TRACE_FUNC();
+
    /* Translate ATI_fs to NIR at variant time because that's when we have the
     * texture types.
     */
@@ -1329,6 +1333,8 @@ st_finalize_program(struct st_context *st, struct gl_program *prog)
    struct gl_context *ctx = st->ctx;
    bool is_bound = false;
 
+   MESA_TRACE_FUNC();
+
    if (prog->info.stage == MESA_SHADER_VERTEX)
       is_bound = prog == ctx->VertexProgram._Current;
    else if (prog->info.stage == MESA_SHADER_TESS_CTRL)
index 7ca0a08..0f309a4 100644 (file)
@@ -32,6 +32,7 @@
 #include "main/uniforms.h"
 #include "pipe/p_shader_tokens.h"
 #include "util/u_memory.h"
+#include "util/perf/cpu_trace.h"
 
 void
 st_get_program_binary_driver_sha1(struct gl_context *ctx, uint8_t *sha1)
@@ -146,6 +147,8 @@ st_deserialise_nir_program(struct gl_context *ctx,
    size_t size = prog->driver_cache_blob_size;
    uint8_t *buffer = (uint8_t *) prog->driver_cache_blob;
 
+   MESA_TRACE_FUNC();
+
    st_set_prog_affected_state_flags(prog);
 
    /* Avoid reallocation of the program parameter list, because the uniform