r600g: reorganise rgtc pieces.
authorDave Airlie <airlied@redhat.com>
Fri, 18 Feb 2011 05:59:58 +0000 (15:59 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 18 Feb 2011 06:00:49 +0000 (16:00 +1000)
when the cs checker fixes go upstream a lot of this can disappear
into a drm version check.

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

index 2321231..ce06d74 100644 (file)
@@ -808,6 +808,8 @@ uint32_t r600_translate_texformat(enum pipe_format format,
        uint32_t result = 0, word4 = 0, yuv_format = 0;
        const struct util_format_description *desc;
        boolean uniform = TRUE;
+       static int r600_enable_s3tc = -1;
+
        int i;
        const uint32_t sign_bit[4] = {
                S_038010_FORMAT_COMP_X(V_038010_SQ_FORMAT_COMP_SIGNED),
@@ -865,13 +867,28 @@ uint32_t r600_translate_texformat(enum pipe_format format,
                break;
        }
 
-       /* S3TC formats. TODO */
-       if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
-               static int r600_enable_s3tc = -1;
+       if (r600_enable_s3tc == -1)
+               r600_enable_s3tc = debug_get_bool_option("R600_ENABLE_S3TC", FALSE);
 
-               if (r600_enable_s3tc == -1)
-                       r600_enable_s3tc =
-                               debug_get_bool_option("R600_ENABLE_S3TC", FALSE);
+       if (desc->layout == UTIL_FORMAT_LAYOUT_RGTC) {
+               if (!r600_enable_s3tc)
+                       goto out_unknown;
+
+               switch (format) {
+               case PIPE_FORMAT_RGTC1_UNORM:
+               case PIPE_FORMAT_RGTC1_SNORM:
+                       result = FMT_BC4;
+                       goto out_word4;
+               case PIPE_FORMAT_RGTC2_UNORM:
+               case PIPE_FORMAT_RGTC2_SNORM:
+                       result = FMT_BC5;
+                       goto out_word4;
+               default:
+                       goto out_unknown;
+               }
+       }
+
+       if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
 
                if (!r600_enable_s3tc)
                        goto out_unknown;
@@ -895,14 +912,6 @@ uint32_t r600_translate_texformat(enum pipe_format format,
                case PIPE_FORMAT_DXT5_SRGBA:
                        result = FMT_BC3;
                        goto out_word4;
-               case PIPE_FORMAT_RGTC1_UNORM:
-               case PIPE_FORMAT_RGTC1_SNORM:
-                       result = FMT_BC4;
-                       goto out_word4;
-               case PIPE_FORMAT_RGTC2_UNORM:
-               case PIPE_FORMAT_RGTC2_SNORM:
-                       result = FMT_BC5;
-                       goto out_word4;
                default:
                        goto out_unknown;
                }
@@ -917,8 +926,6 @@ uint32_t r600_translate_texformat(enum pipe_format format,
 
        /* R8G8Bx_SNORM - TODO CxV8U8 */
 
-       /* RGTC - TODO */
-
        /* See whether the components are of the same size. */
        for (i = 1; i < desc->nr_channels; i++) {
                uniform = uniform && desc->channel[0].size == desc->channel[i].size;