static void si_dump_shader(struct si_screen *sscreen,
struct si_shader_ctx_state *state, FILE *f)
{
- if (!state->cso || !state->current)
+ struct si_shader *current = state->current;
+
+ if (!state->cso || !current)
return;
- si_shader_dump(sscreen, state->current, NULL,
- state->cso->info.processor, f);
+ if (current->shader_log)
+ fwrite(current->shader_log, current->shader_log_size, 1, f);
+ else
+ si_shader_dump(sscreen, state->current, NULL,
+ state->cso->info.processor, f);
}
/**
* if thread_index == -1 (non-threaded). */
LLVMTargetMachineRef tm;
struct pipe_debug_callback debug;
+ bool is_debug_context;
pipe_mutex mutex;
struct si_shader *first_variant; /* immutable after the first variant */
struct radeon_shader_binary binary;
struct si_shader_config config;
struct si_shader_info info;
+
+ /* Shader key + LLVM IR + disassembly + statistics.
+ * Generated for debug contexts only.
+ */
+ char *shader_log;
+ size_t shader_log_size;
};
struct si_shader_part {
union si_shader_key *key,
LLVMTargetMachineRef tm,
struct pipe_debug_callback *debug,
- bool wait)
+ bool wait,
+ bool is_debug_context)
{
struct si_shader_selector *sel = state->cso;
struct si_shader *current = state->current;
pipe_mutex_unlock(sel->mutex);
return r;
}
+
+ if (is_debug_context) {
+ FILE *f = open_memstream(&shader->shader_log,
+ &shader->shader_log_size);
+ if (f) {
+ si_shader_dump(sscreen, shader, NULL, sel->type, f);
+ fclose(f);
+ }
+ }
+
si_shader_init_pm4_state(sscreen, shader);
if (!sel->last_variant) {
si_shader_selector_key(ctx, state->cso, &key);
return si_shader_select_with_key(sctx->screen, state, &key,
- sctx->tm, &sctx->b.debug, true);
+ sctx->tm, &sctx->b.debug, true,
+ sctx->is_debug);
}
static void si_parse_next_shader_property(const struct tgsi_shader_info *info,
}
if (si_shader_select_with_key(sscreen, &state, &key, tm, debug,
- false))
+ false, sel->is_debug_context))
fprintf(stderr, "radeonsi: can't create a monolithic shader\n");
}
}
sel->screen = sscreen;
sel->tm = sctx->tm;
sel->debug = sctx->b.debug;
+ sel->is_debug_context = sctx->is_debug;
sel->tokens = tgsi_dup_tokens(state->tokens);
if (!sel->tokens) {
FREE(sel);
util_queue_fence_init(&sel->ready);
if ((sctx->b.debug.debug_message && !sctx->b.debug.async) ||
+ sctx->is_debug ||
r600_can_dump_shader(&sscreen->b, sel->info.processor) ||
!util_queue_is_initialized(&sscreen->shader_compiler_queue))
si_init_shader_selector_async(sel, -1);