Mesa (main): i915g: Add support for shader-db.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 29 16:41:54 UTC 2021


Module: Mesa
Branch: main
Commit: 6f5f79e042ab3e1a564450fe5f8503fa0e28a025
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f5f79e042ab3e1a564450fe5f8503fa0e28a025

Author: Emma Anholt <emma at anholt.net>
Date:   Tue Aug 11 16:33:57 2020 -0700

i915g: Add support for shader-db.

I wanted to make sure that NIR-to-TGSI wouldn't regress this driver's code
generation, so make it possible to use standard shader-db on it.

Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11912>

---

 src/gallium/drivers/i915/i915_context.c       | 13 +++++++++++++
 src/gallium/drivers/i915/i915_context.h       |  2 ++
 src/gallium/drivers/i915/i915_fpc_translate.c |  7 +++++++
 3 files changed, 22 insertions(+)

diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c
index 709cfd029e5..d86e036b732 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -166,6 +166,18 @@ i915_destroy(struct pipe_context *pipe)
    FREE(i915);
 }
 
+static void
+i915_set_debug_callback(struct pipe_context *pipe,
+                        const struct pipe_debug_callback *cb)
+{
+   struct i915_context *i915 = i915_context(pipe);
+
+   if (cb)
+      i915->debug = *cb;
+   else
+      memset(&i915->debug, 0, sizeof(i915->debug));
+}
+
 struct pipe_context *
 i915_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
 {
@@ -180,6 +192,7 @@ i915_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
    i915->base.priv = priv;
    i915->base.stream_uploader = u_upload_create_default(&i915->base);
    i915->base.const_uploader = i915->base.stream_uploader;
+   i915->base.set_debug_callback = i915_set_debug_callback;
 
    i915->base.destroy = i915_destroy;
 
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h
index 0256a440283..00f892861af 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -303,6 +303,8 @@ struct i915_context {
 
    /** blitter/hw-clear */
    struct blitter_context *blitter;
+
+   struct pipe_debug_callback debug;
 };
 
 /* A flag for each frontend state object:
diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c b/src/gallium/drivers/i915/i915_fpc_translate.c
index bbca6bd8887..0da91a17ee7 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -35,6 +35,7 @@
 
 #include "pipe/p_shader_tokens.h"
 #include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_from_mesa.h"
 #include "tgsi/tgsi_info.h"
 #include "tgsi/tgsi_parse.h"
 #include "util/log.h"
@@ -1030,6 +1031,12 @@ i915_fini_compile(struct i915_context *i915, struct i915_fp_compile *p)
       memcpy(ifs->program, p->declarations, decl_size * sizeof(uint32_t));
       memcpy(&ifs->program[decl_size], p->program,
              program_size * sizeof(uint32_t));
+
+      pipe_debug_message(
+         &i915->debug, SHADER_INFO,
+         "%s shader: %d inst, %d tex, %d tex_indirect, %d const",
+         _mesa_shader_stage_to_abbrev(MESA_SHADER_FRAGMENT), (int)program_size,
+         p->nr_tex_insn, p->nr_tex_indirect, ifs->num_constants);
    }
 
    /* Release the compilation struct:



More information about the mesa-commit mailing list