{"nobin", FD_DBG_NOBIN, "Disable hw binning"},
{"optmsgs", FD_DBG_OPTMSGS,"Enable optimizer debug messages"},
{"glsl120", FD_DBG_GLSL120,"Temporary flag to force GLSL 1.20 (rather than 1.30) on a3xx+"},
+ {"shaderdb", FD_DBG_SHADERDB, "Enable shaderdb output"},
DEBUG_NAMED_VALUE_END
};
#define FD_DBG_NOBIN 0x0100
#define FD_DBG_OPTMSGS 0x0200
#define FD_DBG_GLSL120 0x0400
+#define FD_DBG_SHADERDB 0x0800
extern int fd_mesa_debug;
extern bool fd_binning_enabled;
static void dump_info(struct ir3_shader_variant *so, const char *str)
{
uint32_t *bin;
- const char *type = (so->type == SHADER_VERTEX) ? "VERT" : "FRAG";
+ const char *type = ir3_shader_stage(so->shader);
// TODO make gpu_id configurable on cmdline
bin = ir3_shader_assemble(so, 320);
debug_printf("; %s: %s\n", type, str);
struct tgsi_parse_context parse;
struct ir3_compiler *compiler;
struct ir3_shader_variant v;
+ struct ir3_shader s;
struct ir3_shader_key key = {};
const char *info;
void *ptr;
memset(&v, 0, sizeof(v));
v.key = key;
+ v.shader = &s;
ret = read_file(filename, &ptr, &size);
if (ret) {
tgsi_parse_init(&parse, toks);
switch (parse.FullHeader.Processor.Processor) {
case TGSI_PROCESSOR_FRAGMENT:
- v.type = SHADER_FRAGMENT;
+ s.type = v.type = SHADER_FRAGMENT;
break;
case TGSI_PROCESSOR_VERTEX:
- v.type = SHADER_VERTEX;
+ s.type = v.type = SHADER_VERTEX;
break;
case TGSI_PROCESSOR_COMPUTE:
- v.type = SHADER_COMPUTE;
+ s.type = v.type = SHADER_COMPUTE;
break;
}
struct ir3_compiler {
uint32_t gpu_id;
struct ir3_ra_reg_set *set;
+ uint32_t shader_count;
};
struct ir3_compiler * ir3_compiler_create(uint32_t gpu_id);
unsigned semantic_index = in->data.index;
unsigned n = in->data.driver_location;
- DBG("; in: %u:%u, len=%ux%u, loc=%u\n",
+ DBG("; in: %u:%u, len=%ux%u, loc=%u",
semantic_name, semantic_index, array_len,
ncomp, n);
unsigned n = out->data.driver_location;
unsigned comp = 0;
- DBG("; out: %u:%u, len=%ux%u, loc=%u\n",
+ DBG("; out: %u:%u, len=%ux%u, loc=%u",
semantic_name, semantic_index, array_len,
ncomp, n);
ir3_shader_disasm(v, bin);
}
+ if (fd_mesa_debug & FD_DBG_SHADERDB) {
+ /* print generic shader info: */
+ fprintf(stderr, "SHADER-DB: %s prog %d/%d: %u instructions, %u dwords\n",
+ ir3_shader_stage(v->shader),
+ v->shader->id, v->id,
+ v->info.instrs_count,
+ v->info.sizedwords);
+ fprintf(stderr, "SHADER-DB: %s prog %d/%d: %u half, %u full\n",
+ ir3_shader_stage(v->shader),
+ v->shader->id, v->id,
+ v->info.max_half_reg + 1,
+ v->info.max_reg + 1);
+ fprintf(stderr, "SHADER-DB: %s prog %d/%d: %u const, %u constlen\n",
+ ir3_shader_stage(v->shader),
+ v->shader->id, v->id,
+ v->info.max_const + 1,
+ v->constlen);
+ }
+
free(bin);
/* no need to keep the ir around beyond this point: */
if (!v)
return NULL;
+ v->id = ++shader->variant_count;
v->shader = shader;
v->key = key;
v->type = shader->type;
{
struct ir3_shader *shader = CALLOC_STRUCT(ir3_shader);
shader->compiler = fd_context(pctx)->screen->compiler;
+ shader->id = ++shader->compiler->shader_count;
shader->pctx = pctx;
shader->type = type;
shader->tokens = tgsi_dup_tokens(tokens);
+ if (fd_mesa_debug & FD_DBG_SHADERDB) {
+ /* if shader-db run, create a standard variant immediately
+ * (as otherwise nothing will trigger the shader to be
+ * actually compiled)
+ */
+ static struct ir3_shader_key key = {};
+ ir3_shader_variant(shader, key);
+ }
return shader;
}
{
struct ir3 *ir = so->ir;
struct ir3_register *reg;
- const char *type = (so->type == SHADER_VERTEX) ? "VERT" : "FRAG";
+ const char *type = ir3_shader_stage(so->shader);
uint8_t regid;
unsigned i;
debug_printf("\n");
/* print generic shader info: */
- debug_printf("; %s: %u instructions, %d half, %d full\n", type,
+ debug_printf("; %s prog %d/%d: %u instructions, %d half, %d full\n",
+ type, so->shader->id, so->id,
so->info.instrs_count,
so->info.max_half_reg + 1,
so->info.max_reg + 1);
+ debug_printf("; %d const, %u constlen\n",
+ so->info.max_const + 1,
+ so->constlen);
+
/* print shader type specific info: */
switch (so->type) {
case SHADER_VERTEX:
struct ir3_shader_variant {
struct fd_bo *bo;
+ /* variant id (for debug) */
+ uint32_t id;
+
struct ir3_shader_key key;
struct ir3_info info;
struct ir3_shader {
enum shader_t type;
+ /* shader id (for debug): */
+ uint32_t id;
+ uint32_t variant_count;
+
struct ir3_compiler *compiler;
struct pipe_context *pctx;
struct ir3_shader_key key);
void ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin);
+static inline const char *
+ir3_shader_stage(struct ir3_shader *shader)
+{
+ switch (shader->type) {
+ case SHADER_VERTEX: return "VERT";
+ case SHADER_FRAGMENT: return "FRAG";
+ case SHADER_COMPUTE: return "CL";
+ default:
+ unreachable("invalid type");
+ return NULL;
+ }
+}
+
/*
* Helper/util:
*/