From c383a3cfb22a36f38a0d57300a701c253311c052 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 10 Sep 2012 05:56:46 +0200 Subject: [PATCH] r600g: initialize the first CS just like any other CS by reusing the CS initialization in r600_context_flush. Reviewed-by: Jerome Glisse --- src/gallium/drivers/r600/evergreen_state.c | 6 ----- src/gallium/drivers/r600/r600.h | 1 + src/gallium/drivers/r600/r600_hw_context.c | 29 ++++++++++++++-------- src/gallium/drivers/r600/r600_pipe.c | 2 +- src/gallium/drivers/r600/r600_pipe.h | 4 +++ src/gallium/drivers/r600/r600_state.c | 8 ------ 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index c0615767be2..4c010060e50 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -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; diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h index 7c1d77313de..6363a035a14 100644 --- a/src/gallium/drivers/r600/r600.h +++ b/src/gallium/drivers/r600/r600.h @@ -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); diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c index f183b33c09e..20feb7a8973 100644 --- a/src/gallium/drivers/r600/r600_hw_context.c +++ b/src/gallium/drivers/r600/r600_hw_context.c @@ -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); } diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 048b8013192..658e9a94a26 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -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) diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index 7edcde6d864..7e703a60a0b 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -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; diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index abe886c5e2a..c3fafc3dac1 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -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; -- 2.30.2