Mesa (master): r600g: add a flag to just create flushed texture without flushing.

Dave Airlie airlied at kemper.freedesktop.org
Thu Feb 3 23:05:05 UTC 2011


Module: Mesa
Branch: master
Commit: 3e9bc43fbafdd497d475eaffe0deec81b446d122
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3e9bc43fbafdd497d475eaffe0deec81b446d122

Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Feb  4 09:07:08 2011 +1000

r600g: add a flag to just create flushed texture without flushing.

This just adds a flag to create the texture without doing any
flushing to it. Flushing occurs in the draw function. This avoids
unnecessary flushes when we end up rebinding a CB/DB/texture due
to the blitter just restoring state.

Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/gallium/drivers/r600/evergreen_state.c |    2 +-
 src/gallium/drivers/r600/r600_blit.c       |    2 +-
 src/gallium/drivers/r600/r600_resource.h   |    2 +-
 src/gallium/drivers/r600/r600_state.c      |    8 +++++++-
 src/gallium/drivers/r600/r600_texture.c    |    7 +++++--
 5 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index c64b93b..00d5d00 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -382,7 +382,7 @@ static struct pipe_sampler_view *evergreen_create_sampler_view(struct pipe_conte
 	}
 	tmp = (struct r600_resource_texture *)texture;
 	if (tmp->depth && tmp->tile_type == 1) {
-		r600_texture_depth_flush(ctx, texture);
+		r600_texture_depth_flush(ctx, texture, TRUE);
 		tmp = tmp->flushed_depth_texture;
 	}
 	rbuffer = &tmp->resource;
diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index 1a19080..2c6d217 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -222,7 +222,7 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
 	struct r600_resource_texture *rsrc = (struct r600_resource_texture*)src;
 
 	if (rsrc->depth && !rsrc->is_flushing_texture)
-		r600_texture_depth_flush(ctx, src);
+		r600_texture_depth_flush(ctx, src, FALSE);
 
 	r600_hw_copy_region(ctx, dst, dst_level, dstx, dsty, dstz,
 			    src, src_level, src_box);
diff --git a/src/gallium/drivers/r600/r600_resource.h b/src/gallium/drivers/r600/r600_resource.h
index 8d34b86..8afe866 100644
--- a/src/gallium/drivers/r600/r600_resource.h
+++ b/src/gallium/drivers/r600/r600_resource.h
@@ -103,7 +103,7 @@ static INLINE boolean r600_is_user_buffer(struct pipe_resource *buffer)
 	return r600_buffer(buffer)->user_buffer ? TRUE : FALSE;
 }
 
-int r600_texture_depth_flush(struct pipe_context *ctx, struct pipe_resource *texture);
+int r600_texture_depth_flush(struct pipe_context *ctx, struct pipe_resource *texture, boolean just_create);
 
 /* r600_texture.c texture transfer functions. */
 struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 354d38e..19bfa81 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -430,7 +430,7 @@ static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *c
 	}
 	tmp = (struct r600_resource_texture *)texture;
 	if (tmp->depth && !tmp->is_flushing_texture) {
-		r600_texture_depth_flush(ctx, texture);
+	        r600_texture_depth_flush(ctx, texture, TRUE);
 		tmp = tmp->flushed_depth_texture;
 	}
 	rbuffer = &tmp->resource;
@@ -692,6 +692,12 @@ static void r600_cb(struct r600_pipe_context *rctx, struct r600_pipe_state *rsta
 
 	surf = (struct r600_surface *)state->cbufs[cb];
 	rtex = (struct r600_resource_texture*)state->cbufs[cb]->texture;
+
+	if (rtex->depth && !rtex->is_flushing_texture) {
+	        r600_texture_depth_flush(&rctx->context, state->cbufs[cb]->texture, TRUE);
+		rtex = rtex->flushed_depth_texture;
+	}
+
 	rbuffer = &rtex->resource;
 	bo[0] = rbuffer->bo;
 	bo[1] = rbuffer->bo;
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index c32e541..bc18eef 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -488,7 +488,7 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
 }
 
 int r600_texture_depth_flush(struct pipe_context *ctx,
-			     struct pipe_resource *texture)
+			     struct pipe_resource *texture, boolean just_create)
 {
 	struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
 	struct pipe_resource resource;
@@ -517,6 +517,9 @@ int r600_texture_depth_flush(struct pipe_context *ctx,
 
 	((struct r600_resource_texture *)rtex->flushed_depth_texture)->is_flushing_texture = TRUE;
 out:
+	if (just_create)
+		return 0;
+
 	/* XXX: only do this if the depth texture has actually changed:
 	 */
 	r600_blit_uncompress_depth(ctx, rtex);
@@ -582,7 +585,7 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
 		*/
 		/* XXX: when discard is true, no need to read back from depth texture
 		*/
-		r = r600_texture_depth_flush(ctx, texture);
+		r = r600_texture_depth_flush(ctx, texture, FALSE);
 		if (r < 0) {
 			R600_ERR("failed to create temporary texture to hold untiled copy\n");
 			pipe_resource_reference(&trans->transfer.resource, NULL);




More information about the mesa-commit mailing list