#define ETNA_DBG_FLUSH_ALL 0x100000 /* Flush after every rendered primitive */
#define ETNA_DBG_ZERO 0x200000 /* Zero all resources after allocation */
#define ETNA_DBG_DRAW_STALL 0x400000 /* Stall FE/PE after every draw op */
+#define ETNA_DBG_SHADERDB 0x800000 /* dump program compile information */
extern int etna_mesa_debug; /* set in etna_screen.c from ETNA_DEBUG */
{"flush_all", ETNA_DBG_FLUSH_ALL, "Flush after every rendered primitive"},
{"zero", ETNA_DBG_ZERO, "Zero all resources after allocation"},
{"draw_stall", ETNA_DBG_DRAW_STALL, "Stall FE/PE after each rendered primitive"},
+ {"shaderdb", ETNA_DBG_SHADERDB, "Enable shaderdb output"},
DEBUG_NAMED_VALUE_END
};
return true;
}
+static inline const char *
+etna_shader_stage(struct etna_shader *shader)
+{
+ switch (shader->processor) {
+ case PIPE_SHADER_VERTEX: return "VERT";
+ case PIPE_SHADER_FRAGMENT: return "FRAG";
+ case PIPE_SHADER_COMPUTE: return "CL";
+ default:
+ unreachable("invalid type");
+ return NULL;
+ }
+}
+
+static void
+dump_shader_info(struct etna_shader *shader, struct pipe_debug_callback *debug)
+{
+ if (!unlikely(etna_mesa_debug & ETNA_DBG_SHADERDB))
+ return;
+
+ pipe_debug_message(debug, SHADER_INFO, "\n"
+ "SHADER-DB: %s prog %d: %u instructions %u temps\n"
+ "SHADER-DB: %s prog %d: %u immediates %u consts\n"
+ "SHADER-DB: %s prog %d: %u loops\n",
+ etna_shader_stage(shader),
+ shader->id,
+ shader->code_size,
+ shader->num_temps,
+ etna_shader_stage(shader),
+ shader->id,
+ shader->uniforms.imm_count,
+ shader->uniforms.const_count,
+ etna_shader_stage(shader),
+ shader->id,
+ shader->num_loops);
+}
+
bool
etna_shader_update_vertex(struct etna_context *ctx)
{
const struct pipe_shader_state *pss)
{
struct etna_context *ctx = etna_context(pctx);
+ struct etna_shader *shader = etna_compile_shader(&ctx->specs, pss->tokens);
+
+ static uint32_t id;
+ shader->id = id++;
+
+ dump_shader_info(shader, &ctx->debug);
- return etna_compile_shader(&ctx->specs, pss->tokens);
+ return shader;
}
static void