r600g: initialize the first CS just like any other CS
authorMarek Olšák <maraeo@gmail.com>
Mon, 10 Sep 2012 03:56:46 +0000 (05:56 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 13 Sep 2012 18:18:44 +0000 (20:18 +0200)
by reusing the CS initialization in r600_context_flush.

Reviewed-by: Jerome Glisse <jglisse@redhat.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600.h
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.c

index c0615767be272995d95f2016bab13caaf9b0de9c..4c010060e50a381c21c46fd3cfbf99a1b3b8d66d 100644 (file)
@@ -2186,16 +2186,10 @@ void evergreen_init_state_functions(struct r600_context *rctx)
                r600_init_atom(rctx, &rctx->sample_mask.atom, id++, cayman_emit_sample_mask, 4);
        }
        rctx->sample_mask.sample_mask = ~0;
-       r600_atom_dirty(rctx, &rctx->sample_mask.atom);
 
        r600_init_atom(rctx, &rctx->cb_misc_state.atom, id++, evergreen_emit_cb_misc_state, 0);
-       r600_atom_dirty(rctx, &rctx->cb_misc_state.atom);
-
        r600_init_atom(rctx, &rctx->alphatest_state.atom, id++, r600_emit_alphatest_state, 6);
-       r600_atom_dirty(rctx, &rctx->alphatest_state.atom);
-
        r600_init_atom(rctx, &rctx->db_misc_state.atom, id++, evergreen_emit_db_misc_state, 7);
-       r600_atom_dirty(rctx, &rctx->db_misc_state.atom);
 
        rctx->context.create_blend_state = evergreen_create_blend_state;
        rctx->context.create_depth_stencil_alpha_state = evergreen_create_dsa_state;
index 7c1d77313de8025d72e4001d016d838feb20ffd1..6363a035a14504f7258a3fd7a5a7eb89fc56c9b5 100644 (file)
@@ -200,6 +200,7 @@ void r600_context_fini(struct r600_context *ctx);
 void r600_context_pipe_state_emit(struct r600_context *ctx, struct r600_pipe_state *state, unsigned pkt_flags);
 void r600_context_pipe_state_set(struct r600_context *ctx, struct r600_pipe_state *state);
 void r600_context_flush(struct r600_context *ctx, unsigned flags);
+void r600_begin_new_cs(struct r600_context *ctx);
 
 void r600_context_emit_fence(struct r600_context *ctx, struct r600_resource *fence,
                              unsigned offset, unsigned value);
index f183b33c09e28c1e7dc6ddd193225fe79c5e5486..20feb7a8973d9a60458bd1293058af0755f2f162 100644 (file)
@@ -985,28 +985,27 @@ void r600_flush_emit(struct r600_context *rctx)
 void r600_context_flush(struct r600_context *ctx, unsigned flags)
 {
        struct radeon_winsys_cs *cs = ctx->cs;
-       struct r600_block *enable_block = NULL;
-       bool timer_queries_suspended = false;
-       bool nontimer_queries_suspended = false;
-       bool streamout_suspended = false;
-       unsigned shader;
 
        if (cs->cdw == ctx->start_cs_cmd.atom.num_dw)
                return;
 
+       ctx->timer_queries_suspended = false;
+       ctx->nontimer_queries_suspended = false;
+       ctx->streamout_suspended = false;
+
        /* suspend queries */
        if (ctx->num_cs_dw_timer_queries_suspend) {
                r600_suspend_timer_queries(ctx);
-               timer_queries_suspended = true;
+               ctx->timer_queries_suspended = true;
        }
        if (ctx->num_cs_dw_nontimer_queries_suspend) {
                r600_suspend_nontimer_queries(ctx);
-               nontimer_queries_suspended = true;
+               ctx->nontimer_queries_suspended = true;
        }
 
        if (ctx->num_cs_dw_streamout_end) {
                r600_context_streamout_end(ctx);
-               streamout_suspended = true;
+               ctx->streamout_suspended = true;
        }
 
        /* partial flush is needed to avoid lockups on some chips with user fences */
@@ -1033,6 +1032,14 @@ void r600_context_flush(struct r600_context *ctx, unsigned flags)
        /* Flush the CS. */
        ctx->ws->cs_flush(ctx->cs, flags);
 
+       r600_begin_new_cs(ctx);
+}
+
+void r600_begin_new_cs(struct r600_context *ctx)
+{
+       struct r600_block *enable_block = NULL;
+       unsigned shader;
+
        ctx->pm4_dirty_cdwords = 0;
        ctx->flags = 0;
 
@@ -1066,16 +1073,16 @@ void r600_context_flush(struct r600_context *ctx, unsigned flags)
                r600_sampler_states_dirty(ctx, &samplers->states);
        }
 
