aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/radeonsi/si_hw_context.c
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2017-08-04 18:24:33 +0200
committerNicolai Hähnle <[email protected]>2017-08-22 09:53:14 +0200
commit4c3f36ec6b59de2245257c819df7628aaa6bf57b (patch)
treec7e8c49a472da3bf0f0d763044c95feeaf53356a /src/gallium/drivers/radeonsi/si_hw_context.c
parentbc933397996c9591ef92cb1eae62e909b111d04f (diff)
radeonsi: print saved CS to the log context
Use the auto logger facility, so that CS chunks will be interleaved with other log info. v2: - fix some crashes when not using CE - fix skipping "previous" chunks of current (unflushed) IB - fix error handling in si_begin_cs_debug Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/si_hw_context.c')
-rw-r--r--src/gallium/drivers/radeonsi/si_hw_context.c67
1 files changed, 46 insertions, 21 deletions
diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c b/src/gallium/drivers/radeonsi/si_hw_context.c
index d9170c30954..7481d013f3c 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -57,6 +57,14 @@ static unsigned si_ce_needed_cs_space(void)
return space;
}
+void si_destroy_saved_cs(struct si_saved_cs *scs)
+{
+ radeon_clear_saved_cs(&scs->gfx);
+ radeon_clear_saved_cs(&scs->ce);
+ r600_resource_reference(&scs->trace_buf, NULL);
+ free(scs);
+}
+
/* initialize */
void si_need_cs_space(struct si_context *ctx)
{
@@ -139,17 +147,15 @@ void si_context_gfx_flush(void *context, unsigned flags,
si_emit_cache_flush(ctx);
- if (ctx->trace_buf)
+ if (ctx->current_saved_cs) {
si_trace_emit(ctx);
+ si_log_hw_flush(ctx);
- if (ctx->is_debug) {
/* Save the IB for debug contexts. */
- radeon_clear_saved_cs(&ctx->last_gfx);
- radeon_save_cs(ws, cs, &ctx->last_gfx, true);
- radeon_clear_saved_cs(&ctx->last_ce);
- radeon_save_cs(ws, ctx->ce_ib, &ctx->last_ce, false);
- r600_resource_reference(&ctx->last_trace_buf, ctx->trace_buf);
- r600_resource_reference(&ctx->trace_buf, NULL);
+ radeon_save_cs(ws, cs, &ctx->current_saved_cs->gfx, true);
+ if (ctx->ce_ib)
+ radeon_save_cs(ws, ctx->ce_ib, &ctx->current_saved_cs->ce, false);
+ ctx->current_saved_cs->flushed = true;
}
/* Flush the CS. */
@@ -165,31 +171,50 @@ void si_context_gfx_flush(void *context, unsigned flags,
*/
ctx->b.ws->fence_wait(ctx->b.ws, ctx->b.last_gfx_fence, 800*1000*1000);
- si_check_vm_faults(&ctx->b, &ctx->last_gfx, RING_GFX);
+ si_check_vm_faults(&ctx->b, &ctx->current_saved_cs->gfx, RING_GFX);
}
+ if (ctx->current_saved_cs)
+ si_saved_cs_reference(&ctx->current_saved_cs, NULL);
+
si_begin_new_cs(ctx);
ctx->gfx_flush_in_progress = false;
}
-void si_begin_new_cs(struct si_context *ctx)
+static void si_begin_cs_debug(struct si_context *ctx)
{
- if (ctx->is_debug) {
- static const uint32_t zeros[2];
+ static const uint32_t zeros[2];
+ assert(!ctx->current_saved_cs);
+
+ ctx->current_saved_cs = calloc(1, sizeof(*ctx->current_saved_cs));
+ if (!ctx->current_saved_cs)
+ return;
+
+ pipe_reference_init(&ctx->current_saved_cs->reference, 1);
- /* Create a buffer used for writing trace IDs and initialize it to 0. */
- assert(!ctx->trace_buf);
- ctx->trace_buf = (struct r600_resource*)
+ ctx->current_saved_cs->trace_buf = (struct r600_resource*)
pipe_buffer_create(ctx->b.b.screen, 0,
PIPE_USAGE_STAGING, 8);
- if (ctx->trace_buf)
- pipe_buffer_write_nooverlap(&ctx->b.b, &ctx->trace_buf->b.b,
- 0, sizeof(zeros), zeros);
- ctx->trace_id = 0;
+ if (!ctx->current_saved_cs->trace_buf) {
+ free(ctx->current_saved_cs);
+ ctx->current_saved_cs = NULL;
+ return;
}
- if (ctx->trace_buf)
- si_trace_emit(ctx);
+ pipe_buffer_write_nooverlap(&ctx->b.b, &ctx->current_saved_cs->trace_buf->b.b,
+ 0, sizeof(zeros), zeros);
+ ctx->current_saved_cs->trace_id = 0;
+
+ si_trace_emit(ctx);
+
+ radeon_add_to_buffer_list(&ctx->b, &ctx->b.gfx, ctx->current_saved_cs->trace_buf,
+ RADEON_USAGE_READWRITE, RADEON_PRIO_TRACE);
+}
+
+void si_begin_new_cs(struct si_context *ctx)
+{
+ if (ctx->is_debug)
+ si_begin_cs_debug(ctx);
/* Flush read caches at the beginning of CS not flushed by the kernel. */
if (ctx->b.chip_class >= CIK)