summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-01-14 01:38:51 +0100
committerMarek Olšák <[email protected]>2013-01-15 21:50:34 +0100
commit7660529c44b3f6753e9b5636e876a3cd83c8ba51 (patch)
tree337240303d58cbe61f9b3489fda4aeee8426bf51
parentca2c28859eca83f8fbf1f43616f5ef861e95e8d6 (diff)
r300g: fix and cleanup flushing before clearing CMASK, ZMASK, and HIZ
-rw-r--r--src/gallium/drivers/r300/r300_blit.c7
-rw-r--r--src/gallium/drivers/r300/r300_context.c6
-rw-r--r--src/gallium/drivers/r300/r300_context.h13
-rw-r--r--src/gallium/drivers/r300/r300_emit.c9
4 files changed, 17 insertions, 18 deletions
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c
index 2bb6063846b..e903e9a57cc 100644
--- a/src/gallium/drivers/r300/r300_blit.c
+++ b/src/gallium/drivers/r300/r300_blit.c
@@ -295,12 +295,14 @@ static void r300_clear(struct pipe_context* pipe,
r300_depth_clear_value(fb->zsbuf->format, depth, stencil);
r300_mark_atom_dirty(r300, &r300->zmask_clear);
+ r300_mark_atom_dirty(r300, &r300->gpu_flush);
buffers &= ~PIPE_CLEAR_DEPTHSTENCIL;
}
if (hiz_clear) {
r300->hiz_clear_value = r300_hiz_clear_value(depth);
r300_mark_atom_dirty(r300, &r300->hiz_clear);
+ r300_mark_atom_dirty(r300, &r300->gpu_flush);
}
r300->num_z_clears++;
}
@@ -339,6 +341,7 @@ static void r300_clear(struct pipe_context* pipe,
if (r300->screen->cmask_resource == fb->cbufs[0]->texture) {
r300_set_clear_color(r300, color);
r300_mark_atom_dirty(r300, &r300->cmask_clear);
+ r300_mark_atom_dirty(r300, &r300->gpu_flush);
buffers &= ~PIPE_CLEAR_COLOR;
}
}
@@ -375,6 +378,7 @@ static void r300_clear(struct pipe_context* pipe,
* procedure. */
/* Calculate zmask_clear and hiz_clear atom sizes. */
unsigned dwords =
+ r300->gpu_flush.size +
(r300->zmask_clear.dirty ? r300->zmask_clear.size : 0) +
(r300->hiz_clear.dirty ? r300->hiz_clear.size : 0) +
(r300->cmask_clear.dirty ? r300->cmask_clear.size : 0) +
@@ -386,6 +390,9 @@ static void r300_clear(struct pipe_context* pipe,
}
/* Emit clear packets. */
+ r300_emit_gpu_flush(r300, r300->gpu_flush.size, r300->gpu_flush.state);
+ r300->gpu_flush.dirty = FALSE;
+
if (r300->zmask_clear.dirty) {
r300_emit_zmask_clear(r300, r300->zmask_clear.size,
r300->zmask_clear.state);
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index a6fccc6e02c..d8af13f9954 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -204,9 +204,9 @@ static boolean r300_setup_atoms(struct r300_context* r300)
R300_INIT_ATOM(texture_cache_inval, 2);
R300_INIT_ATOM(textures_state, 0);
/* Clear commands */
- R300_INIT_ATOM(hiz_clear, r300->screen->caps.hiz_ram > 0 ? 6 : 0);
- R300_INIT_ATOM(zmask_clear, r300->screen->caps.zmask_ram > 0 ? 6 : 0);
- R300_INIT_ATOM(cmask_clear, 6);
+ R300_INIT_ATOM(hiz_clear, r300->screen->caps.hiz_ram > 0 ? 4 : 0);
+ R300_INIT_ATOM(zmask_clear, r300->screen->caps.zmask_ram > 0 ? 4 : 0);
+ R300_INIT_ATOM(cmask_clear, 4);
/* ZB (unpipelined), SU. */
R300_INIT_ATOM(query_start, 4);
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 33851519bd8..8f8dc0c8a79 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -487,6 +487,13 @@ struct r300_context {
* performance and stability if not handled with care. */
/* GPU flush. */
struct r300_atom gpu_flush;
+ /* Clears must be emitted immediately after the flush. */
+ /* HiZ clear */
+ struct r300_atom hiz_clear;
+ /* zmask clear */
+ struct r300_atom zmask_clear;
+ /* cmask clear */
+ struct r300_atom cmask_clear;
/* Anti-aliasing (MSAA) state. */
struct r300_atom aa_state;
/* Framebuffer state. */
@@ -537,12 +544,6 @@ struct r300_context {
struct r300_atom texture_cache_inval;
/* Textures state. */
struct r300_atom textures_state;
- /* HiZ clear */
- struct r300_atom hiz_clear;
- /* zmask clear */
- struct r300_atom zmask_clear;
- /* cmask clear */
- struct r300_atom cmask_clear;
/* Occlusion query. */
struct r300_atom query_start;
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 9ea084fac2d..b3dc2a041be 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -1210,9 +1210,6 @@ void r300_emit_hiz_clear(struct r300_context *r300, unsigned size, void *state)
tex = r300_resource(fb->zsbuf->texture);
BEGIN_CS(size);
- OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
- R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
- R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
OUT_CS_PKT3(R300_PACKET3_3D_CLEAR_HIZ, 2);
OUT_CS(0);
OUT_CS(tex->tex.hiz_dwords[fb->zsbuf->u.tex.level]);
@@ -1235,9 +1232,6 @@ void r300_emit_zmask_clear(struct r300_context *r300, unsigned size, void *state
tex = r300_resource(fb->zsbuf->texture);
BEGIN_CS(size);
- OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT,
- R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
- R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
OUT_CS_PKT3(R300_PACKET3_3D_CLEAR_ZMASK, 2);
OUT_CS(0);
OUT_CS(tex->tex.zmask_dwords[fb->zsbuf->u.tex.level]);
@@ -1259,9 +1253,6 @@ void r300_emit_cmask_clear(struct r300_context *r300, unsigned size, void *state
tex = r300_resource(fb->cbufs[0]->texture);
BEGIN_CS(size);
- OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT,
- R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS |
- R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D);
OUT_CS_PKT3(R300_PACKET3_3D_CLEAR_CMASK, 2);
OUT_CS(0);
OUT_CS(tex->tex.cmask_dwords);