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 c64b93bd4fcfdf5c0b1bcfd836c85b6ed44ed49e..00d5d007ddfa99801b67293a0b36f5e6d296afc7 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 1a1908031f0b7439d773b62e7e0065930f876373..2c6d217abe7a0b7020b8f76d3ac6bf87fa21c839 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 8d34b864f823feb7f57608f69bf6a4783c2ec584..8afe866c91e1b5c765b85b3e5b1ced36a885e1d0 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 354d38ec2344c61b4bc0e810e9c1e33c372521c9..19bfa81b99adf5f4365a13698543ecabc4e5a3aa 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 c32e541eb50a1bc24a2da49bd9f79397346fb99e..bc18eef6cfebd5894024e9040fab40e704a3221a 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);