comp->prog->shader = code;
comp->prog->shader_size = num_instr * sizeof(gpir_codegen_instr);
+ comp->num_instr = num_instr;
if (lima_debug & LIMA_DEBUG_GP) {
gpir_codegen_print_prog(comp);
struct lima_vs_shader_state *prog;
int constant_base;
+
+ /* shaderdb */
+ int num_instr;
+ int num_loops;
+ int num_spills;
+ int num_fills;
} gpir_compiler;
#define GPIR_VALUE_REG_NUM 11
#include "util/ralloc.h"
#include "compiler/nir/nir.h"
+#include "pipe/p_state.h"
+
#include "gpir.h"
#include "lima_context.h"
return 4;
}
-bool gpir_compile_nir(struct lima_vs_shader_state *prog, struct nir_shader *nir)
+static void gpir_print_shader_db(struct nir_shader *nir, gpir_compiler *comp,
+ struct pipe_debug_callback *debug)
+{
+ const struct shader_info *info = &nir->info;
+ char *shaderdb;
+ int ret = asprintf(&shaderdb,
+ "%s shader: %d inst, %d loops, %d:%d spills:fills\n",
+ gl_shader_stage_name(info->stage),
+ comp->num_instr,
+ comp->num_loops,
+ comp->num_spills,
+ comp->num_fills);
+ assert(ret >= 0);
+
+ if (lima_debug & LIMA_DEBUG_SHADERDB)
+ fprintf(stderr, "SHADER-DB: %s\n", shaderdb);
+
+ pipe_debug_message(debug, SHADER_INFO, "%s", shaderdb);
+ free(shaderdb);
+}
+
+bool gpir_compile_nir(struct lima_vs_shader_state *prog, struct nir_shader *nir,
+ const struct pipe_debug_callback *debug)
{
nir_function_impl *func = nir_shader_get_entrypoint(nir);
gpir_compiler *comp = gpir_compiler_create(prog, func->reg_alloc, func->ssa_alloc);
v->components += glsl_get_components(var->type);
}
+ gpir_print_shader_db(nir, comp, debug);
+
ralloc_free(comp);
return true;
struct lima_fs_shader_state;
/* gpir interface */
-bool gpir_compile_nir(struct lima_vs_shader_state *prog, struct nir_shader *nir);
+bool gpir_compile_nir(struct lima_vs_shader_state *prog, struct nir_shader *nir,
+ const struct pipe_debug_callback *debug);
/* ppir interface */
bool ppir_compile_nir(struct lima_fs_shader_state *prog, struct nir_shader *nir,
- struct ra_regs *ra);
+ struct ra_regs *ra,
+ const struct pipe_debug_callback *debug);
struct ra_regs *ppir_regalloc_init(void *mem_ctx);
void lima_nir_lower_uniform_to_scalar(nir_shader *shader);
#include "util/ralloc.h"
#include "util/bitscan.h"
#include "compiler/nir/nir.h"
+#include "pipe/p_state.h"
+
#include "ppir.h"
}
}
+static void ppir_print_shader_db(struct nir_shader *nir, ppir_compiler *comp,
+ const struct pipe_debug_callback *debug)
+{
+ const struct shader_info *info = &nir->info;
+ char *shaderdb;
+ int ret = asprintf(&shaderdb,
+ "%s shader: %d inst, %d loops, %d:%d spills:fills\n",
+ gl_shader_stage_name(info->stage),
+ comp->cur_instr_index,
+ comp->num_loops,
+ comp->num_spills,
+ comp->num_fills);
+ assert(ret >= 0);
+
+ if (lima_debug & LIMA_DEBUG_SHADERDB)
+ fprintf(stderr, "SHADER-DB: %s\n", shaderdb);
+
+ pipe_debug_message(debug, SHADER_INFO, "%s", shaderdb);
+ free(shaderdb);
+}
+
bool ppir_compile_nir(struct lima_fs_shader_state *prog, struct nir_shader *nir,
- struct ra_regs *ra)
+ struct ra_regs *ra,
+ const struct pipe_debug_callback *debug)
{
nir_function_impl *func = nir_shader_get_entrypoint(nir);
ppir_compiler *comp = ppir_compiler_create(prog, func->reg_alloc, func->ssa_alloc);
if (!ppir_codegen_prog(comp))
goto err_out0;
+ ppir_print_shader_db(nir, comp, debug);
+
ralloc_free(comp);
return true;
/* for regalloc spilling debug */
int force_spilling;
+ /* shaderdb */
+ int num_loops;
+ int num_spills;
+ int num_fills;
+
ppir_block *discard_block;
} ppir_compiler;
if (!load_node)
return NULL;
list_addtail(&load_node->list, &node->list);
+ comp->num_fills++;
ppir_load_node *load = ppir_node_to_load(load_node);
if (!load_node)
return NULL;
list_addtail(&load_node->list, &node->list);
+ comp->num_fills++;
ppir_load_node *load = ppir_node_to_load(load_node);
if (!store_node)
return false;
list_addtail(&store_node->list, &node->list);
+ comp->num_spills++;
ppir_store_node *store = ppir_node_to_store(store_node);
lima_create_fs_state(struct pipe_context *pctx,
const struct pipe_shader_state *cso)
{
+ struct lima_context *ctx = lima_context(pctx);
struct lima_screen *screen = lima_screen(pctx->screen);
struct lima_fs_shader_state *so = rzalloc(NULL, struct lima_fs_shader_state);
if (lima_debug & LIMA_DEBUG_PP)
nir_print_shader(nir, stdout);
- if (!ppir_compile_nir(so, nir, screen->pp_ra)) {
+ if (!ppir_compile_nir(so, nir, screen->pp_ra, &ctx->debug)) {
ralloc_free(so);
return NULL;
}
lima_create_vs_state(struct pipe_context *pctx,
const struct pipe_shader_state *cso)
{
+ struct lima_context *ctx = lima_context(pctx);
struct lima_vs_shader_state *so = rzalloc(NULL, struct lima_vs_shader_state);
if (!so)
if (lima_debug & LIMA_DEBUG_GP)
nir_print_shader(nir, stdout);
- if (!gpir_compile_nir(so, nir)) {
+ if (!gpir_compile_nir(so, nir, &ctx->debug)) {
ralloc_free(so);
return NULL;
}
"print PP shader compiler result of each stage" },
{ "dump", LIMA_DEBUG_DUMP,
"dump GPU command stream to $PWD/lima.dump" },
+ { "shaderdb", LIMA_DEBUG_SHADERDB,
+ "print shader information for shaderdb" },
{ NULL }
};
#define LIMA_DEBUG_GP (1 << 0)
#define LIMA_DEBUG_PP (1 << 1)
#define LIMA_DEBUG_DUMP (1 << 2)
+#define LIMA_DEBUG_SHADERDB (1 << 3)
extern uint32_t lima_debug;
extern FILE *lima_dump_command_stream;