lima: add summary report for shader-db
Very basic summary, loops and gpir spills:fills are not updated yet and are only there to comply with the strings to shader-db report.py regex. For now it can be used to analyze the impact of changes in instruction count in both gpir and ppir. The LIMA_DEBUG=shaderdb setting can be useful to output stats on applications other than shader-db. Signed-off-by: Erico Nunes <nunes.erico@gmail.com> Reviewed-by: Qiang Yu <yuq825@gmail.com>
This commit is contained in:
@@ -602,6 +602,7 @@ bool gpir_codegen_prog(gpir_compiler *comp)
|
||||
|
||||
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);
|
||||
|
@@ -388,6 +388,12 @@ typedef struct gpir_compiler {
|
||||
|
||||
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
|
||||
|
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "util/ralloc.h"
|
||||
#include "compiler/nir/nir.h"
|
||||
#include "pipe/p_state.h"
|
||||
|
||||
|
||||
#include "gpir.h"
|
||||
#include "lima_context.h"
|
||||
@@ -396,7 +398,29 @@ static int gpir_glsl_type_size(enum glsl_base_type type)
|
||||
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);
|
||||
@@ -446,6 +470,8 @@ bool gpir_compile_nir(struct lima_vs_shader_state *prog, struct nir_shader *nir)
|
||||
v->components += glsl_get_components(var->type);
|
||||
}
|
||||
|
||||
gpir_print_shader_db(nir, comp, debug);
|
||||
|
||||
ralloc_free(comp);
|
||||
return true;
|
||||
|
||||
|
@@ -53,12 +53,14 @@ struct lima_vs_shader_state;
|
||||
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);
|
||||
|
@@ -27,6 +27,8 @@
|
||||
#include "util/ralloc.h"
|
||||
#include "util/bitscan.h"
|
||||
#include "compiler/nir/nir.h"
|
||||
#include "pipe/p_state.h"
|
||||
|
||||
|
||||
#include "ppir.h"
|
||||
|
||||
@@ -562,8 +564,30 @@ static void ppir_add_ordering_deps(ppir_compiler *comp)
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -611,6 +635,8 @@ bool ppir_compile_nir(struct lima_fs_shader_state *prog, struct nir_shader *nir,
|
||||
if (!ppir_codegen_prog(comp))
|
||||
goto err_out0;
|
||||
|
||||
ppir_print_shader_db(nir, comp, debug);
|
||||
|
||||
ralloc_free(comp);
|
||||
return true;
|
||||
|
||||
|
@@ -346,6 +346,11 @@ typedef struct ppir_compiler {
|
||||
/* for regalloc spilling debug */
|
||||
int force_spilling;
|
||||
|
||||
/* shaderdb */
|
||||
int num_loops;
|
||||
int num_spills;
|
||||
int num_fills;
|
||||
|
||||
ppir_block *discard_block;
|
||||
} ppir_compiler;
|
||||
|
||||
|
@@ -392,6 +392,7 @@ static ppir_alu_node* ppir_update_spilled_src(ppir_compiler *comp,
|
||||
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);
|
||||
|
||||
@@ -484,6 +485,7 @@ static bool ppir_update_spilled_dest(ppir_compiler *comp, ppir_block *block,
|
||||
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);
|
||||
|
||||
@@ -533,6 +535,7 @@ static bool ppir_update_spilled_dest(ppir_compiler *comp, ppir_block *block,
|
||||
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);
|
||||
|
||||
|
@@ -214,6 +214,7 @@ static void *
|
||||
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);
|
||||
|
||||
@@ -234,7 +235,7 @@ lima_create_fs_state(struct pipe_context *pctx,
|
||||
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;
|
||||
}
|
||||
@@ -306,6 +307,7 @@ static void *
|
||||
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)
|
||||
@@ -325,7 +327,7 @@ lima_create_vs_state(struct pipe_context *pctx,
|
||||
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;
|
||||
}
|
||||
|
@@ -440,6 +440,8 @@ static const struct debug_named_value debug_options[] = {
|
||||
"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 }
|
||||
};
|
||||
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#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;
|
||||
|
Reference in New Issue
Block a user