Merge branch 'llvm-cliptest-viewport'
[mesa.git] / src / gallium / drivers / r600 / r600_blit.c
index aecc87f7da10f9d831a461a21ace23888901e006..50d47060c1a7da395c004da08245f70a54f2e15c 100644 (file)
@@ -22,6 +22,7 @@
  */
 #include <util/u_surface.h>
 #include <util/u_blitter.h>
+#include <util/u_format.h>
 #include "r600_pipe.h"
 
 enum r600_blitter_op /* bitmask */
@@ -80,19 +81,10 @@ static void r600_blitter_end(struct pipe_context *ctx)
 int 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_framebuffer_state fb = *rctx->pframebuffer;
        struct pipe_surface *zsurf, *cbsurf;
        int level = 0;
        float depth = 1.0f;
 
-       r600_context_queries_suspend(&rctx->ctx);
-       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);
 
@@ -100,21 +92,17 @@ int r600_blit_uncompress_depth(struct pipe_context *ctx, struct r600_resource_te
                        (struct pipe_resource*)texture->flushed_depth_texture,
                        0, level, 0, PIPE_BIND_RENDER_TARGET);
 
-       r600_blitter_begin(ctx, R600_CLEAR);
-       util_blitter_save_framebuffer(rctx->blitter, &fb);
        if (rctx->family == CHIP_RV610 || rctx->family == CHIP_RV630 ||
-               rctx->family == CHIP_RV620 || rctx->family == CHIP_RV635)
+           rctx->family == CHIP_RV620 || rctx->family == CHIP_RV635)
                depth = 0.0f;
 
+       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);
 
        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);
-       r600_context_queries_resume(&rctx->ctx);
+
 
        return 0;
 }
@@ -163,6 +151,26 @@ static void r600_clear_depth_stencil(struct pipe_context *ctx,
 }
 
 
+
+/* Copy a block of pixels from one surface to another using HW. */
+static void r600_hw_copy_region(struct pipe_context *ctx,
+                                struct pipe_resource *dst,
+                                struct pipe_subresource subdst,
+                                unsigned dstx, unsigned dsty, unsigned dstz,
+                                struct pipe_resource *src,
+                                struct pipe_subresource subsrc,
+                                unsigned srcx, unsigned srcy, unsigned srcz,
+                                unsigned width, unsigned height)
+{
+       struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
+
+       r600_blitter_begin(ctx, R600_COPY);
+       util_blitter_copy_region(rctx->blitter, dst, subdst, dstx, dsty, dstz,
+                                src, subsrc, srcx, srcy, srcz, width, height,
+                                TRUE);
+       r600_blitter_end(ctx);
+}
+
 static void r600_resource_copy_region(struct pipe_context *ctx,
                                      struct pipe_resource *dst,
                                      struct pipe_subresource subdst,
@@ -172,8 +180,16 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
                                      unsigned srcx, unsigned srcy, unsigned srcz,
                                      unsigned width, unsigned height)
 {
-       util_resource_copy_region(ctx, dst, subdst, dstx, dsty, dstz,
-                                 src, subsrc, srcx, srcy, srcz, width, height);
+       boolean is_depth;
+       /* there is something wrong with depth resource copies at the moment so avoid them for now */
+       is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
+       if (is_depth)
+               util_resource_copy_region(ctx, dst, subdst, dstx, dsty, dstz,
+                                         src, subsrc, srcx, srcy, srcz, width, height);
+       else
+               r600_hw_copy_region(ctx, dst, subdst, dstx, dsty, dstz,
+                                   src, subsrc, srcx, srcy, srcz, width, height);
+
 }
 
 void r600_init_blit_functions(struct r600_pipe_context *rctx)