-       if (streamout_suspended) {
+       if (ctx->streamout_suspended) {
                ctx->streamout_start = TRUE;
                ctx->streamout_append_bitmask = ~0;
        }
 
        /* resume queries */
-       if (timer_queries_suspended) {
+       if (ctx->timer_queries_suspended) {
                r600_resume_timer_queries(ctx);
        }
-       if (nontimer_queries_suspended) {
+       if (ctx->nontimer_queries_suspended) {
                r600_resume_nontimer_queries(ctx);
        }
 
index 048b801319257fc861d3b0ae658258bbf01f5fef..658e9a94a262537d3a851f31ad903d56b7983e67 100644 (file)
@@ -286,7 +286,6 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
 
        rctx->cs = rctx->ws->cs_create(rctx->ws);
        rctx->ws->cs_set_flush_callback(rctx->cs, r600_flush_from_winsys, rctx);
-       r600_emit_atom(rctx, &rctx->start_cs_cmd.atom);
 
         rctx->uploader = u_upload_create(&rctx->context, 1024 * 1024, 256,
                                          PIPE_BIND_INDEX_BUFFER |
@@ -299,6 +298,7 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen, void
                goto fail;
        rctx->blitter->draw_rectangle = r600_draw_rectangle;
 
+       r600_begin_new_cs(rctx);
        r600_get_backend_mask(rctx); /* this emits commands and must be last */
 
        if (rctx->chip_class == R600)
index 7edcde6d8645e6d1a0b7ad27a18e06b2443ea557..7e703a60a0bc3c77e090d36dcd0237391984fef7 100644 (file)
@@ -416,6 +416,10 @@ struct r600_context {
        struct list_head        active_nontimer_queries;
        unsigned                num_cs_dw_nontimer_queries_suspend;
 
+       bool                    timer_queries_suspended;
+       bool                    nontimer_queries_suspended;
+       bool                    streamout_suspended;
+
        unsigned                num_cs_dw_streamout_end;
 
        unsigned                backend_mask;
index abe886c5e2ac7d22b976b32541e86815117693ca..c3fafc3dac10b79c7bea3f62061ce757d29f0e00 100644 (file)
@@ -2065,20 +2065,12 @@ void r600_init_state_functions(struct r600_context *rctx)
        r600_init_atom(rctx, &rctx->vertex_buffer_state.atom, id++, r600_emit_vertex_buffers, 0);
 
        r600_init_atom(rctx, &rctx->seamless_cube_map.atom, id++, r600_emit_seamless_cube_map, 3);
-       r600_atom_dirty(rctx, &rctx->seamless_cube_map.atom);
-
        r600_init_atom(rctx, &rctx->sample_mask.atom, id++, r600_emit_sample_mask, 3);
        rctx->sample_mask.sample_mask = ~0;
-       r600_atom_dirty(rctx, &rctx->sample_mask.atom);
 
        r600_init_atom(rctx, &rctx->cb_misc_state.atom, id++, r600_emit_cb_misc_state, 0);
-       r600_atom_dirty(rctx, &rctx->cb_misc_state.atom);
-
        r600_init_atom(rctx, &rctx->alphatest_state.atom, id++, r600_emit_alphatest_state, 6);
-       r600_atom_dirty(rctx, &rctx->alphatest_state.atom);
-
        r600_init_atom(rctx, &rctx->db_misc_state.atom, id++, r600_emit_db_misc_state, 4);
-       r600_atom_dirty(rctx, &rctx->db_misc_state.atom);
 
        rctx->context.create_blend_state = r600_create_blend_state;
        rctx->context.create_depth_stencil_alpha_state = r600_create_dsa_state;