r600g: rework dirty / depth texture tracking.
authorDave Airlie <airlied@redhat.com>
Thu, 3 Feb 2011 03:12:35 +0000 (13:12 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 3 Feb 2011 04:17:05 +0000 (14:17 +1000)
this adds a flag to keep track of whether the depth texture structure
is the flushed texture or not, so we can avoid doing flushes when
we do a hw rendering from one to the other.

it also renames flushed to dirty_db which tracks if the DB copy
has been dirtied by being bound to the hw.

Signed-off-by: Dave Airlie <airlied@redhat.com>
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_state_common.c
src/gallium/drivers/r600/r600_texture.c

index a8e85df3c4857c2c88ebec139ee79c0a6d59491f..ca032811048f5c7a4017c04298deab9deea90bf9 100644 (file)
@@ -85,7 +85,8 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx, struct r600_resource_t
        int level = 0;
        float depth = 1.0f;
 
-       if (texture->flushed) return;
+       if (!texture->dirty_db)
+               return;
 
        surf_tmpl.format = texture->resource.base.b.format;
        surf_tmpl.u.tex.level = level;
@@ -107,10 +108,11 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx, struct r600_resource_t
        r600_blitter_begin(ctx, R600_CLEAR_SURFACE);
        util_blitter_custom_depth_stencil(rctx->blitter, zsurf, cbsurf, rctx->custom_dsa_flush, depth);
        r600_blitter_end(ctx);
-       texture->flushed = true;
 
        pipe_surface_reference(&zsurf, NULL);
        pipe_surface_reference(&cbsurf, NULL);
+
+       texture->dirty_db = FALSE;
 }
 
 void r600_flush_depth_textures(struct r600_pipe_context *rctx)
@@ -132,9 +134,6 @@ void r600_flush_depth_textures(struct r600_pipe_context *rctx)
                if (!tex->depth)
                        continue;
 
-               if (tex->tile_type == 0)
-                       continue;
-
                r600_blit_uncompress_depth(&rctx->context, tex);
        }
 }
index 5b5df5a5bac3592479fc6e738949ce8f6a028cfc..8d34b864f823feb7f57608f69bf6a4783c2ec584 100644 (file)
@@ -61,9 +61,9 @@ struct r600_resource_texture {
        unsigned                        tiled;
        unsigned                        tile_type;
        unsigned                        depth;
-       unsigned                        dirty;
+       unsigned                        dirty_db;
        struct r600_resource_texture    *flushed_depth_texture;
-       bool                            flushed;
+       boolean                         is_flushing_texture;
 };
 
 #define R600_BUFFER_MAGIC 0xabcd1600
index 6adbbd9eabe24195efba2a846d2731465487eeca..354d38ec2344c61b4bc0e810e9c1e33c372521c9 100644 (file)
@@ -429,7 +429,7 @@ static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *c
                R600_ERR("unknow format %d\n", state->format);
        }
        tmp = (struct r600_resource_texture *)texture;
-       if (tmp->depth && tmp->tile_type == 1) {
+       if (tmp->depth && !tmp->is_flushing_texture) {
                r600_texture_depth_flush(ctx, texture);
                tmp = tmp->flushed_depth_texture;
        }
@@ -760,8 +760,6 @@ static void r600_db(struct r600_pipe_context *rctx, struct r600_pipe_state *rsta
        surf = (struct r600_surface *)state->zsbuf;
        rtex = (struct r600_resource_texture*)state->zsbuf->texture;
 
-       rtex->tile_type = 1;
-
        rbuffer = &rtex->resource;
 
        /* XXX quite sure for dx10+ hw don't need any offset hacks */
index d82985e1b1ff9580980c59009d0e7065774ca52e..3b037f8c8c2e14e562e2624a79024cb05904997e 100644 (file)
@@ -602,7 +602,7 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
        if (rctx->framebuffer.zsbuf)
        {
                struct pipe_resource *tex = rctx->framebuffer.zsbuf->texture;
-               ((struct r600_resource_texture *)tex)->flushed = false;
+               ((struct r600_resource_texture *)tex)->dirty_db = TRUE;
        }
 
        pipe_resource_reference(&draw.index_buffer, NULL);
index 14422bbfe4169b38969535066ee880278423c3b5..7b38337eda567da9c69f0e2a8b93a642ab731f0d 100644 (file)
@@ -513,6 +513,7 @@ int r600_texture_depth_flush(struct pipe_context *ctx,
                return -ENOMEM;
        }
 
+       ((struct r600_resource_texture *)rtex->flushed_depth_texture)->is_flushing_texture = TRUE;
 out:
        /* XXX: only do this if the depth texture has actually changed:
         */
@@ -574,7 +575,7 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
        trans->transfer.level = level;
        trans->transfer.usage = usage;
        trans->transfer.box = *box;
-       if (rtex->depth && rtex->tile_type == 1) {
+       if (rtex->depth) {
                /* XXX: only readback the rectangle which is being mapped?
                */
                /* XXX: when discard is true, no need to read back from depth texture