summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2014-04-12 18:12:11 +0200
committerMarek Olšák <[email protected]>2014-04-16 14:02:52 +0200
commit11459436d9314681087463f2c006c58b6fcff396 (patch)
tree3620c11c52f31e266783bfd74ad2d92bba3575f7 /src/gallium/drivers
parentadfadeadd8316e95626fec4771393d32a70af649 (diff)
r600g,radeonsi: share some of gfx flush code
Reviewed-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/r600/r600_hw_context.c44
-rw-r--r--src/gallium/drivers/radeon/r600_pipe_common.c47
-rw-r--r--src/gallium/drivers/radeon/r600_pipe_common.h2
-rw-r--r--src/gallium/drivers/radeonsi/si_hw_context.c44
4 files changed, 55 insertions, 82 deletions
diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c
index 6d3f7992708..a860519d911 100644
--- a/src/gallium/drivers/r600/r600_hw_context.c
+++ b/src/gallium/drivers/r600/r600_hw_context.c
@@ -236,35 +236,12 @@ void r600_context_gfx_flush(void *context, unsigned flags,
struct r600_context *ctx = context;
struct radeon_winsys_cs *cs = ctx->b.rings.gfx.cs;
- if (ctx->b.rings.gfx.cs->cdw == ctx->b.initial_gfx_cs_size)
+ 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);
- }
-
- ctx->b.nontimer_queries_suspended = false;
- ctx->b.streamout.suspended = false;
-
- /* suspend queries */
- if (ctx->b.num_cs_dw_nontimer_queries_suspend) {
- r600_suspend_nontimer_queries(&ctx->b);
- ctx->b.nontimer_queries_suspended = true;
- }
-
- if (ctx->b.streamout.begin_emitted) {
- r600_emit_streamout_end(&ctx->b);
- ctx->b.streamout.suspended = true;
- }
+ r600_preflush_suspend_features(&ctx->b);
/* flush the framebuffer cache */
ctx->b.flags |= R600_CONTEXT_FLUSH_AND_INV |
@@ -362,22 +339,7 @@ void r600_begin_new_cs(struct r600_context *ctx)
r600_sampler_states_dirty(ctx, &samplers->states);
}
- if (ctx->b.streamout.suspended) {
- ctx->b.streamout.append_bitmask = ctx->b.streamout.enabled_mask;
- r600_streamout_buffers_dirty(&ctx->b);
- }
-
- /* resume queries */
- if (ctx->b.nontimer_queries_suspended) {
- 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);
- }
+ r600_postflush_resume_features(&ctx->b);
/* Re-emit the draw state. */
ctx->last_primitive_type = -1;
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index 3a0d9811ce6..750886532f2 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -53,6 +53,53 @@ static void r600_memory_barrier(struct pipe_context *ctx, unsigned flags)
{
}
+void r600_preflush_suspend_features(struct r600_common_context *ctx)
+{
+ /* Disable render condition. */
+ ctx->saved_render_cond = NULL;
+ ctx->saved_render_cond_cond = FALSE;
+ ctx->saved_render_cond_mode = 0;
+ if (ctx->current_render_cond) {
+ ctx->saved_render_cond = ctx->current_render_cond;
+ ctx->saved_render_cond_cond = ctx->current_render_cond_cond;
+ ctx->saved_render_cond_mode = ctx->current_render_cond_mode;
+ ctx->b.render_condition(&ctx->b, NULL, FALSE, 0);
+ }
+
+ /* suspend queries */
+ ctx->nontimer_queries_suspended = false;
+ if (ctx->num_cs_dw_nontimer_queries_suspend) {
+ r600_suspend_nontimer_queries(ctx);
+ ctx->nontimer_queries_suspended = true;
+ }
+
+ ctx->streamout.suspended = false;
+ if (ctx->streamout.begin_emitted) {
+ r600_emit_streamout_end(ctx);
+ ctx->streamout.suspended = true;
+ }
+}
+
+void r600_postflush_resume_features(struct r600_common_context *ctx)
+{
+ if (ctx->streamout.suspended) {
+ ctx->streamout.append_bitmask = ctx->streamout.enabled_mask;
+ r600_streamout_buffers_dirty(ctx);
+ }
+
+ /* resume queries */
+ if (ctx->nontimer_queries_suspended) {
+ r600_resume_nontimer_queries(ctx);
+ }
+
+ /* Re-enable render condition. */
+ if (ctx->saved_render_cond) {
+ ctx->b.render_condition(&ctx->b, ctx->saved_render_cond,
+ ctx->saved_render_cond_cond,
+ ctx->saved_render_cond_mode);
+ }
+}
+
static void r600_flush_from_st(struct pipe_context *ctx,
struct pipe_fence_handle **fence,
unsigned flags)
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index a87efdcbdae..ada124f93ed 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -407,6 +407,8 @@ struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
bool r600_common_screen_init(struct r600_common_screen *rscreen,
struct radeon_winsys *ws);
void r600_destroy_common_screen(struct r600_common_screen *rscreen);
+void r600_preflush_suspend_features(struct r600_common_context *ctx);
+void r600_postflush_resume_features(struct r600_common_context *ctx);
bool r600_common_context_init(struct r600_common_context *rctx,
struct r600_common_screen *rscreen);
void r600_common_context_cleanup(struct r600_common_context *rctx);
diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c b/src/gallium/drivers/radeonsi/si_hw_context.c
index 37ca290291f..185041e9598 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -88,30 +88,7 @@ void si_context_gfx_flush(void *context, unsigned flags,
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) {
- r600_suspend_nontimer_queries(&ctx->b);
- ctx->b.nontimer_queries_suspended = true;
- }
-
- ctx->b.streamout.suspended = false;
-
- if (ctx->b.streamout.begin_emitted) {
- r600_emit_streamout_end(&ctx->b);
- ctx->b.streamout.suspended = true;
- }
+ r600_preflush_suspend_features(&ctx->b);
ctx->b.flags |= R600_CONTEXT_FLUSH_AND_INV_CB |
R600_CONTEXT_FLUSH_AND_INV_CB_META |
@@ -182,27 +159,12 @@ void si_begin_new_cs(struct si_context *ctx)
si_pm4_emit(ctx, ctx->queued.named.init);
ctx->emitted.named.init = ctx->queued.named.init;
- if (ctx->b.streamout.suspended) {
- ctx->b.streamout.append_bitmask = ctx->b.streamout.enabled_mask;
- r600_streamout_buffers_dirty(&ctx->b);
- }
-
- /* resume queries */
- if (ctx->b.nontimer_queries_suspended) {
- 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);
+ r600_postflush_resume_features(&ctx->b);
+
ctx->b.initial_gfx_cs_size = ctx->b.rings.gfx.cs->cdw;
}