r600g: add a flag to just create flushed texture without flushing.
authorDave Airlie <airlied@redhat.com>
Thu, 3 Feb 2011 23:07:08 +0000 (09:07 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 3 Feb 2011 23:09:45 +0000 (09:09 +1000)
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@redhat.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_resource.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_texture.c

index c64b93b..00d5d00 100644 (file)
@@ -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;
index 1a19080..2c6d217 100644 (file)
@@ -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);
index 8d34b86..8afe866 100644 (file)
@@ -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,
index 354d38e..19bfa81 100644 (file)
@@ -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;
index c32e541..bc18eef 100644 (file)
@@ -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);