r600g: implement MSAA resolving for 8-bit and 16-bit integer formats
authorMarek Olšák <maraeo@gmail.com>
Fri, 12 Oct 2012 04:04:01 +0000 (06:04 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 12 Oct 2012 13:23:27 +0000 (15:23 +0200)
by changing the format to NORM.

src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_blitter.h
src/gallium/drivers/r600/r600_blit.c

index 4ad7a6be4eb4b643297a82f75ee01da479b1d622..1072a0e9a74e84270492964a578664989ba5beef 100644 (file)
@@ -1704,7 +1704,8 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter,
                                       struct pipe_resource *src,
                                       unsigned src_layer,
                                       unsigned sample_mask,
-                                      void *custom_blend)
+                                      void *custom_blend,
+                                       enum pipe_format format)
 {
    struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
    struct pipe_context *pipe = ctx->base.pipe;
@@ -1724,7 +1725,7 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter,
    pipe->set_sample_mask(pipe, sample_mask);
 
    memset(&surf_tmpl, 0, sizeof(surf_tmpl));
-   surf_tmpl.format = dst->format;
+   surf_tmpl.format = format;
    surf_tmpl.u.tex.level = dst_level;
    surf_tmpl.u.tex.first_layer = dst_layer;
    surf_tmpl.u.tex.last_layer = dst_layer;
index 40636c61619a8d9aa45a41fb84cc9657b664a805..4f7146701b1f6d0107832585fbdbfdebd9d52472 100644 (file)
@@ -344,7 +344,8 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter,
                                        struct pipe_resource *src,
                                        unsigned src_layer,
                                       unsigned sampled_mask,
-                                       void *custom_blend);
+                                       void *custom_blend,
+                                       enum pipe_format format);
 
 /* The functions below should be used to save currently bound constant state
  * objects inside a driver. The objects are automatically restored at the end
index 102b3808ca229a6c9ab53f1688ea9b5f4156a596..8597b8dfcf72399b5a2ebe22e11360f03189398e 100644 (file)
@@ -574,6 +574,42 @@ static void r600_resource_copy_region(struct pipe_context *ctx,
        pipe_sampler_view_reference(&src_view, NULL);
 }
 
+/* For MSAA integer resolving to work, we change the format to NORM using this function. */
+static enum pipe_format int_to_norm_format(enum pipe_format format)
+{
+       switch (format) {
+#define REPLACE_FORMAT_SIGN(format,sign) \
+       case PIPE_FORMAT_##format##_##sign##INT: \
+               return PIPE_FORMAT_##format##_##sign##NORM
+#define REPLACE_FORMAT(format) \
+               REPLACE_FORMAT_SIGN(format, U); \
+               REPLACE_FORMAT_SIGN(format, S)
+
+       REPLACE_FORMAT_SIGN(B10G10R10A2, U);
+       REPLACE_FORMAT(R8);
+       REPLACE_FORMAT(R8G8);
+       REPLACE_FORMAT(R8G8B8);
+       REPLACE_FORMAT(R8G8B8A8);
+       REPLACE_FORMAT(A8);
+       REPLACE_FORMAT(I8);
+       REPLACE_FORMAT(L8);
+       REPLACE_FORMAT(L8A8);
+       REPLACE_FORMAT(R16);
+       REPLACE_FORMAT(R16G16);
+       REPLACE_FORMAT(R16G16B16);
+       REPLACE_FORMAT(R16G16B16A16);
+       REPLACE_FORMAT(A16);
+       REPLACE_FORMAT(I16);
+       REPLACE_FORMAT(L16);
+       REPLACE_FORMAT(L16A16);
+
+#undef REPLACE_FORMAT
+#undef REPLACE_FORMAT_SIGN
+       default:
+               return format;
+       }
+}
+
 static void r600_msaa_color_resolve(struct pipe_context *ctx,
                              const struct pipe_blit_info *info)
 {
@@ -595,7 +631,8 @@ static void r600_msaa_color_resolve(struct pipe_context *ctx,
                                                  info->dst.resource, info->dst.level,
                                                  info->dst.box.z,
                                                  info->src.resource, info->src.box.z,
-                                                 sample_mask, rctx->custom_blend_resolve);
+                                                 sample_mask, rctx->custom_blend_resolve,
+                                                  int_to_norm_format(info->dst.format));
                r600_blitter_end(ctx);
                return;
        }
@@ -620,7 +657,8 @@ static void r600_msaa_color_resolve(struct pipe_context *ctx,
        util_blitter_custom_resolve_color(rctx->blitter,
                                          tmp, 0, 0,
                                          info->src.resource, info->src.box.z,
-                                         sample_mask, rctx->custom_blend_resolve);
+                                         sample_mask, rctx->custom_blend_resolve,
+                                          int_to_norm_format(tmp->format));
        r600_blitter_end(ctx);
 
        /* blit */
@@ -645,7 +683,7 @@ static void r600_blit(struct pipe_context *ctx,
        if (info->src.resource->nr_samples > 1 &&
            info->dst.resource->nr_samples <= 1 &&
            !util_format_is_depth_or_stencil(info->src.resource->format) &&
-           !util_format_is_pure_integer(info->src.resource->format)) {
+           !util_format_is_pure_integer(int_to_norm_format(info->src.resource->format))) {
                r600_msaa_color_resolve(ctx, info);
                return;
        }