diff options
author | Tom Stellard <[email protected]> | 2010-10-17 23:17:01 -0700 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2010-10-18 20:51:05 -0700 |
commit | f822cc22f223a0a4f9cf1cdd5871780e5df11d67 (patch) | |
tree | c6527323377efde526a8d8b44b19659d4a805b66 /src/mesa/drivers/dri | |
parent | 9d2ab6cb00e72fd8b53d0f97578758504b49ee23 (diff) |
r300g: Add new debug option for logging vertex/fragment program stats
Diffstat (limited to 'src/mesa/drivers/dri')
5 files changed, 70 insertions, 9 deletions
diff --git a/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c b/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c index 4793f335770..2f130198d35 100644 --- a/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c +++ b/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c @@ -145,8 +145,8 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c) {"final code validation", 0, 1, rc_validate_final_shader, NULL}, {"machine code generation", 0, is_r500, r500BuildFragmentProgramHwCode, NULL}, {"machine code generation", 0, !is_r500, r300BuildFragmentProgramHwCode, NULL}, - {"dump machine code", 0, is_r500 && c->Base.Debug, r500FragmentProgramDump, NULL}, - {"dump machine code", 0, !is_r500 && c->Base.Debug, r300FragmentProgramDump, NULL}, + {"dump machine code", 0, is_r500 && (c->Base.Debug & RC_DBG_LOG), r500FragmentProgramDump, NULL}, + {"dump machine code", 0, !is_r500 && (c->Base.Debug & RC_DBG_LOG), r300FragmentProgramDump, NULL}, {NULL, 0, 0, NULL, NULL} }; diff --git a/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c b/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c index d7d49e514b9..bf8341f0173 100644 --- a/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c +++ b/src/mesa/drivers/dri/r300/compiler/r3xx_vertprog.c @@ -1067,7 +1067,7 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c) {"dead constants", 1, kill_consts, rc_remove_unused_constants, &c->code->constants_remap_table}, {"final code validation", 0, 1, rc_validate_final_shader, NULL}, {"machine code generation", 0, 1, translate_vertex_program, NULL}, - {"dump machine code", 0,c->Base.Debug,r300_vertex_program_dump, NULL}, + {"dump machine code", 0, c->Base.Debug & RC_DBG_LOG, r300_vertex_program_dump, NULL}, {NULL, 0, 0, NULL, NULL} }; diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_compiler.c b/src/mesa/drivers/dri/r300/compiler/radeon_compiler.c index b410b2daf42..125d64e6497 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_compiler.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_compiler.c @@ -26,7 +26,9 @@ #include <stdio.h> #include <stdlib.h> +#include "radeon_dataflow.h" #include "radeon_program.h" +#include "radeon_program_pair.h" void rc_init(struct radeon_compiler * c) @@ -50,7 +52,7 @@ void rc_debug(struct radeon_compiler * c, const char * fmt, ...) { va_list ap; - if (!c->Debug) + if (!(c->Debug & RC_DBG_LOG)) return; va_start(ap, fmt); @@ -84,7 +86,7 @@ void rc_error(struct radeon_compiler * c, const char * fmt, ...) } } - if (c->Debug) { + if (c->Debug & RC_DBG_LOG) { fprintf(stderr, "r300compiler error: "); va_start(ap, fmt); @@ -351,11 +353,65 @@ void rc_transform_fragment_face(struct radeon_compiler *c, unsigned face) } } +static void reg_count_callback(void * userdata, struct rc_instruction * inst, + rc_register_file file, unsigned int index, unsigned int mask) +{ + unsigned int * max_reg = userdata; + if (file == RC_FILE_TEMPORARY) + index > *max_reg ? *max_reg = index : 0; +} + +static void print_stats(struct radeon_compiler * c) +{ + struct rc_instruction * tmp; + unsigned i, max_reg, insts, fc, tex, alpha, rgb, presub; + max_reg = insts = fc = tex = alpha = rgb = presub = 0; + for(tmp = c->Program.Instructions.Next; tmp != &c->Program.Instructions; + tmp = tmp->Next){ + const struct rc_opcode_info * info; + rc_for_all_reads_mask(tmp, reg_count_callback, &max_reg); + if (tmp->Type == RC_INSTRUCTION_NORMAL) { + if (tmp->U.I.PreSub.Opcode != RC_PRESUB_NONE) + presub++; + info = rc_get_opcode_info(tmp->U.I.Opcode); + } else { + if (tmp->U.P.RGB.Src[RC_PAIR_PRESUB_SRC].Used) + presub++; + if (tmp->U.P.Alpha.Src[RC_PAIR_PRESUB_SRC].Used) + presub++; + /* Assuming alpha will never be a flow control or + * a tex instruction. */ + if (tmp->U.P.Alpha.Opcode != RC_OPCODE_NOP) + alpha++; + if (tmp->U.P.RGB.Opcode != RC_OPCODE_NOP) + rgb++; + info = rc_get_opcode_info(tmp->U.P.RGB.Opcode); + } + if (info->IsFlowControl) + fc++; + if (info->HasTexture) + tex++; + insts++; + } + if (insts < 4) + return; + fprintf(stderr,"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" + "~%4u Instructions\n" + "~%4u Vector Instructions (RGB)\n" + "~%4u Scalar Instructions (Alpha)\n" + "~%4u Flow Control Instructions\n" + "~%4u Texture Instructions\n" + "~%4u Presub Operations\n" + "~%4u Temporary Registers\n" + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", + insts, rgb, alpha, fc, tex, presub, max_reg + 1); +} + /* Executes a list of compiler passes given in the parameter 'list'. */ void rc_run_compiler(struct radeon_compiler *c, struct radeon_compiler_pass *list, const char *shader_name) { - if (c->Debug) { + if (c->Debug & RC_DBG_LOG) { fprintf(stderr, "%s: before compilation\n", shader_name); rc_print_program(&c->Program); } @@ -367,12 +423,14 @@ void rc_run_compiler(struct radeon_compiler *c, struct radeon_compiler_pass *lis if (c->Error) return; - if (c->Debug && list[i].dump) { + if ((c->Debug & RC_DBG_LOG) && list[i].dump) { fprintf(stderr, "%s: after '%s'\n", shader_name, list[i].name); rc_print_program(&c->Program); } } } + if (c->Debug & RC_DBG_STATS) + print_stats(c); } void rc_validate_final_shader(struct radeon_compiler *c, void *user) diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h b/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h index 6d96ac9fdd9..31fd469a04f 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h +++ b/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h @@ -30,12 +30,15 @@ #include "radeon_program.h" #include "radeon_emulate_loops.h" +#define RC_DBG_LOG (1 << 0) +#define RC_DBG_STATS (1 << 1) + struct rc_swizzle_caps; struct radeon_compiler { struct memory_pool Pool; struct rc_program Program; - unsigned Debug:1; + unsigned Debug:2; unsigned Error:1; char * ErrorMsg; diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_remove_constants.c b/src/mesa/drivers/dri/r300/compiler/radeon_remove_constants.c index d6c808ad815..5f67f536f61 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_remove_constants.c +++ b/src/mesa/drivers/dri/r300/compiler/radeon_remove_constants.c @@ -145,6 +145,6 @@ void rc_remove_unused_constants(struct radeon_compiler *c, void *user) free(const_used); free(inv_remap_table); - if (c->Debug) + if (c->Debug & RC_DBG_LOG) rc_constants_print(&c->Program.Constants); } |