r600g: always decompress all mipmaps and layers, slices, or faces of zbuffers
authorMarek Olšák <maraeo@gmail.com>
Sun, 4 Sep 2011 00:58:41 +0000 (02:58 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sat, 10 Sep 2011 06:53:29 +0000 (08:53 +0200)
This fixes piglit/fbo-depth-array.

Reviewed-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_texture.c

index ba0790c0402db5aedd0d003651059bd39ca96be3..9a71c8447c6ca2ba3c7cd6eb9562a202a0225510 100644 (file)
@@ -101,39 +101,62 @@ static void r600_blitter_end(struct pipe_context *ctx)
        rctx->blit = false;
 }
 
+static unsigned u_num_layers(struct pipe_resource *r, unsigned level)
+{
+       switch (r->target) {
+       case PIPE_TEXTURE_CUBE:
+               return 6;
+       case PIPE_TEXTURE_3D:
+               return u_minify(r->depth0, level);
+       case PIPE_TEXTURE_1D_ARRAY:
+               return r->array_size;
+       case PIPE_TEXTURE_2D_ARRAY:
+               return r->array_size;
+       default:
+               return 1;
+       }
+}
+
 void r600_blit_uncompress_depth(struct pipe_context *ctx, struct r600_resource_texture *texture)
 {
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
-       struct pipe_surface *zsurf, *cbsurf, surf_tmpl;
-       int level = 0;
+       unsigned layer, level;
        float depth = 1.0f;
 
        if (!texture->dirty_db)
                return;
 
-       surf_tmpl.format = texture->real_format;
-       surf_tmpl.u.tex.level = level;
-       surf_tmpl.u.tex.first_layer = 0;
-       surf_tmpl.u.tex.last_layer = 0;
-       surf_tmpl.usage = PIPE_BIND_DEPTH_STENCIL;
-
-       zsurf = ctx->create_surface(ctx, &texture->resource.b.b.b, &surf_tmpl);
-
-       surf_tmpl.format = texture->flushed_depth_texture->real_format;
-       surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
-       cbsurf = ctx->create_surface(ctx,
-                       (struct pipe_resource*)texture->flushed_depth_texture, &surf_tmpl);
-
        if (rctx->family == CHIP_RV610 || rctx->family == CHIP_RV630 ||
            rctx->family == CHIP_RV620 || rctx->family == CHIP_RV635)
                depth = 0.0f;
 
-       r600_blitter_begin(ctx, R600_DECOMPRESS);
-       util_blitter_custom_depth_stencil(rctx->blitter, zsurf, cbsurf, rctx->custom_dsa_flush, depth);
-       r600_blitter_end(ctx);
+       for (level = 0; level <= texture->resource.b.b.b.last_level; level++) {
+               unsigned num_layers = u_num_layers(&texture->resource.b.b.b, level);
+
+               for (layer = 0; layer < num_layers; layer++) {
+                       struct pipe_surface *zsurf, *cbsurf, surf_tmpl;
+
+                       surf_tmpl.format = texture->real_format;
+                       surf_tmpl.u.tex.level = level;
+                       surf_tmpl.u.tex.first_layer = layer;
+                       surf_tmpl.u.tex.last_layer = layer;
+                       surf_tmpl.usage = PIPE_BIND_DEPTH_STENCIL;
+
+                       zsurf = ctx->create_surface(ctx, &texture->resource.b.b.b, &surf_tmpl);
 
-       pipe_surface_reference(&zsurf, NULL);
-       pipe_surface_reference(&cbsurf, NULL);
+                       surf_tmpl.format = texture->flushed_depth_texture->real_format;
+                       surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
+                       cbsurf = ctx->create_surface(ctx,
+                                       (struct pipe_resource*)texture->flushed_depth_texture, &surf_tmpl);
+
+                       r600_blitter_begin(ctx, R600_DECOMPRESS);
+                       util_blitter_custom_depth_stencil(rctx->blitter, zsurf, cbsurf, rctx->custom_dsa_flush, depth);
+                       r600_blitter_end(ctx);
+
+                       pipe_surface_reference(&zsurf, NULL);
+                       pipe_surface_reference(&cbsurf, NULL);
+               }
+       }
 
        texture->dirty_db = FALSE;
 }
index 691cc48dea7c0d5d10a1b78fe1e7e6fa50b7d586..425e269069fb1fd38a8d32f5e568af62187713cb 100644 (file)
@@ -573,19 +573,17 @@ int r600_texture_depth_flush(struct pipe_context *ctx,
        if (rtex->flushed_depth_texture)
                goto out;
 
-       resource.target = PIPE_TEXTURE_2D;
+       resource.target = texture->target;
        resource.format = texture->format;
        resource.width0 = texture->width0;
        resource.height0 = texture->height0;
-       resource.depth0 = 1;
-       resource.array_size = 1;
+       resource.depth0 = texture->depth0;
+       resource.array_size = texture->array_size;
        resource.last_level = texture->last_level;
-       resource.nr_samples = 0;
+       resource.nr_samples = texture->nr_samples;
        resource.usage = PIPE_USAGE_DYNAMIC;
-       resource.bind = 0;
-       resource.flags = R600_RESOURCE_FLAG_TRANSFER;
-
-       resource.bind |= PIPE_BIND_DEPTH_STENCIL;
+       resource.bind = texture->bind | PIPE_BIND_DEPTH_STENCIL;
+       resource.flags = R600_RESOURCE_FLAG_TRANSFER | texture->flags;
 
        rtex->flushed_depth_texture = (struct r600_resource_texture *)ctx->screen->resource_create(ctx->screen, &resource);
        if (rtex->flushed_depth_texture == NULL) {