From 6f5f79e042ab3e1a564450fe5f8503fa0e28a025 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 11 Aug 2020 16:33:57 -0700 Subject: [PATCH] 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 Part-of: --- 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 709cfd0..d86e036 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 0256a44..00f8928 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 bbca6bd..0da91a1 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: -- 2.7.4