radeonsi: merge si_flush with si_context_flush
authorMarek Olšák <marek.olsak@amd.com>
Sat, 12 Apr 2014 15:34:44 +0000 (17:34 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 16 Apr 2014 12:02:51 +0000 (14:02 +0200)
This also removes si_flush_gfx_ring.

Reviewed-by: Christian König <christian.koenig@amd.com>
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

index 36a4fb1f6aaa08a7617da092230ebd2431ac8ebf..a87efdcbdae98dc6a66d1cede80f04b580d4fa18 100644 (file)
@@ -352,6 +352,10 @@ struct r600_common_context {
        unsigned                        current_render_cond_mode;
        boolean                         current_render_cond_cond;
        boolean                         predicate_drawing;
+       /* For context flushing. */
+       struct pipe_query               *saved_render_cond;
+       boolean                         saved_render_cond_cond;
+       unsigned                        saved_render_cond_mode;
 
        /* Copy one resource to another using async DMA. */
        void (*dma_copy)(struct pipe_context *ctx,
index f52778163823646c23375da454ef2746da77a6b9..37ca290291f490313a2ed965b4424fb7f1ad642d 100644 (file)
@@ -77,14 +77,28 @@ void si_need_cs_space(struct si_context *ctx, unsigned num_dw,
        }
 }
 
-void si_context_flush(struct si_context *ctx, unsigned flags,
-                     struct pipe_fence_handle **fence)
+void si_context_gfx_flush(void *context, unsigned flags,
+                         struct pipe_fence_handle **fence)
 {
+       struct si_context *ctx = context;
        struct radeon_winsys_cs *cs = ctx->b.rings.gfx.cs;
 
        if (cs->cdw == ctx->b.initial_gfx_cs_size)
                return;
 
+       ctx->b.rings.gfx.flushing = true;
+
+       /* Disable render condition. */
+       ctx->b.saved_render_cond = NULL;
+       ctx->b.saved_render_cond_cond = FALSE;
+       ctx->b.saved_render_cond_mode = 0;
+       if (ctx->b.current_render_cond) {
+               ctx->b.saved_render_cond = ctx->b.current_render_cond;
+               ctx->b.saved_render_cond_cond = ctx->b.current_render_cond_cond;
+               ctx->b.saved_render_cond_mode = ctx->b.current_render_cond_mode;
+               ctx->b.b.render_condition(&ctx->b.b, NULL, FALSE, 0);
+       }
+
        /* suspend queries */
        ctx->b.nontimer_queries_suspended = false;
        if (ctx->b.num_cs_dw_nontimer_queries_suspend) {
@@ -125,6 +139,7 @@ void si_context_flush(struct si_context *ctx, unsigned flags,
 
        /* Flush the CS. */
        ctx->b.ws->cs_flush(cs, flags, fence, 0);
+       ctx->b.rings.gfx.flushing = false;
 
 #if SI_TRACE_CS
        if (ctx->screen->b.trace_bo) {
@@ -177,6 +192,13 @@ void si_begin_new_cs(struct si_context *ctx)
                r600_resume_nontimer_queries(&ctx->b);
        }
 
+       /* Re-enable render condition. */
+       if (ctx->b.saved_render_cond) {
+               ctx->b.b.render_condition(&ctx->b.b, ctx->b.saved_render_cond,
+                                         ctx->b.saved_render_cond_cond,
+                                         ctx->b.saved_render_cond_mode);
+       }
+
        ctx->framebuffer.atom.dirty = true;
        ctx->b.streamout.enable_atom.dirty = true;
        si_all_descriptors_begin_new_cs(ctx);
index d434064b5724ef6742a0a13fe229fa79684f10c6..7f3b0c22198133ea62f84313ec53652b0816e6a6 100644 (file)
 /*
  * pipe_context
  */
-static void si_flush(struct pipe_context *ctx, unsigned flags,
-                    struct pipe_fence_handle **fence)
-{
-       struct si_context *sctx = (struct si_context *)ctx;
-       struct pipe_query *render_cond = NULL;
-       boolean render_cond_cond = FALSE;
-       unsigned render_cond_mode = 0;
-
-       /* Disable render condition. */
-       if (sctx->b.current_render_cond) {
-               render_cond = sctx->b.current_render_cond;
-               render_cond_cond = sctx->b.current_render_cond_cond;
-               render_cond_mode = sctx->b.current_render_cond_mode;
-               ctx->render_condition(ctx, NULL, FALSE, 0);
-       }
-
-       si_context_flush(sctx, flags, fence);
-
-       /* Re-enable render condition. */
-       if (render_cond) {
-               ctx->render_condition(ctx, render_cond, render_cond_cond, render_cond_mode);
-       }
-}
-
 static void si_flush_from_st(struct pipe_context *ctx,
                             struct pipe_fence_handle **fence,
                             unsigned flags)
@@ -70,14 +46,7 @@ static void si_flush_from_st(struct pipe_context *ctx,
        if (sctx->b.rings.dma.cs) {
                sctx->b.rings.dma.flush(sctx, rflags, NULL);
        }
-
-       si_flush(ctx, rflags, fence);
-}
-
-static void si_flush_gfx_ring(void *ctx, unsigned flags,
-                             struct pipe_fence_handle **fence)
-{
-       si_flush(ctx, flags, fence);
+       sctx->b.rings.gfx.flush(sctx, rflags, fence);
 }
 
 static void si_destroy_context(struct pipe_context *context)
@@ -145,9 +114,9 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, void *
                sctx->b.b.create_video_buffer = vl_video_buffer_create;
        }
 
-       sctx->b.rings.gfx.cs = ws->cs_create(ws, RING_GFX, si_flush_gfx_ring,
+       sctx->b.rings.gfx.cs = ws->cs_create(ws, RING_GFX, si_context_gfx_flush,
                                             sctx, NULL);
-       sctx->b.rings.gfx.flush = si_flush_gfx_ring;
+       sctx->b.rings.gfx.flush = si_context_gfx_flush;
 
        si_init_all_descriptors(sctx);
 
index 8930f2becb84a743cb4964a6d64e201ab80bca4a..a74bbcf5c6185526ffbf91c06001057ce84a8b2b 100644 (file)
@@ -177,8 +177,8 @@ void si_dma_copy(struct pipe_context *ctx,
                 const struct pipe_box *src_box);
 
 /* si_hw_context.c */
-void si_context_flush(struct si_context *ctx, unsigned flags,
-                     struct pipe_fence_handle **fence);
+void si_context_gfx_flush(void *context, unsigned flags,
+                         struct pipe_fence_handle **fence);
 void si_begin_new_cs(struct si_context *ctx);
 void si_need_cs_space(struct si_context *ctx, unsigned num_dw, boolean count_draw_in);