r600g: set number type correctly for color buffers.
authorDave Airlie <airlied@redhat.com>
Thu, 15 Sep 2011 11:34:43 +0000 (12:34 +0100)
committerDave Airlie <airlied@redhat.com>
Fri, 16 Sep 2011 08:25:48 +0000 (09:25 +0100)
If we get a scaled type assume its a real integer type (as textures are).

Also fixup the blend bypass and blend clamp flags on evergreen as per the
docs.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/evergreen_state.c

index 32fd74c0d1c3dae21cc051f3e06f5f4d641ae0a3..0e7e635ce8e63c90de346d62f0c6af03c27ca997 100644 (file)
@@ -1297,6 +1297,7 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state
        const struct util_format_description *desc;
        struct r600_bo *bo[3];
        int i;
+       unsigned blend_clamp = 0, blend_bypass = 0;
 
        surf = (struct r600_surface *)state->cbufs[cb];
        rtex = (struct r600_resource_texture*)state->cbufs[cb]->texture;
@@ -1325,11 +1326,20 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state
                        break;
                }
        }
-       ntype = V_028C70_NUMBER_UNORM;
        if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
                ntype = V_028C70_NUMBER_SRGB;
-       else if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED)
-               ntype = V_028C70_NUMBER_SNORM;
+       else if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {
+               if (desc->channel[i].normalized)
+                       ntype = V_028C70_NUMBER_SNORM;
+               else
+                       ntype = V_028C70_NUMBER_SINT;
+       } else if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED) {
+               if (desc->channel[i].normalized)
+                       ntype = V_028C70_NUMBER_UNORM;
+               else
+                       ntype = V_028C70_NUMBER_UINT;
+       } else
+               ntype = V_028C70_NUMBER_UNORM;
 
        format = r600_translate_colorformat(surf->base.format);
        swap = r600_translate_colorswap(surf->base.format);
@@ -1343,14 +1353,28 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state
        if ((format == FMT_32_32_32_32 || format == FMT_16_16_16_16) && rtex->force_int_type)
                ntype = V_028C70_NUMBER_UINT;
 
+       /* blend clamp should be set for all NORM/SRGB types */
+       if (ntype == V_028C70_NUMBER_UNORM || ntype == V_028C70_NUMBER_SNORM ||
+           ntype == V_028C70_NUMBER_SRGB)
+               blend_clamp = 1;
+
+       /* set blend bypass according to docs if SINT/UINT or
+          8/24 COLOR variants */
+       if (ntype == V_028C70_NUMBER_UINT || ntype == V_028C70_NUMBER_SINT ||
+           format == V_028C70_COLOR_8_24 || format == V_028C70_COLOR_24_8 ||
+           format == V_028C70_COLOR_X24_8_32_FLOAT) {
+               blend_clamp = 0;
+               blend_bypass = 1;
+       }
+
        color_info = S_028C70_FORMAT(format) |
                S_028C70_COMP_SWAP(swap) |
                S_028C70_ARRAY_MODE(rtex->array_mode[level]) |
-               S_028C70_BLEND_CLAMP(1) |
+               S_028C70_BLEND_CLAMP(blend_clamp) |
+               S_028C70_BLEND_BYPASS(blend_bypass) |
                S_028C70_NUMBER_TYPE(ntype) |
                S_028C70_ENDIAN(endian);
 
-
        /* EXPORT_NORM is an optimzation that can be enabled for better
         * performance in certain cases.
         * EXPORT_NORM can be enabled if: