r600g: use ptr for blit depth uncompress function
authorJerome Glisse <jglisse@redhat.com>
Tue, 28 Sep 2010 12:59:47 +0000 (08:59 -0400)
committerJerome Glisse <jglisse@redhat.com>
Tue, 28 Sep 2010 13:51:08 +0000 (09:51 -0400)
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
src/gallium/drivers/r600/r600_context.c
src/gallium/drivers/r600/r600_resource.h
src/gallium/drivers/r600/r600_state2.c
src/gallium/drivers/r600/r600_texture.c

index ec1f44639a31cfe68cd06322de0642df915de7d1..091751e93a910fbfa27c234d15e16378048685c5 100644 (file)
@@ -170,6 +170,7 @@ struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
 
        rctx->ctx = radeon_ctx_init(rscreen->rw);
        radeon_draw_init(&rctx->draw, rscreen->rw);
+       r600_blit_uncompress_depth_ptr = r600_blit_uncompress_depth;
        return &rctx->context;
  out_free:
        FREE(rctx);
index a24197c3c23fb472274789bc6c41355813abef1b..b0026e957891781d3936fd3954679c4ff3074480 100644 (file)
@@ -104,4 +104,6 @@ static INLINE boolean r600_buffer_is_user_buffer(struct pipe_resource *buffer)
 
 int r600_texture_depth_flush(struct pipe_context *ctx,
                             struct pipe_resource *texture);
+
+extern int (*r600_blit_uncompress_depth_ptr)(struct pipe_context *ctx, struct r600_resource_texture *texture);
 #endif
index a88426fc9a47df8e386c50134048eff363fa2132..32a11d8522d815f65cc59ea4decebfac50c1d80d 100644 (file)
@@ -743,6 +743,46 @@ static void r600_blitter_save_states(struct pipe_context *ctx)
        /* TODO queries */
 }
 
+int r600_blit_uncompress_depth2(struct pipe_context *ctx, struct r600_resource_texture *texture)
+{
+       struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
+       struct pipe_framebuffer_state fb = *rctx->pframebuffer;
+       struct pipe_surface *zsurf, *cbsurf;
+       int level = 0;
+       float depth = 1.0f;
+
+       for (int i = 0; i < fb.nr_cbufs; i++) {
+               fb.cbufs[i] = NULL;
+               pipe_surface_reference(&fb.cbufs[i], rctx->pframebuffer->cbufs[i]);
+       }
+       fb.zsbuf = NULL;
+       pipe_surface_reference(&fb.zsbuf, rctx->pframebuffer->zsbuf);
+
+       zsurf = ctx->screen->get_tex_surface(ctx->screen, &texture->resource.base.b, 0, level, 0,
+                                            PIPE_BIND_DEPTH_STENCIL);
+
+       cbsurf = ctx->screen->get_tex_surface(ctx->screen, texture->flushed_depth_texture, 0, level, 0,
+                                             PIPE_BIND_RENDER_TARGET);
+
+       r600_blitter_save_states(ctx);
+       util_blitter_save_framebuffer(rctx->blitter, &fb);
+
+       if (rctx->family == CHIP_RV610 || rctx->family == CHIP_RV630 ||
+               rctx->family == CHIP_RV620 || rctx->family == CHIP_RV635)
+               depth = 0.0f;
+
+       util_blitter_custom_depth_stencil(rctx->blitter, zsurf, cbsurf, rctx->custom_dsa_flush, depth);
+
+       pipe_surface_reference(&zsurf, NULL);
+       pipe_surface_reference(&cbsurf, NULL);
+       for (int i = 0; i < fb.nr_cbufs; i++) {
+               pipe_surface_reference(&fb.cbufs[i], NULL);
+       }
+       pipe_surface_reference(&fb.zsbuf, NULL);
+
+       return 0;
+}
+
 static void r600_clear(struct pipe_context *ctx, unsigned buffers,
                        const float *rgba, double depth, unsigned stencil)
 {
@@ -2270,6 +2310,8 @@ static struct pipe_context *r600_create_context2(struct pipe_screen *screen, voi
        LIST_INITHEAD(&rctx->query_list);
        rctx->custom_dsa_flush = r600_create_db_flush_dsa(rctx);
 
+       r600_blit_uncompress_depth_ptr = r600_blit_uncompress_depth2;
+
        return &rctx->context;
 }
 
index 16468c9b1a9cafd10d4a9fac326a9b9c7ae7302d..c24aaeefa77eb103b817c5491e07ebda7037b7f1 100644 (file)
@@ -234,6 +234,8 @@ static unsigned int r600_texture_is_referenced(struct pipe_context *context,
        return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
 }
 
+int (*r600_blit_uncompress_depth_ptr)(struct pipe_context *ctx, struct r600_resource_texture *texture);
+
 int r600_texture_depth_flush(struct pipe_context *ctx,
                             struct pipe_resource *texture)
 {
@@ -263,7 +265,7 @@ int r600_texture_depth_flush(struct pipe_context *ctx,
        }
 
 out:
-       r600_blit_uncompress_depth(ctx, rtex);
+       r600_blit_uncompress_depth_ptr(ctx, rtex);
        return 0;
 }