From 663c0e5155e9916b10163c102f0ece4eda5c3154 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sun, 24 Apr 2016 16:59:16 -0400 Subject: [PATCH] freedreno/ir3: use pipe_debug_callback for shader-db traces For multi-threaded shader-db support. Signed-off-by: Rob Clark --- src/gallium/drivers/freedreno/a3xx/fd3_emit.h | 4 +- src/gallium/drivers/freedreno/a3xx/fd3_program.c | 5 ++- src/gallium/drivers/freedreno/a4xx/fd4_emit.h | 4 +- src/gallium/drivers/freedreno/a4xx/fd4_program.c | 5 ++- src/gallium/drivers/freedreno/ir3/ir3_shader.c | 53 ++++++++++++++---------- src/gallium/drivers/freedreno/ir3/ir3_shader.h | 5 ++- 6 files changed, 43 insertions(+), 33 deletions(-) diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.h b/src/gallium/drivers/freedreno/a3xx/fd3_emit.h index 42dbfca..17e1fef 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.h +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.h @@ -67,7 +67,7 @@ fd3_emit_get_vp(struct fd3_emit *emit) { if (!emit->vp) { struct fd3_shader_stateobj *so = emit->prog->vp; - emit->vp = ir3_shader_variant(so->shader, emit->key); + emit->vp = ir3_shader_variant(so->shader, emit->key, emit->debug); } return emit->vp; } @@ -82,7 +82,7 @@ fd3_emit_get_fp(struct fd3_emit *emit) emit->fp = &binning_fp; } else { struct fd3_shader_stateobj *so = emit->prog->fp; - emit->fp = ir3_shader_variant(so->shader, emit->key); + emit->fp = ir3_shader_variant(so->shader, emit->key, emit->debug); } } return emit->fp; diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_program.c b/src/gallium/drivers/freedreno/a3xx/fd3_program.c index 57e269c..8152f8f 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_program.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_program.c @@ -50,9 +50,10 @@ static struct fd3_shader_stateobj * create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state *cso, enum shader_t type) { + struct fd_context *ctx = fd_context(pctx); + struct ir3_compiler *compiler = ctx->screen->compiler; struct fd3_shader_stateobj *so = CALLOC_STRUCT(fd3_shader_stateobj); - struct ir3_compiler *compiler = fd_context(pctx)->screen->compiler; - so->shader = ir3_shader_create(compiler, cso, type); + so->shader = ir3_shader_create(compiler, cso, type, &ctx->debug); return so; } diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.h b/src/gallium/drivers/freedreno/a4xx/fd4_emit.h index 41df321..a39697d 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.h +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.h @@ -76,7 +76,7 @@ fd4_emit_get_vp(struct fd4_emit *emit) { if (!emit->vp) { struct fd4_shader_stateobj *so = emit->prog->vp; - emit->vp = ir3_shader_variant(so->shader, emit->key); + emit->vp = ir3_shader_variant(so->shader, emit->key, emit->debug); } return emit->vp; } @@ -91,7 +91,7 @@ fd4_emit_get_fp(struct fd4_emit *emit) emit->fp = &binning_fp; } else { struct fd4_shader_stateobj *so = emit->prog->fp; - emit->fp = ir3_shader_variant(so->shader, emit->key); + emit->fp = ir3_shader_variant(so->shader, emit->key, emit->debug); } } return emit->fp; diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_program.c b/src/gallium/drivers/freedreno/a4xx/fd4_program.c index d782b94..4396383 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_program.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_program.c @@ -50,9 +50,10 @@ static struct fd4_shader_stateobj * create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state *cso, enum shader_t type) { + struct fd_context *ctx = fd_context(pctx); + struct ir3_compiler *compiler = ctx->screen->compiler; struct fd4_shader_stateobj *so = CALLOC_STRUCT(fd4_shader_stateobj); - struct ir3_compiler *compiler = fd_context(pctx)->screen->compiler; - so->shader = ir3_shader_create(compiler, cso, type); + so->shader = ir3_shader_create(compiler, cso, type, &ctx->debug); return so; } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.c b/src/gallium/drivers/freedreno/ir3/ir3_shader.c index 435a565..8019a12 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.c @@ -147,25 +147,6 @@ assemble_variant(struct ir3_shader_variant *v) ir3_shader_disasm(v, bin); } - if (fd_mesa_debug & FD_DBG_SHADERDB) { - /* print generic shader info: */ - fprintf(stderr, "SHADER-DB: %s prog %d/%d: %u instructions, %u dwords\n", - ir3_shader_stage(v->shader), - v->shader->id, v->id, - v->info.instrs_count, - v->info.sizedwords); - fprintf(stderr, "SHADER-DB: %s prog %d/%d: %u half, %u full\n", - ir3_shader_stage(v->shader), - v->shader->id, v->id, - v->info.max_half_reg + 1, - v->info.max_reg + 1); - fprintf(stderr, "SHADER-DB: %s prog %d/%d: %u const, %u constlen\n", - ir3_shader_stage(v->shader), - v->shader->id, v->id, - v->info.max_const + 1, - v->constlen); - } - free(bin); /* no need to keep the ir around beyond this point: */ @@ -173,6 +154,30 @@ assemble_variant(struct ir3_shader_variant *v) v->ir = NULL; } +static void +dump_shader_info(struct ir3_shader_variant *v, struct pipe_debug_callback *debug) +{ + if (!unlikely(fd_mesa_debug & FD_DBG_SHADERDB)) + return; + + pipe_debug_message(debug, SHADER_INFO, "\n" + "SHADER-DB: %s prog %d/%d: %u instructions, %u dwords\n" + "SHADER-DB: %s prog %d/%d: %u half, %u full\n" + "SHADER-DB: %s prog %d/%d: %u const, %u constlen\n", + ir3_shader_stage(v->shader), + v->shader->id, v->id, + v->info.instrs_count, + v->info.sizedwords, + ir3_shader_stage(v->shader), + v->shader->id, v->id, + v->info.max_half_reg + 1, + v->info.max_reg + 1, + ir3_shader_stage(v->shader), + v->shader->id, v->id, + v->info.max_const + 1, + v->constlen); +} + static struct ir3_shader_variant * create_variant(struct ir3_shader *shader, struct ir3_shader_key key) { @@ -207,7 +212,8 @@ fail: } struct ir3_shader_variant * -ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key) +ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key, + struct pipe_debug_callback *debug) { struct ir3_shader_variant *v; @@ -248,6 +254,7 @@ ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key) if (v) { v->next = shader->variants; shader->variants = v; + dump_shader_info(v, debug); } return v; @@ -269,8 +276,8 @@ ir3_shader_destroy(struct ir3_shader *shader) struct ir3_shader * ir3_shader_create(struct ir3_compiler *compiler, - const struct pipe_shader_state *cso, - enum shader_t type) + const struct pipe_shader_state *cso, enum shader_t type, + struct pipe_debug_callback *debug) { struct ir3_shader *shader = CALLOC_STRUCT(ir3_shader); shader->compiler = compiler; @@ -294,7 +301,7 @@ ir3_shader_create(struct ir3_compiler *compiler, * actually compiled) */ static struct ir3_shader_key key = {0}; - ir3_shader_variant(shader, key); + ir3_shader_variant(shader, key, debug); } return shader; } diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h index ff6bf1d..077ba5d 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h @@ -263,10 +263,11 @@ struct ir3_shader { void * ir3_shader_assemble(struct ir3_shader_variant *v, uint32_t gpu_id); struct ir3_shader * ir3_shader_create(struct ir3_compiler *compiler, - const struct pipe_shader_state *cso, enum shader_t type); + const struct pipe_shader_state *cso, enum shader_t type, + struct pipe_debug_callback *debug); void ir3_shader_destroy(struct ir3_shader *shader); struct ir3_shader_variant * ir3_shader_variant(struct ir3_shader *shader, - struct ir3_shader_key key); + struct ir3_shader_key key, struct pipe_debug_callback *debug); void ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin); struct fd_ringbuffer; -- 2.7.4