freedreno/ir3: use pipe_debug_callback for shader-db traces
authorRob Clark <robclark@freedesktop.org>
Sun, 24 Apr 2016 20:59:16 +0000 (16:59 -0400)
committerRob Clark <robclark@freedesktop.org>
Sat, 30 Apr 2016 18:56:20 +0000 (14:56 -0400)
For multi-threaded shader-db support.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/a3xx/fd3_emit.h
src/gallium/drivers/freedreno/a3xx/fd3_program.c
src/gallium/drivers/freedreno/a4xx/fd4_emit.h
src/gallium/drivers/freedreno/a4xx/fd4_program.c
src/gallium/drivers/freedreno/ir3/ir3_shader.c
src/gallium/drivers/freedreno/ir3/ir3_shader.h

index 42dbfca9b979510f53146a8d0b82921860013c45..17e1fef882fd3b5e2dc8b2ea4798ffa650ce7b08 100644 (file)
@@ -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;
index 57e269cc21f1a5013d3127c2a9778eb3a27d1467..8152f8fcb9c2c48c4af0fcb78dae060851f48f51 100644 (file)
@@ -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;
 }
 
index 41df321911678739340222391936b59b01e475f2..a39697dafb441355f7c742972482f55eab7d102f 100644 (file)
@@ -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;
index d782b94f8486c4911eb236fff6f6410738fc03eb..4396383eef9a3b57cc1cc5bfb087a81e34d71825 100644 (file)
@@ -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;
 }
 
index 435a565e61ec1b8e9019084cc07dfcbb8bb94cad..8019a1286c062def61833576d9566fa78f5cedff 100644 (file)
@@ -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;
 }
index ff6bf1d67b80cd00226a309a6c78414572789fad..077ba5db3797e1186895097a62dae8a99de4f212 100644 (file)
@@ -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;