mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 22:49:13 +02:00
pan/decode: Hoist shader-db stats to shared decode
We'll want all this information to validate the shader descriptor. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
parent
a8f86fcb51
commit
58fc260312
4 changed files with 70 additions and 38 deletions
|
|
@ -44,7 +44,7 @@ static bool is_instruction_int = false;
|
|||
|
||||
/* Stats */
|
||||
|
||||
static unsigned nr_ins = 0;
|
||||
static struct midgard_disasm_stats midg_stats;
|
||||
|
||||
/* Prints a short form of the tag for branching, the minimum needed to be
|
||||
* legible and unambiguous */
|
||||
|
|
@ -554,7 +554,7 @@ print_vector_field(const char *name, uint16_t *words, uint16_t reg_word,
|
|||
reg_info->src2_reg, override, is_int);
|
||||
}
|
||||
|
||||
nr_ins++;
|
||||
midg_stats.instruction_count++;
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
|
@ -635,7 +635,7 @@ print_scalar_field(const char *name, uint16_t *words, uint16_t reg_word,
|
|||
} else
|
||||
print_scalar_src(alu_field->src2, reg_info->src2_reg);
|
||||
|
||||
nr_ins++;
|
||||
midg_stats.instruction_count++;
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
|
@ -744,7 +744,7 @@ print_compact_branch_writeout_field(uint16_t word)
|
|||
}
|
||||
}
|
||||
|
||||
nr_ins++;
|
||||
midg_stats.instruction_count++;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -782,7 +782,7 @@ print_extended_branch_writeout_field(uint8_t *words)
|
|||
print_tag_short(br.dest_tag);
|
||||
printf("\n");
|
||||
|
||||
nr_ins++;
|
||||
midg_stats.instruction_count++;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
|
|
@ -1061,7 +1061,7 @@ print_load_store_instr(uint64_t data,
|
|||
print_load_store_arg(word->arg_2, 1);
|
||||
printf(" /* %X */\n", word->varying_parameters);
|
||||
|
||||
nr_ins++;
|
||||
midg_stats.instruction_count++;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1349,11 +1349,11 @@ print_texture_word(uint32_t *word, unsigned tabs)
|
|||
printf("// unknown8 = 0x%x\n", texture->unknown8);
|
||||
}
|
||||
|
||||
nr_ins++;
|
||||
midg_stats.instruction_count++;
|
||||
}
|
||||
|
||||
void
|
||||
disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned nr_registers, const char *prefix)
|
||||
struct midgard_disasm_stats
|
||||
disassemble_midgard(uint8_t *code, size_t size)
|
||||
{
|
||||
uint32_t *words = (uint32_t *) code;
|
||||
unsigned num_words = size / 4;
|
||||
|
|
@ -1366,9 +1366,7 @@ disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned nr_register
|
|||
unsigned i = 0;
|
||||
|
||||
/* Stats for shader-db */
|
||||
unsigned nr_bundles = 0;
|
||||
unsigned nr_quadwords = 0;
|
||||
nr_ins = 0;
|
||||
memset(&midg_stats, 0, sizeof(midg_stats));
|
||||
|
||||
while (i < num_words) {
|
||||
unsigned tag = words[i] & 0xF;
|
||||
|
|
@ -1424,8 +1422,8 @@ disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned nr_register
|
|||
unsigned next = (words[i] & 0xF0) >> 4;
|
||||
|
||||
/* We are parsing per bundle anyway */
|
||||
nr_bundles++;
|
||||
nr_quadwords += num_quad_words;
|
||||
midg_stats.bundle_count++;
|
||||
midg_stats.quadword_count += num_quad_words;
|
||||
|
||||
/* Break based on instruction prefetch flag */
|
||||
|
||||
|
|
@ -1439,18 +1437,5 @@ disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned nr_register
|
|||
i += 4 * num_quad_words;
|
||||
}
|
||||
|
||||
if (stats) {
|
||||
unsigned nr_threads =
|
||||
(nr_registers <= 4) ? 4 :
|
||||
(nr_registers <= 8) ? 2 :
|
||||
1;
|
||||
|
||||
printf("%s"
|
||||
"%u inst, %u bundles, %u quadwords, "
|
||||
"%u registers, %u threads, 0 loops\n",
|
||||
prefix,
|
||||
nr_ins, nr_bundles, nr_quadwords,
|
||||
nr_registers, nr_threads);
|
||||
|
||||
}
|
||||
return midg_stats;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,23 @@
|
|||
#include <stddef.h>
|
||||
void disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned regs, const char *prefix);
|
||||
|
||||
struct midgard_disasm_stats {
|
||||
/* Counts gleaned from disassembly, or negative if the field cannot be
|
||||
* inferred, for instance due to indirect access. If negative, the abs
|
||||
* is the upper limit for the count. */
|
||||
|
||||
signed texture_count;
|
||||
signed sampler_count;
|
||||
signed attribute_count;
|
||||
signed varying_count;
|
||||
signed uniform_count;
|
||||
signed uniform_buffer_count;
|
||||
signed work_count;
|
||||
|
||||
/* These are pseudometrics for shader-db */
|
||||
unsigned instruction_count;
|
||||
unsigned bundle_count;
|
||||
unsigned quadword_count;
|
||||
};
|
||||
|
||||
struct midgard_disasm_stats
|
||||
disassemble_midgard(uint8_t *code, size_t size);
|
||||
|
|
|
|||
|
|
@ -2810,7 +2810,7 @@ midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midga
|
|||
program->tls_size = ctx->tls_size;
|
||||
|
||||
if (midgard_debug & MIDGARD_DBG_SHADERS)
|
||||
disassemble_midgard(program->compiled.data, program->compiled.size, false, 0, "");
|
||||
disassemble_midgard(program->compiled.data, program->compiled.size);
|
||||
|
||||
if (midgard_debug & MIDGARD_DBG_SHADERDB) {
|
||||
unsigned nr_bundles = 0, nr_ins = 0, nr_quadwords = 0;
|
||||
|
|
|
|||
|
|
@ -1720,7 +1720,7 @@ pandecode_scratchpad(uintptr_t pscratchpad, int job_no, char *suffix)
|
|||
|
||||
static unsigned shader_id = 0;
|
||||
|
||||
static void
|
||||
static struct midgard_disasm_stats
|
||||
pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type,
|
||||
bool is_bifrost, unsigned nr_regs)
|
||||
{
|
||||
|
|
@ -1735,19 +1735,45 @@ pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type,
|
|||
|
||||
printf("\n\n");
|
||||
|
||||
char prefix[512];
|
||||
|
||||
snprintf(prefix, sizeof(prefix) - 1, "shader%d - %s shader: ",
|
||||
shader_id++,
|
||||
(type == JOB_TYPE_TILER) ? "FRAGMENT" : "VERTEX");
|
||||
struct midgard_disasm_stats stats;
|
||||
|
||||
if (is_bifrost) {
|
||||
disassemble_bifrost(code, sz, false);
|
||||
|
||||
/* TODO: Extend stats to Bifrost */
|
||||
stats.texture_count = -1;
|
||||
stats.sampler_count = -1;
|
||||
stats.attribute_count = -1;
|
||||
stats.varying_count = -1;
|
||||
stats.uniform_count = -1;
|
||||
stats.uniform_buffer_count = -1;
|
||||
stats.work_count = -1;
|
||||
|
||||
stats.instruction_count = 0;
|
||||
stats.bundle_count = 0;
|
||||
stats.quadword_count = 0;
|
||||
} else {
|
||||
disassemble_midgard(code, sz, true, nr_regs, prefix);
|
||||
stats = disassemble_midgard(code, sz);
|
||||
stats.work_count = nr_regs;
|
||||
}
|
||||
|
||||
printf("\n\n");
|
||||
/* Print shader-db stats */
|
||||
|
||||
unsigned nr_threads =
|
||||
(stats.work_count <= 4) ? 4 :
|
||||
(stats.work_count <= 8) ? 2 :
|
||||
1;
|
||||
|
||||
printf("shader%d - %s shader: "
|
||||
"%u inst, %u bundles, %u quadwords, "
|
||||
"%u registers, %u threads, 0 loops\n\n\n",
|
||||
shader_id++,
|
||||
(type == JOB_TYPE_TILER) ? "FRAGMENT" : "VERTEX",
|
||||
stats.instruction_count, stats.bundle_count, stats.quadword_count,
|
||||
stats.work_count, nr_threads);
|
||||
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue