r600g,radeonsi: consolidate variables for CS tracing
authorMarek Olšák <marek.olsak@amd.com>
Wed, 22 Jan 2014 01:02:18 +0000 (02:02 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 28 Jan 2014 00:39:42 +0000 (01:39 +0100)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/drivers/r600/r600_hw_context.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeonsi/si_hw_context.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_pm4.c
src/gallium/drivers/radeonsi/si_state_draw.c

index d6b0280affaf9be225f38b9cd13a7f4f2a56e061..9b0c558c29e01113412497426ca653e873fa6e4c 100644 (file)
@@ -54,7 +54,7 @@ void r600_need_cs_space(struct r600_context *ctx, unsigned num_dw,
                for (i = 0; i < R600_NUM_ATOMS; i++) {
                        if (ctx->atoms[i] && ctx->atoms[i]->dirty) {
                                num_dw += ctx->atoms[i]->num_dw;
-                               if (ctx->screen->trace_bo) {
+                               if (ctx->screen->b.trace_bo) {
                                        num_dw += R600_TRACE_CS_DWORDS;
                                }
                        }
@@ -62,7 +62,7 @@ void r600_need_cs_space(struct r600_context *ctx, unsigned num_dw,
 
                /* The upper-bound of how much space a draw command would take. */
                num_dw += R600_MAX_FLUSH_CS_DWORDS + R600_MAX_DRAW_CS_DWORDS;
-               if (ctx->screen->trace_bo) {
+               if (ctx->screen->b.trace_bo) {
                        num_dw += R600_TRACE_CS_DWORDS;
                }
        }
@@ -270,7 +270,7 @@ void r600_context_flush(struct r600_context *ctx, unsigned flags)
        }
 
        /* Flush the CS. */
-       ctx->b.ws->cs_flush(ctx->b.rings.gfx.cs, flags, ctx->screen->cs_count++);
+       ctx->b.ws->cs_flush(ctx->b.rings.gfx.cs, flags, ctx->screen->b.cs_count++);
 }
 
 void r600_begin_new_cs(struct r600_context *ctx)
index a7138969d96d957fc8aff439016a110c63f3cd8f..eec04bfaebbbe6cf935dd23fec51c5ec32cf5164 100644 (file)
@@ -259,8 +259,8 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
                goto fail;
        }
 
-       if (rscreen->trace_bo) {
-               rctx->b.rings.gfx.cs = rctx->b.ws->cs_create(rctx->b.ws, RING_GFX, rscreen->trace_bo->cs_buf);
+       if (rscreen->b.trace_bo) {
+               rctx->b.rings.gfx.cs = rctx->b.ws->cs_create(rctx->b.ws, RING_GFX, rscreen->b.trace_bo->cs_buf);
        } else {
                rctx->b.rings.gfx.cs = rctx->b.ws->cs_create(rctx->b.ws, RING_GFX, NULL);
        }
@@ -743,9 +743,9 @@ static void r600_destroy_screen(struct pipe_screen* pscreen)
                compute_memory_pool_delete(rscreen->global_pool);
        }
 
-       if (rscreen->trace_bo) {
-               rscreen->b.ws->buffer_unmap(rscreen->trace_bo->cs_buf);
-               pipe_resource_reference((struct pipe_resource**)&rscreen->trace_bo, NULL);
+       if (rscreen->b.trace_bo) {
+               rscreen->b.ws->buffer_unmap(rscreen->b.trace_bo->cs_buf);
+               pipe_resource_reference((struct pipe_resource**)&rscreen->b.trace_bo, NULL);
        }
 
        rscreen->b.ws->destroy(rscreen->b.ws);
@@ -860,14 +860,14 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
 
        rscreen->global_pool = compute_memory_pool_new(rscreen);
 
-       rscreen->cs_count = 0;
+       rscreen->b.cs_count = 0;
        if (rscreen->b.info.drm_minor >= 28 && (rscreen->b.debug_flags & DBG_TRACE_CS)) {
-               rscreen->trace_bo = (struct r600_resource*)pipe_buffer_create(&rscreen->b.b,
+               rscreen->b.trace_bo = (struct r600_resource*)pipe_buffer_create(&rscreen->b.b,
                                                                                PIPE_BIND_CUSTOM,
                                                                                PIPE_USAGE_STAGING,
                                                                                4096);
-               if (rscreen->trace_bo) {
-                       rscreen->trace_ptr = rscreen->b.ws->buffer_map(rscreen->trace_bo->cs_buf, NULL,
+               if (rscreen->b.trace_bo) {
+                       rscreen->b.trace_ptr = rscreen->b.ws->buffer_map(rscreen->b.trace_bo->cs_buf, NULL,
                                                                        PIPE_TRANSFER_UNSYNCHRONIZED);
                }
        }
index 101d7405ee134c0e5ae74f548aa7d169467919e1..112cb269d85d08bcac4a8718cfee6c2f6b8a378d 100644 (file)
@@ -204,9 +204,6 @@ struct r600_screen {
         * XXX: Not sure if this is the best place for global_pool.  Also,
         * it's not thread safe, so it won't work with multiple contexts. */
        struct compute_memory_pool *global_pool;
-       struct r600_resource            *trace_bo;
-       uint32_t                        *trace_ptr;
-       unsigned                        cs_count;
 };
 
 struct r600_pipe_sampler_view {
@@ -461,7 +458,7 @@ static INLINE void r600_emit_atom(struct r600_context *rctx, struct r600_atom *a
 {
        atom->emit(&rctx->b, atom);
        atom->dirty = false;
-       if (rctx->screen->trace_bo) {
+       if (rctx->screen->b.trace_bo) {
                r600_trace_emit(rctx);
        }
 }
index 3a6f16753f445cd8349342e3b2c6550220709ad6..d8fab1083e1fb4ddb9cad2c87f06d0642191d162 100644 (file)
@@ -1389,7 +1389,7 @@ static void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info
                                        (info.count_from_stream_output ? S_0287F0_USE_OPAQUE(1) : 0);
        }
 
-       if (rctx->screen->trace_bo) {
+       if (rctx->screen->b.trace_bo) {
                r600_trace_emit(rctx);
        }
 
@@ -2190,13 +2190,13 @@ void r600_trace_emit(struct r600_context *rctx)
        uint64_t va;
        uint32_t reloc;
 
-       va = r600_resource_va(&rscreen->b.b, (void*)rscreen->trace_bo);
-       reloc = r600_context_bo_reloc(&rctx->b, &rctx->b.rings.gfx, rscreen->trace_bo, RADEON_USAGE_READWRITE);
+       va = r600_resource_va(&rscreen->b.b, (void*)rscreen->b.trace_bo);
+       reloc = r600_context_bo_reloc(&rctx->b, &rctx->b.rings.gfx, rscreen->b.trace_bo, RADEON_USAGE_READWRITE);
        radeon_emit(cs, PKT3(PKT3_MEM_WRITE, 3, 0));
        radeon_emit(cs, va & 0xFFFFFFFFUL);
        radeon_emit(cs, (va >> 32UL) & 0xFFUL);
        radeon_emit(cs, cs->cdw);
-       radeon_emit(cs, rscreen->cs_count);
+       radeon_emit(cs, rscreen->b.cs_count);
        radeon_emit(cs, PKT3(PKT3_NOP, 0, 0));
        radeon_emit(cs, reloc);
 }
index 5496a12f2c152b65a6392f75bd6d08d566c30aae..d0e0c436e0ba87aeda35aa2ddaae3ebbd2e20dde 100644 (file)
@@ -180,6 +180,10 @@ struct r600_common_screen {
         * It must be locked prior to using and flushed before unlocking. */
        struct pipe_context             *aux_context;
        pipe_mutex                      aux_context_lock;
+
+       struct r600_resource            *trace_bo;
+       uint32_t                        *trace_ptr;
+       unsigned                        cs_count;
 };
 
 /* This encapsulates a state or an operation which can emitted into the GPU
index a7536e3fbbfde928cc445d6309e8ec3e3d2f4c24..bb3d0809e223aedb48c671532ffafa0281bf1725 100644 (file)
@@ -71,7 +71,7 @@ void si_need_cs_space(struct si_context *ctx, unsigned num_dw,
        num_dw += ctx->atoms.cache_flush->num_dw;
 
 #if SI_TRACE_CS
-       if (ctx->screen->trace_bo) {
+       if (ctx->screen->b.trace_bo) {
                num_dw += SI_TRACE_CS_DWORDS;
        }
 #endif
@@ -118,14 +118,14 @@ void si_context_flush(struct si_context *ctx, unsigned flags)
        flags |= RADEON_FLUSH_KEEP_TILING_FLAGS;
 
 #if SI_TRACE_CS
-       if (ctx->screen->trace_bo) {
+       if (ctx->screen->b.trace_bo) {
                struct si_screen *sscreen = ctx->screen;
                unsigned i;
 
                for (i = 0; i < cs->cdw; i++) {
-                       fprintf(stderr, "[%4d] [%5d] 0x%08x\n", sscreen->cs_count, i, cs->buf[i]);
+                       fprintf(stderr, "[%4d] [%5d] 0x%08x\n", sscreen->b.cs_count, i, cs->buf[i]);
                }
-               sscreen->cs_count++;
+               sscreen->b.cs_count++;
        }
 #endif
 
@@ -133,21 +133,21 @@ void si_context_flush(struct si_context *ctx, unsigned flags)
        ctx->b.ws->cs_flush(ctx->b.rings.gfx.cs, flags, 0);
 
 #if SI_TRACE_CS
-       if (ctx->screen->trace_bo) {
+       if (ctx->screen->b.trace_bo) {
                struct si_screen *sscreen = ctx->screen;
                unsigned i;
 
                for (i = 0; i < 10; i++) {
                        usleep(5);
-                       if (!ctx->ws->buffer_is_busy(sscreen->trace_bo->buf, RADEON_USAGE_READWRITE)) {
+                       if (!ctx->ws->buffer_is_busy(sscreen->b.trace_bo->buf, RADEON_USAGE_READWRITE)) {
                                break;
                        }
                }
                if (i == 10) {
                        fprintf(stderr, "timeout on cs lockup likely happen at cs %d dw %d\n",
-                               sscreen->trace_ptr[1], sscreen->trace_ptr[0]);
+                               sscreen->b.trace_ptr[1], sscreen->b.trace_ptr[0]);
                } else {
-                       fprintf(stderr, "cs %d executed in %dms\n", sscreen->trace_ptr[1], i * 5);
+                       fprintf(stderr, "cs %d executed in %dms\n", sscreen->b.trace_ptr[1], i * 5);
                }
        }
 #endif
@@ -193,8 +193,8 @@ void si_trace_emit(struct si_context *sctx)
        struct radeon_winsys_cs *cs = sctx->cs;
        uint64_t va;
 
-       va = r600_resource_va(&sscreen->screen, (void*)sscreen->trace_bo);
-       r600_context_bo_reloc(sctx, sscreen->trace_bo, RADEON_USAGE_READWRITE);
+       va = r600_resource_va(&sscreen->screen, (void*)sscreen->b.trace_bo);
+       r600_context_bo_reloc(sctx, sscreen->b.trace_bo, RADEON_USAGE_READWRITE);
        cs->buf[cs->cdw++] = PKT3(PKT3_WRITE_DATA, 4, 0);
        cs->buf[cs->cdw++] = PKT3_WRITE_DATA_DST_SEL(PKT3_WRITE_DATA_DST_SEL_MEM_SYNC) |
                                PKT3_WRITE_DATA_WR_CONFIRM |
@@ -202,6 +202,6 @@ void si_trace_emit(struct si_context *sctx)
        cs->buf[cs->cdw++] = va & 0xFFFFFFFFUL;
        cs->buf[cs->cdw++] = (va >> 32UL) & 0xFFFFFFFFUL;
        cs->buf[cs->cdw++] = cs->cdw;
-       cs->buf[cs->cdw++] = sscreen->cs_count;
+       cs->buf[cs->cdw++] = sscreen->b.cs_count;
 }
 #endif
index 8666b5b071c682c9896e079c201bf5a30ca4f174..6aaf59568c4c69c398928f722a0225d3770f082c 100644 (file)
@@ -564,9 +564,9 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
        r600_common_screen_cleanup(&sscreen->b);
 
 #if SI_TRACE_CS
-       if (sscreen->trace_bo) {
-               sscreen->ws->buffer_unmap(sscreen->trace_bo->cs_buf);
-               pipe_resource_reference((struct pipe_resource**)&sscreen->trace_bo, NULL);
+       if (sscreen->b.trace_bo) {
+               sscreen->ws->buffer_unmap(sscreen->b.trace_bo->cs_buf);
+               pipe_resource_reference((struct pipe_resource**)&sscreen->b.trace_bo, NULL);
        }
 #endif
 
@@ -611,14 +611,14 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
                sscreen->b.debug_flags |= DBG_FS | DBG_VS | DBG_GS | DBG_PS | DBG_CS;
 
 #if SI_TRACE_CS
-       sscreen->cs_count = 0;
+       sscreen->b.cs_count = 0;
        if (sscreen->info.drm_minor >= 28) {
-               sscreen->trace_bo = (struct r600_resource*)pipe_buffer_create(&sscreen->screen,
+               sscreen->b.trace_bo = (struct r600_resource*)pipe_buffer_create(&sscreen->screen,
                                                                                PIPE_BIND_CUSTOM,
                                                                                PIPE_USAGE_STAGING,
                                                                                4096);
-               if (sscreen->trace_bo) {
-                       sscreen->trace_ptr = sscreen->ws->buffer_map(sscreen->trace_bo->cs_buf, NULL,
+               if (sscreen->b.trace_bo) {
+                       sscreen->b.trace_ptr = sscreen->ws->buffer_map(sscreen->b.trace_bo->cs_buf, NULL,
                                                                        PIPE_TRANSFER_UNSYNCHRONIZED);
                }
        }
index aa62852b0931673103645742d43869bf9377f89d..e137bfc58d4e6e1a64476e8babbc9397250f3396 100644 (file)
@@ -55,11 +55,6 @@ struct si_pipe_compute;
 
 struct si_screen {
        struct r600_common_screen       b;
-#if SI_TRACE_CS
-       struct r600_resource            *trace_bo;
-       uint32_t                        *trace_ptr;
-       unsigned                        cs_count;
-#endif
 };
 
 struct si_pipe_sampler_view {
index 5b13285027287c9b5c3cf0080f45f28e84c43191..c8769370db0862ceaec3d81d01fa399293a88928 100644 (file)
@@ -202,7 +202,7 @@ unsigned si_pm4_dirty_dw(struct si_context *sctx)
                count += state->ndw;
 #if SI_TRACE_CS
                /* for tracing each states */
-               if (sctx->screen->trace_bo) {
+               if (sctx->screen->b.trace_bo) {
                        count += SI_TRACE_CS_DWORDS;
                }
 #endif
@@ -228,7 +228,7 @@ void si_pm4_emit(struct si_context *sctx, struct si_pm4_state *state)
        cs->cdw += state->ndw;
 
 #if SI_TRACE_CS
-       if (sctx->screen->trace_bo) {
+       if (sctx->screen->b.trace_bo) {
                si_trace_emit(sctx);
        }
 #endif
index 5c2ff8a249e6b6f1acb8dca09faf89674a31603b..45dd4baa4709b19101fa87a9b6a17cf3c4d866fc 100644 (file)
@@ -750,7 +750,7 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
        sctx->pm4_dirty_cdwords = 0;
 
 #if SI_TRACE_CS
-       if (sctx->screen->trace_bo) {
+       if (sctx->screen->b.trace_bo) {
                si_trace_emit(sctx);
        }
 #endif