panfrost: Add PAN_MESA_DEBUG=precompile for shader-db

We would like to use run.c for shader-db runs (rather than capturing in
real-time, which is limiting).

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3125>
This commit is contained in:
Alyssa Rosenzweig 2019-12-13 15:13:02 -05:00 committed by Marge Bot
parent 2c8742ed85
commit 271726eaca
3 changed files with 33 additions and 3 deletions

View file

@ -1700,7 +1700,8 @@ panfrost_bind_vertex_elements_state(
static void *
panfrost_create_shader_state(
struct pipe_context *pctx,
const struct pipe_shader_state *cso)
const struct pipe_shader_state *cso,
enum pipe_shader_type stage)
{
struct panfrost_shader_variants *so = CALLOC_STRUCT(panfrost_shader_variants);
so->base = *cso;
@ -1710,6 +1711,21 @@ panfrost_create_shader_state(
if (cso->type == PIPE_SHADER_IR_TGSI)
so->base.tokens = tgsi_dup_tokens(so->base.tokens);
/* Precompile for shader-db if we need to */
if (unlikely((pan_debug & PAN_DBG_PRECOMPILE) && cso->type == PIPE_SHADER_IR_NIR)) {
struct panfrost_context *ctx = pan_context(pctx);
struct mali_shader_meta meta;
struct panfrost_shader_state state;
uint64_t outputs_written;
panfrost_shader_compile(ctx, &meta,
PIPE_SHADER_IR_NIR,
so->base.ir.nir,
tgsi_processor_to_shader_stage(stage), &state,
&outputs_written);
}
return so;
}
@ -1976,6 +1992,18 @@ panfrost_bind_shader_state(
}
}
static void *
panfrost_create_vs_state(struct pipe_context *pctx, const struct pipe_shader_state *hwcso)
{
return panfrost_create_shader_state(pctx, hwcso, PIPE_SHADER_VERTEX);
}
static void *
panfrost_create_fs_state(struct pipe_context *pctx, const struct pipe_shader_state *hwcso)
{
return panfrost_create_shader_state(pctx, hwcso, PIPE_SHADER_FRAGMENT);
}
static void
panfrost_bind_vs_state(struct pipe_context *pctx, void *hwcso)
{
@ -2595,11 +2623,11 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
gallium->bind_vertex_elements_state = panfrost_bind_vertex_elements_state;
gallium->delete_vertex_elements_state = panfrost_generic_cso_delete;
gallium->create_fs_state = panfrost_create_shader_state;
gallium->create_fs_state = panfrost_create_fs_state;
gallium->delete_fs_state = panfrost_delete_shader_state;
gallium->bind_fs_state = panfrost_bind_fs_state;
gallium->create_vs_state = panfrost_create_shader_state;
gallium->create_vs_state = panfrost_create_vs_state;
gallium->delete_vs_state = panfrost_delete_shader_state;
gallium->bind_vs_state = panfrost_bind_vs_state;

View file

@ -60,6 +60,7 @@ static const struct debug_named_value debug_options[] = {
{"deqp", PAN_DBG_DEQP, "Hacks for dEQP"},
{"afbc", PAN_DBG_AFBC, "Enable non-conformant AFBC impl"},
{"sync", PAN_DBG_SYNC, "Wait for each job's completion and check for any GPU fault"},
{"precompile", PAN_DBG_PRECOMPILE, "Precompile shaders for shader-db"},
DEBUG_NAMED_VALUE_END
};

View file

@ -33,6 +33,7 @@
#define PAN_DBG_DEQP 0x0004
#define PAN_DBG_AFBC 0x0008
#define PAN_DBG_SYNC 0x0010
#define PAN_DBG_PRECOMPILE 0x0020
extern int pan_debug;