Mesa (master): softpipe: Add support for reporting shader-db output.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jul 23 00:47:16 UTC 2020
Module: Mesa
Branch: master
Commit: 259a03b4f0b04903d348a38bccc8954ef9f83738
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=259a03b4f0b04903d348a38bccc8954ef9f83738
Author: Eric Anholt <eric at anholt.net>
Date: Tue Jul 21 15:55:40 2020 -0700
softpipe: Add support for reporting shader-db output.
In doing the softpipe NIR and NIR-to-TGSI transition, I want to make sure
I don't make shaders significantly worse, so I need shader-db output.
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6018>
---
src/gallium/drivers/softpipe/sp_context.c | 13 ++++++++++
src/gallium/drivers/softpipe/sp_context.h | 2 ++
src/gallium/drivers/softpipe/sp_state_shader.c | 34 +++++++++++++++++++++++---
3 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 6a896b8a41d..d82e996bffc 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -191,6 +191,18 @@ softpipe_render_condition(struct pipe_context *pipe,
}
+static void
+softpipe_set_debug_callback(struct pipe_context *pipe,
+ const struct pipe_debug_callback *cb)
+{
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+
+ if (cb)
+ softpipe->debug = *cb;
+ else
+ memset(&softpipe->debug, 0, sizeof(softpipe->debug));
+}
+
struct pipe_context *
softpipe_create_context(struct pipe_screen *screen,
@@ -231,6 +243,7 @@ softpipe_create_context(struct pipe_screen *screen,
softpipe_init_image_funcs(&softpipe->pipe);
softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
+ softpipe->pipe.set_debug_callback = softpipe_set_debug_callback;
softpipe->pipe.draw_vbo = softpipe_draw_vbo;
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index d4be1efc945..cd2e498de6b 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -204,6 +204,8 @@ struct softpipe_context {
* of sp_sampler_view?
*/
struct softpipe_tex_tile_cache *tex_cache[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
+
+ struct pipe_debug_callback debug;
};
diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c
index b53d5540bdb..19e854ce39f 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -39,8 +39,10 @@
#include "draw/draw_vs.h"
#include "draw/draw_gs.h"
#include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_from_mesa.h"
#include "tgsi/tgsi_scan.h"
#include "tgsi/tgsi_parse.h"
+#include "compiler/shader_enums.h"
/**
@@ -116,7 +118,24 @@ softpipe_find_fs_variant(struct softpipe_context *sp,
}
static void
-softpipe_create_shader_state(struct pipe_shader_state *shader,
+softpipe_shader_db(struct pipe_context *pipe, const struct tgsi_token *tokens)
+{
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+
+ struct tgsi_shader_info info;
+ tgsi_scan_shader(tokens, &info);
+ pipe_debug_message(&softpipe->debug, SHADER_INFO, "%s shader: %d inst, %d loops, %d temps, %d const, %d imm",
+ _mesa_shader_stage_to_abbrev(tgsi_processor_to_shader_stage(info.processor)),
+ info.num_instructions,
+ info.opcode_count[TGSI_OPCODE_BGNLOOP],
+ info.file_max[TGSI_FILE_TEMPORARY] + 1,
+ info.file_max[TGSI_FILE_CONSTANT] + 1,
+ info.immediate_count);
+}
+
+static void
+softpipe_create_shader_state(struct pipe_context *pipe,
+ struct pipe_shader_state *shader,
const struct pipe_shader_state *templ,
bool debug)
{
@@ -129,6 +148,8 @@ softpipe_create_shader_state(struct pipe_shader_state *shader,
if (debug)
tgsi_dump(shader->tokens, 0);
+
+ softpipe_shader_db(pipe, shader->tokens);
}
static void *
@@ -138,7 +159,8 @@ softpipe_create_fs_state(struct pipe_context *pipe,
struct softpipe_context *softpipe = softpipe_context(pipe);
struct sp_fragment_shader *state = CALLOC_STRUCT(sp_fragment_shader);
- softpipe_create_shader_state(&state->shader, templ, sp_debug & SP_DBG_FS);
+ softpipe_create_shader_state(pipe, &state->shader, templ,
+ sp_debug & SP_DBG_FS);
/* draw's fs state */
state->draw_shader = draw_create_fragment_shader(softpipe->draw,
@@ -222,7 +244,8 @@ softpipe_create_vs_state(struct pipe_context *pipe,
if (!state)
goto fail;
- softpipe_create_shader_state(&state->shader, templ, sp_debug & SP_DBG_VS);
+ softpipe_create_shader_state(pipe, &state->shader, templ,
+ sp_debug & SP_DBG_VS);
if (!state->shader.tokens)
goto fail;
@@ -282,7 +305,8 @@ softpipe_create_gs_state(struct pipe_context *pipe,
if (!state)
goto fail;
- softpipe_create_shader_state(&state->shader, templ, sp_debug & SP_DBG_GS);
+ softpipe_create_shader_state(pipe, &state->shader, templ,
+ sp_debug & SP_DBG_GS);
if (templ->tokens) {
state->draw_data = draw_create_geometry_shader(softpipe->draw, templ);
@@ -391,6 +415,8 @@ softpipe_create_compute_state(struct pipe_context *pipe,
if (sp_debug & SP_DBG_CS)
tgsi_dump(tokens, 0);
+ softpipe_shader_db(pipe, tokens);
+
state = CALLOC_STRUCT(sp_compute_shader);
state->shader = *templ;
More information about the mesa-commit
mailing list