struct panfrost_pool *shader_pool,
struct panfrost_pool *desc_pool,
const nir_shader *ir,
+ struct util_debug_callback *dbg,
struct panfrost_shader_state *state)
{
struct panfrost_screen *screen = pan_screen(pscreen);
xfb->info.internal = true;
state->xfb = calloc(1, sizeof(struct panfrost_shader_state));
- panfrost_shader_compile(pscreen, shader_pool, desc_pool, xfb, state->xfb);
+ panfrost_shader_compile(pscreen, shader_pool, desc_pool, xfb, dbg, state->xfb);
/* Main shader no longer uses XFB */
s->info.has_transform_feedback_varyings = false;
/* Call out to Midgard compiler given the above NIR */
struct panfrost_compile_inputs inputs = {
+ .debug = dbg,
.gpu_id = dev->gpu_id,
- .shaderdb = !!(dev->debug & PAN_DBG_PRECOMPILE),
.fixed_sysval_ubo = -1,
.fixed_varying_mask = state->key.fixed_varying_mask
};
}
panfrost_shader_compile(pctx->screen, &ctx->shaders, &ctx->descs,
- deserialized ?: cso->prog, v);
+ deserialized ?: cso->prog,
+ &ctx->base.debug, v);
/* There are no variants so we won't need the NIR again */
ralloc_free(deserialized);
#include "tgsi/tgsi_from_mesa.h"
#include "nir/tgsi_to_nir.h"
#include "util/u_math.h"
+#include "util/u_debug_cb.h"
#include "pan_screen.h"
#include "pan_util.h"
panfrost_shader_compile(pctx->screen,
&ctx->shaders, &ctx->descs,
- so->nir, &state);
+ so->nir, &ctx->base.debug, &state);
}
return so;
/* We finally have a variant, so compile it */
panfrost_shader_compile(ctx->base.screen,
&ctx->shaders, &ctx->descs,
- variants->nir, shader_state);
+ variants->nir, &ctx->base.debug, shader_state);
/* Fixup the stream out information */
shader_state->stream_output = variants->stream_output;
gallium->destroy = panfrost_destroy;
gallium->set_framebuffer_state = panfrost_set_framebuffer_state;
+ gallium->set_debug_callback = u_default_set_debug_callback;
gallium->flush = panfrost_flush;
gallium->clear = panfrost_clear;
struct panfrost_pool *shader_pool,
struct panfrost_pool *desc_pool,
const nir_shader *ir,
+ struct util_debug_callback *dbg,
struct panfrost_shader_state *state);
void
return gl_shader_stage_name(ctx->stage);
}
-static void
-bi_print_stats(bi_context *ctx, unsigned size, FILE *fp)
+static char *
+bi_print_stats(bi_context *ctx, unsigned size)
{
struct bi_stats stats = { 0 };
unsigned nr_threads = full_threads ? 2 : 1;
/* Dump stats */
- char *str = ralloc_asprintf(NULL, "%s - %s shader: "
+ char *str = ralloc_asprintf(NULL, "%s shader: "
"%u inst, %u tuples, %u clauses, "
"%f cycles, %f arith, %f texture, %f vary, %f ldst, "
"%u quadwords, %u threads",
- ctx->nir->info.label ?: "",
bi_shader_stage_name(ctx),
stats.nr_ins, stats.nr_tuples, stats.nr_clauses,
cycles_bound, cycles_arith, cycles_texture,
ralloc_asprintf_append(&str, ", %u preloads", bi_count_preload_cost(ctx));
}
- ralloc_asprintf_append(&str, ", %u loops, %u:%u spills:fills\n",
+ ralloc_asprintf_append(&str, ", %u loops, %u:%u spills:fills",
ctx->loop_count, ctx->spills, ctx->fills);
- fputs(str, stderr);
- ralloc_free(str);
+ return str;
}
-static void
-va_print_stats(bi_context *ctx, unsigned size, FILE *fp)
+static char *
+va_print_stats(bi_context *ctx, unsigned size)
{
unsigned nr_ins = 0;
struct va_stats stats = { 0 };
unsigned nr_threads = (ctx->info.work_reg_count <= 32) ? 2 : 1;
/* Dump stats */
- fprintf(stderr, "%s - %s shader: "
+ return ralloc_asprintf(NULL, "%s shader: "
"%u inst, %f cycles, %f fma, %f cvt, %f sfu, %f v, "
"%f t, %f ls, %u quadwords, %u threads, %u loops, "
- "%u:%u spills:fills\n",
- ctx->nir->info.label ?: "",
+ "%u:%u spills:fills",
bi_shader_stage_name(ctx),
nr_ins, cycles, cycles_fma, cycles_cvt, cycles_sfu,
cycles_v, cycles_t, cycles_ls, size / 16, nr_threads,
fflush(stdout);
}
- if ((bifrost_debug & BIFROST_DBG_SHADERDB || inputs->shaderdb) &&
- !skip_internal) {
+ if (!skip_internal &&
+ ((bifrost_debug & BIFROST_DBG_SHADERDB) || inputs->debug)) {
+ char *shaderdb;
+
if (ctx->arch >= 9) {
- va_print_stats(ctx, binary->size - offset, stderr);
+ shaderdb = va_print_stats(ctx, binary->size - offset);
} else {
- bi_print_stats(ctx, binary->size - offset, stderr);
+ shaderdb = bi_print_stats(ctx, binary->size - offset);
}
+
+ if (bifrost_debug & BIFROST_DBG_SHADERDB)
+ fprintf(stderr, "SHADER-DB: %s\n", shaderdb);
+
+ if (inputs->debug)
+ util_debug_message(inputs->debug, SHADER_INFO, "%s", shaderdb);
+
+ ralloc_free(shaderdb);
}
return ctx;
if (binary->size)
memset(util_dynarray_grow(binary, uint8_t, 16), 0, 16);
- if ((midgard_debug & MIDGARD_DBG_SHADERDB || inputs->shaderdb) &&
+ if ((midgard_debug & MIDGARD_DBG_SHADERDB || inputs->debug) &&
!nir->info.internal) {
unsigned nr_bundles = 0, nr_ins = 0;
(nr_registers <= 8) ? 2 :
1;
+ char *shaderdb = NULL;
+
/* Dump stats */
- fprintf(stderr, "%s - %s shader: "
+ asprintf(&shaderdb, "%s shader: "
"%u inst, %u bundles, %u quadwords, "
"%u registers, %u threads, %u loops, "
- "%u:%u spills:fills\n",
- ctx->nir->info.label ?: "",
+ "%u:%u spills:fills",
ctx->inputs->is_blend ? "PAN_SHADER_BLEND" :
gl_shader_stage_name(ctx->stage),
nr_ins, nr_bundles, ctx->quadword_count,
nr_registers, nr_threads,
ctx->loop_count,
ctx->spills, ctx->fills);
+
+ if (midgard_debug & MIDGARD_DBG_SHADERDB)
+ fprintf(stderr, "SHADER-DB: %s\n", shaderdb);
+
+ if (inputs->debug)
+ util_debug_message(inputs->debug, SHADER_INFO, "%s", shaderdb);
+
+ free(shaderdb);
}
_mesa_hash_table_u64_destroy(ctx->ssa_constants);
panfrost_sysval_for_instr(nir_instr *instr, nir_dest *dest);
struct panfrost_compile_inputs {
+ struct util_debug_callback *debug;
+
unsigned gpu_id;
bool is_blend, is_blit;
struct {
} blend;
int fixed_sysval_ubo;
struct panfrost_sysvals *fixed_sysval_layout;
- bool shaderdb;
bool no_idvs;
bool no_ubo_to_push;