r600g: fixup vertex format picking.
authorDave Airlie <airlied@redhat.com>
Fri, 1 Oct 2010 03:09:09 +0000 (13:09 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 1 Oct 2010 03:36:56 +0000 (13:36 +1000)
there are some vertex formats defined in r600c not in the docs.

src/gallium/drivers/r600/eg_state_inlines.h
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/evergreend.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_inlines.h
src/gallium/drivers/r600/r600d.h

index 497865a..c93b9d9 100644 (file)
@@ -453,25 +453,6 @@ static INLINE uint32_t r600_translate_colorformat(enum pipe_format format)
        }
 }
 
-static INLINE void r600_translate_vertex_num_format(enum pipe_format format, uint32_t *num_format_p,
-                                                   uint32_t *format_comp_p)
-{
-       uint32_t num_format = 0, format_comp = 0;
-       switch (format) {
-       case PIPE_FORMAT_R16G16B16A16_SSCALED:
-       case PIPE_FORMAT_R16G16B16_SSCALED:
-       case PIPE_FORMAT_R16G16_SSCALED:
-       case PIPE_FORMAT_R32G32_SSCALED:
-               num_format = V_030008_SQ_NUM_FORMAT_SCALED;
-               format_comp = 1;
-               break;
-       default:
-               break;
-       }
-       *num_format_p = num_format;
-       *format_comp_p = format_comp;
-}
-
 static INLINE boolean r600_is_sampler_format_supported(enum pipe_format format)
 {
        return r600_translate_texformat(format, NULL, NULL, NULL) != ~0;
@@ -493,4 +474,173 @@ static INLINE boolean r600_is_vertex_format_supported(enum pipe_format format)
        return r600_translate_colorformat(format) != ~0;
 }
 
+static INLINE uint32_t r600_translate_vertex_data_type(enum pipe_format format)
+{
+       uint32_t result = 0;
+       const struct util_format_description *desc;
+       unsigned i;
+
+       desc = util_format_description(format);
+       if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
+               goto out_unknown;
+       }
+
+       /* Find the first non-VOID channel. */
+       for (i = 0; i < 4; i++) {
+               if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
+                       break;
+               }
+       }
+
+       switch (desc->channel[i].type) {
+               /* Half-floats, floats, doubles */
+        case UTIL_FORMAT_TYPE_FLOAT:
+               switch (desc->channel[i].size) {
+                case 16:
+                       switch (desc->nr_channels) {
+                       case 1:
+                               result = V_030008_FMT_16_FLOAT;
+                               break;
+                       case 2:
+                               result = V_030008_FMT_16_16_FLOAT;
+                               break;
+                       case 3:
+                               result = V_030008_FMT_16_16_16_FLOAT;
+                               break;
+                       case 4:
+                               result = V_030008_FMT_16_16_16_16_FLOAT;
+                               break;
+                       }
+                       break;
+                case 32:
+                       switch (desc->nr_channels) {
+                       case 1:
+                               result = V_030008_FMT_32_FLOAT;
+                               break;
+                       case 2:
+                               result = V_030008_FMT_32_32_FLOAT;
+                               break;
+                       case 3:
+                               result = V_030008_FMT_32_32_32_FLOAT;
+                               break;
+                       case 4:
+                               result = V_030008_FMT_32_32_32_32_FLOAT;
+                               break;
+                       }
+                       break;
+                default:
+                       goto out_unknown;
+               }
+               break;
+               /* Unsigned ints */
+        case UTIL_FORMAT_TYPE_UNSIGNED:
+               /* Signed ints */
+        case UTIL_FORMAT_TYPE_SIGNED:
+               switch (desc->channel[i].size) {
+                case 8:
+                       switch (desc->nr_channels) {
+                       case 1:
+                               result = V_030008_FMT_8;
+                               break;
+                       case 2:
+                               result = V_030008_FMT_8_8;
+                               break;
+                       case 3:
+                       //      result = V_038008_FMT_8_8_8; /* fails piglit draw-vertices test */
+                       //      break;
+                       case 4:
+                               result = V_030008_FMT_8_8_8_8;
+                               break;
+                       }
+                       break;
+                case 16:
+                       switch (desc->nr_channels) {
+                       case 1:
+                               result = V_030008_FMT_16;
+                               break;
+                       case 2:
+                               result = V_030008_FMT_16_16;
+                               break;
+                       case 3:
+                       //      result = V_038008_FMT_16_16_16; /* fails piglit draw-vertices test */
+                       //      break;
+                       case 4:
+                               result = V_030008_FMT_16_16_16_16;
+                               break;
+                       }
+                       break;
+                case 32:
+                       switch (desc->nr_channels) {
+                       case 1:
+                               result = V_030008_FMT_32;
+                               break;
+                       case 2:
+                               result = V_030008_FMT_32_32;
+                               break;
+                       case 3:
+                               result = V_030008_FMT_32_32_32;
+                               break;
+                       case 4:
+                               result = V_030008_FMT_32_32_32_32;
+                               break;
+                       }
+                       break;
+                default:
+                       goto out_unknown;
+               }
+               break;
+        default:
+               goto out_unknown;
+       }
+       
+       result = S_030008_DATA_FORMAT(result);
+
+       if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {
+               result |= S_030008_FORMAT_COMP_ALL(1);
+       }
+       if (desc->channel[i].normalized) {
+               result |= S_030008_NUM_FORMAT_ALL(0);
+       } else {
+               result |= S_030008_NUM_FORMAT_ALL(2);
+       }
+       return result;
+out_unknown:
+       R600_ERR("unsupported vertex format %s\n", util_format_name(format));
+       return ~0;
+}
+
+static INLINE uint32_t r600_translate_vertex_data_swizzle(enum pipe_format format)
+{
+        const struct util_format_description *desc = util_format_description(format);
+        unsigned i;
+        uint32_t word3;
+
+        assert(format);
+
+        if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
+                fprintf(stderr, "r600: Bad format %s in %s:%d\n",
+                        util_format_short_name(format), __FUNCTION__, __LINE__);
+                return 0;
+        }
+
+        word3 = 0;
+        for (i = 0; i < desc->nr_channels; i++) {
+                switch (i) {
+                case 0:
+                        word3 |= S_03000C_DST_SEL_X(desc->swizzle[0]);
+                        break;
+                case 1:
+                        word3 |= S_03000C_DST_SEL_Y(desc->swizzle[1]);
+                        break;
+                case 2:
+                        word3 |= S_03000C_DST_SEL_Z(desc->swizzle[2]);
+                        break;
+                case 3:
+                        word3 |= S_03000C_DST_SEL_W(desc->swizzle[3]);
+                        break;
+                }
+        }
+        return word3;
+}
+
 #endif
index 06dc840..2f5f1bf 100644 (file)
@@ -1334,7 +1334,7 @@ void evergreen_draw(struct pipe_context *ctx, const struct pipe_draw_info *info)
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_pipe_state *rstate;
        struct r600_resource *rbuffer;
-       unsigned i, j, offset, format, prim;
+       unsigned i, j, offset, prim;
        u32 vgt_dma_index_type, vgt_draw_initiator, mask;
        struct pipe_vertex_buffer *vertex_buffer;
        struct r600_draw rdraw;
@@ -1402,34 +1402,28 @@ void evergreen_draw(struct pipe_context *ctx, const struct pipe_draw_info *info)
                return;
 
        for (i = 0 ; i < rctx->vertex_elements->count; i++) {
-               unsigned num_format = 0, format_comp = 0;
-
+               uint32_t word3, word2;
+               uint32_t format;
                rstate = &rctx->vs_resource[i];
+
+               rstate->id = R600_PIPE_STATE_RESOURCE;
+               rstate->nregs = 0;
+
                j = rctx->vertex_elements->elements[i].vertex_buffer_index;
                vertex_buffer = &rctx->vertex_buffer[j];
                rbuffer = (struct r600_resource*)vertex_buffer->buffer;
                offset = rctx->vertex_elements->elements[i].src_offset + vertex_buffer->buffer_offset;
-               format = r600_translate_colorformat(rctx->vertex_elements->elements[i].src_format);
-               rstate->id = R600_PIPE_STATE_RESOURCE;
-               rstate->nregs = 0;
 
-               r600_translate_vertex_num_format(rctx->vertex_elements->elements[i].src_format, &num_format, &format_comp);
+               format = r600_translate_vertex_data_type(rctx->vertex_elements->elements[i].src_format);
+
+               word2 = format | S_030008_STRIDE(vertex_buffer->stride);
+
+               word3 = r600_translate_vertex_data_swizzle(rctx->vertex_elements->elements[i].src_format);
+
                r600_pipe_state_add_reg(rstate, R_030000_RESOURCE0_WORD0, offset, 0xFFFFFFFF, rbuffer->bo);
                r600_pipe_state_add_reg(rstate, R_030004_RESOURCE0_WORD1, rbuffer->size - offset - 1, 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate,
-                                       R_030008_RESOURCE0_WORD2,
-                                       S_030008_STRIDE(vertex_buffer->stride) |
-                                       S_030008_DATA_FORMAT(format) |
-                                       S_030008_NUM_FORMAT_ALL(num_format) |
-                                       S_030008_FORMAT_COMP_ALL(format_comp),
-                                       0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate,
-                                       R_03000C_RESOURCE0_WORD3,
-                                       S_03000C_DST_SEL_X(V_03000C_SQ_SEL_X) |
-                                       S_03000C_DST_SEL_Y(V_03000C_SQ_SEL_Y) |
-                                       S_03000C_DST_SEL_Z(V_03000C_SQ_SEL_Z) |
-                                       S_03000C_DST_SEL_W(V_03000C_SQ_SEL_W),
-                                       0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg(rstate, R_030008_RESOURCE0_WORD2, word2, 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg(rstate, R_03000C_RESOURCE0_WORD3, word3, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_030010_RESOURCE0_WORD4, 0x00000000, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_030014_RESOURCE0_WORD5, 0x00000000, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_030018_RESOURCE0_WORD6, 0x00000000, 0xFFFFFFFF, NULL);
index ce2b667..f9328c6 100644 (file)
 #define   S_030008_DATA_FORMAT(x)                      (((x) & 0x3F) << 20)
 #define   G_030008_DATA_FORMAT(x)                      (((x) >> 20) & 0x3F)
 #define   C_030008_DATA_FORMAT                         0xFC0FFFFF
-#define     V_030008_COLOR_INVALID                     0x00000000
-#define     V_030008_COLOR_8                           0x00000001
-#define     V_030008_COLOR_4_4                         0x00000002
-#define     V_030008_COLOR_3_3_2                       0x00000003
-#define     V_030008_COLOR_16                          0x00000005
-#define     V_030008_COLOR_16_FLOAT                    0x00000006
-#define     V_030008_COLOR_8_8                         0x00000007
-#define     V_030008_COLOR_5_6_5                       0x00000008
-#define     V_030008_COLOR_6_5_5                       0x00000009
-#define     V_030008_COLOR_1_5_5_5                     0x0000000A
-#define     V_030008_COLOR_4_4_4_4                     0x0000000B
-#define     V_030008_COLOR_5_5_5_1                     0x0000000C
-#define     V_030008_COLOR_32                          0x0000000D
-#define     V_030008_COLOR_32_FLOAT                    0x0000000E
-#define     V_030008_COLOR_16_16                       0x0000000F
-#define     V_030008_COLOR_16_16_FLOAT                 0x00000010
-#define     V_030008_COLOR_8_24                        0x00000011
-#define     V_030008_COLOR_8_24_FLOAT                  0x00000012
-#define     V_030008_COLOR_24_8                        0x00000013
-#define     V_030008_COLOR_24_8_FLOAT                  0x00000014
-#define     V_030008_COLOR_10_11_11                    0x00000015
-#define     V_030008_COLOR_10_11_11_FLOAT              0x00000016
-#define     V_030008_COLOR_11_11_10                    0x00000017
-#define     V_030008_COLOR_11_11_10_FLOAT              0x00000018
-#define     V_030008_COLOR_2_10_10_10                  0x00000019
-#define     V_030008_COLOR_8_8_8_8                     0x0000001A
-#define     V_030008_COLOR_10_10_10_2                  0x0000001B
-#define     V_030008_COLOR_X24_8_32_FLOAT              0x0000001C
-#define     V_030008_COLOR_32_32                       0x0000001D
-#define     V_030008_COLOR_32_32_FLOAT                 0x0000001E
-#define     V_030008_COLOR_16_16_16_16                 0x0000001F
-#define     V_030008_COLOR_16_16_16_16_FLOAT           0x00000020
-#define     V_030008_COLOR_32_32_32_32                 0x00000022
-#define     V_030008_COLOR_32_32_32_32_FLOAT           0x00000023
+#define     V_030008_FMT_INVALID                     0x00000000
+#define     V_030008_FMT_8                           0x00000001
+#define     V_030008_FMT_4_4                         0x00000002
+#define     V_030008_FMT_3_3_2                       0x00000003
+#define     V_030008_FMT_16                          0x00000005
+#define     V_030008_FMT_16_FLOAT                    0x00000006
+#define     V_030008_FMT_8_8                         0x00000007
+#define     V_030008_FMT_5_6_5                       0x00000008
+#define     V_030008_FMT_6_5_5                       0x00000009
+#define     V_030008_FMT_1_5_5_5                     0x0000000A
+#define     V_030008_FMT_4_4_4_4                     0x0000000B
+#define     V_030008_FMT_5_5_5_1                     0x0000000C
+#define     V_030008_FMT_32                          0x0000000D
+#define     V_030008_FMT_32_FLOAT                    0x0000000E
+#define     V_030008_FMT_16_16                       0x0000000F
+#define     V_030008_FMT_16_16_FLOAT                 0x00000010
+#define     V_030008_FMT_8_24                        0x00000011
+#define     V_030008_FMT_8_24_FLOAT                  0x00000012
+#define     V_030008_FMT_24_8                        0x00000013
+#define     V_030008_FMT_24_8_FLOAT                  0x00000014
+#define     V_030008_FMT_10_11_11                    0x00000015
+#define     V_030008_FMT_10_11_11_FLOAT              0x00000016
+#define     V_030008_FMT_11_11_10                    0x00000017
+#define     V_030008_FMT_11_11_10_FLOAT              0x00000018
+#define     V_030008_FMT_2_10_10_10                  0x00000019
+#define     V_030008_FMT_8_8_8_8                     0x0000001A
+#define     V_030008_FMT_10_10_10_2                  0x0000001B
+#define     V_030008_FMT_X24_8_32_FLOAT              0x0000001C
+#define     V_030008_FMT_32_32                       0x0000001D
+#define     V_030008_FMT_32_32_FLOAT                 0x0000001E
+#define     V_030008_FMT_16_16_16_16                 0x0000001F
+#define     V_030008_FMT_16_16_16_16_FLOAT           0x00000020
+#define     V_030008_FMT_32_32_32_32                 0x00000022
+#define     V_030008_FMT_32_32_32_32_FLOAT           0x00000023
+#define     V_030008_FMT_8_8_8                       0x0000002c
+#define     V_030008_FMT_16_16_16                    0x0000002d
+#define     V_030008_FMT_16_16_16_FLOAT              0x0000002e
+#define     V_030008_FMT_32_32_32                    0x0000002f
+#define     V_030008_FMT_32_32_32_FLOAT              0x00000030
 #define   S_030008_NUM_FORMAT_ALL(x)                   (((x) & 0x3) << 26)
 #define   G_030008_NUM_FORMAT_ALL(x)                   (((x) >> 26) & 0x3)
 #define   C_030008_NUM_FORMAT_ALL                      0xF3FFFFFF
index c86bad7..8ed8718 100644 (file)
@@ -52,7 +52,7 @@ static void r600_draw_common(struct r600_drawl *draw)
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)draw->ctx;
        struct r600_pipe_state *rstate;
        struct r600_resource *rbuffer;
-       unsigned i, j, offset, format, prim;
+       unsigned i, j, offset, prim;
        u32 vgt_dma_index_type, vgt_draw_initiator, mask;
        struct pipe_vertex_buffer *vertex_buffer;
        struct r600_draw rdraw;
@@ -86,27 +86,24 @@ static void r600_draw_common(struct r600_drawl *draw)
                return;
 
        for (i = 0 ; i < rctx->vertex_elements->count; i++) {
-               unsigned num_format = 0, format_comp = 0;
+               uint32_t word2, format;
 
                rstate = &rctx->vs_resource[i];
+               rstate->id = R600_PIPE_STATE_RESOURCE;
+               rstate->nregs = 0;
+
                j = rctx->vertex_elements->elements[i].vertex_buffer_index;
                vertex_buffer = &rctx->vertex_buffer[j];
                rbuffer = (struct r600_resource*)vertex_buffer->buffer;
                offset = rctx->vertex_elements->elements[i].src_offset + vertex_buffer->buffer_offset;
-               format = r600_translate_colorformat(rctx->vertex_elements->elements[i].src_format);
-               rstate->id = R600_PIPE_STATE_RESOURCE;
-               rstate->nregs = 0;
 
-               r600_translate_vertex_num_format(rctx->vertex_elements->elements[i].src_format, &num_format, &format_comp);
+               format = r600_translate_vertex_data_type(rctx->vertex_elements->elements[i].src_format);
+
+               word2 = format | S_038008_STRIDE(vertex_buffer->stride);
+
                r600_pipe_state_add_reg(rstate, R_038000_RESOURCE0_WORD0, offset, 0xFFFFFFFF, rbuffer->bo);
                r600_pipe_state_add_reg(rstate, R_038004_RESOURCE0_WORD1, rbuffer->size - offset - 1, 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate,
-                                       R_038008_RESOURCE0_WORD2,
-                                       S_038008_STRIDE(vertex_buffer->stride) |
-                                       S_038008_DATA_FORMAT(format) |
-                                       S_038008_NUM_FORMAT_ALL(num_format) |
-                                       S_038008_FORMAT_COMP_ALL(format_comp),
-                                       0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg(rstate, R_038008_RESOURCE0_WORD2, word2, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_03800C_RESOURCE0_WORD3, 0x00000000, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_038010_RESOURCE0_WORD4, 0x00000000, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_038014_RESOURCE0_WORD5, 0x00000000, 0xFFFFFFFF, NULL);
index f41b6a0..81f2850 100644 (file)
@@ -464,29 +464,6 @@ static INLINE uint32_t r600_translate_colorformat(enum pipe_format format)
        }
 }
 
-static INLINE void r600_translate_vertex_num_format(enum pipe_format format, uint32_t *num_format_p,
-                                                   uint32_t *format_comp_p)
-{
-       uint32_t num_format = 0, format_comp = 0;
-       switch (format) {
-       case PIPE_FORMAT_R16G16B16A16_SSCALED:
-       case PIPE_FORMAT_R16G16B16_SSCALED:
-       case PIPE_FORMAT_R16G16_SSCALED:
-       case PIPE_FORMAT_R32G32_SSCALED:
-               format_comp = 1;
-       case PIPE_FORMAT_R16G16B16A16_USCALED:
-       case PIPE_FORMAT_R16G16B16_USCALED:
-       case PIPE_FORMAT_R16G16_USCALED:
-       case PIPE_FORMAT_R32G32_USCALED:
-               num_format = V_038008_SQ_NUM_FORMAT_SCALED;
-               break;
-       default:
-               break;
-       }
-       *num_format_p = num_format;
-       *format_comp_p = format_comp;
-}
-
 static INLINE boolean r600_is_sampler_format_supported(enum pipe_format format)
 {
        return r600_translate_texformat(format, NULL, NULL, NULL) != ~0;
@@ -508,4 +485,139 @@ static INLINE boolean r600_is_vertex_format_supported(enum pipe_format format)
        return r600_translate_colorformat(format) != ~0;
 }
 
+static INLINE uint32_t r600_translate_vertex_data_type(enum pipe_format format)
+{
+       uint32_t result = 0;
+       const struct util_format_description *desc;
+       unsigned i;
+
+       desc = util_format_description(format);
+       if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
+               goto out_unknown;
+       }
+
+       /* Find the first non-VOID channel. */
+       for (i = 0; i < 4; i++) {
+               if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
+                       break;
+               }
+       }
+
+       switch (desc->channel[i].type) {
+               /* Half-floats, floats, doubles */
+        case UTIL_FORMAT_TYPE_FLOAT:
+               switch (desc->channel[i].size) {
+                case 16:
+                       switch (desc->nr_channels) {
+                       case 1:
+                               result = V_038008_FMT_16_FLOAT;
+                               break;
+                       case 2:
+                               result = V_038008_FMT_16_16_FLOAT;
+                               break;
+                       case 3:
+                               result = V_038008_FMT_16_16_16_FLOAT;
+                               break;
+                       case 4:
+                               result = V_038008_FMT_16_16_16_16_FLOAT;
+                               break;
+                       }
+                       break;
+                case 32:
+                       switch (desc->nr_channels) {
+                       case 1:
+                               result = V_038008_FMT_32_FLOAT;
+                               break;
+                       case 2:
+                               result = V_038008_FMT_32_32_FLOAT;
+                               break;
+                       case 3:
+                               result = V_038008_FMT_32_32_32_FLOAT;
+                               break;
+                       case 4:
+                               result = V_038008_FMT_32_32_32_32_FLOAT;
+                               break;
+                       }
+                       break;
+                default:
+                       goto out_unknown;
+               }
+               break;
+               /* Unsigned ints */
+        case UTIL_FORMAT_TYPE_UNSIGNED:
+               /* Signed ints */
+        case UTIL_FORMAT_TYPE_SIGNED:
+               switch (desc->channel[i].size) {
+                case 8:
+                       switch (desc->nr_channels) {
+                       case 1:
+                               result = V_038008_FMT_8;
+                               break;
+                       case 2:
+                               result = V_038008_FMT_8_8;
+                               break;
+                       case 3:
+                       //      result = V_038008_FMT_8_8_8; /* fails piglit draw-vertices test */
+                       //      break;
+                       case 4:
+                               result = V_038008_FMT_8_8_8_8;
+                               break;
+                       }
+                       break;
+                case 16:
+                       switch (desc->nr_channels) {
+                       case 1:
+                               result = V_038008_FMT_16;
+                               break;
+                       case 2:
+                               result = V_038008_FMT_16_16;
+                               break;
+                       case 3:
+                       //      result = V_038008_FMT_16_16_16; /* fails piglit draw-vertices test */
+                       //      break;
+                       case 4:
+                               result = V_038008_FMT_16_16_16_16;
+                               break;
+                       }
+                       break;
+                case 32:
+                       switch (desc->nr_channels) {
+                       case 1:
+                               result = V_038008_FMT_32;
+                               break;
+                       case 2:
+                               result = V_038008_FMT_32_32;
+                               break;
+                       case 3:
+                               result = V_038008_FMT_32_32_32;
+                               break;
+                       case 4:
+                               result = V_038008_FMT_32_32_32_32;
+                               break;
+                       }
+                       break;
+                default:
+                       goto out_unknown;
+               }
+               break;
+        default:
+               goto out_unknown;
+       }
+       
+       result = S_038008_DATA_FORMAT(result);
+
+       if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {
+               result |= S_038008_FORMAT_COMP_ALL(1);
+       }
+       if (desc->channel[i].normalized) {
+               result |= S_038008_NUM_FORMAT_ALL(0);
+       } else {
+               result |= S_038008_NUM_FORMAT_ALL(2);
+       }
+       return result;
+out_unknown:
+       R600_ERR("unsupported vertex format %s\n", util_format_name(format));
+       return ~0;
+}
+
 #endif
index 02e3734..3d1c5db 100644 (file)
 #define   S_038008_DATA_FORMAT(x)                      (((x) & 0x3F) << 20)
 #define   G_038008_DATA_FORMAT(x)                      (((x) >> 20) & 0x3F)
 #define   C_038008_DATA_FORMAT                         0xFC0FFFFF
-#define     V_038008_COLOR_INVALID                     0x00000000
-#define     V_038008_COLOR_8                           0x00000001
-#define     V_038008_COLOR_4_4                         0x00000002
-#define     V_038008_COLOR_3_3_2                       0x00000003
-#define     V_038008_COLOR_16                          0x00000005
-#define     V_038008_COLOR_16_FLOAT                    0x00000006
-#define     V_038008_COLOR_8_8                         0x00000007
-#define     V_038008_COLOR_5_6_5                       0x00000008
-#define     V_038008_COLOR_6_5_5                       0x00000009
-#define     V_038008_COLOR_1_5_5_5                     0x0000000A
-#define     V_038008_COLOR_4_4_4_4                     0x0000000B
-#define     V_038008_COLOR_5_5_5_1                     0x0000000C
-#define     V_038008_COLOR_32                          0x0000000D
-#define     V_038008_COLOR_32_FLOAT                    0x0000000E
-#define     V_038008_COLOR_16_16                       0x0000000F
-#define     V_038008_COLOR_16_16_FLOAT                 0x00000010
-#define     V_038008_COLOR_8_24                        0x00000011
-#define     V_038008_COLOR_8_24_FLOAT                  0x00000012
-#define     V_038008_COLOR_24_8                        0x00000013
-#define     V_038008_COLOR_24_8_FLOAT                  0x00000014
-#define     V_038008_COLOR_10_11_11                    0x00000015
-#define     V_038008_COLOR_10_11_11_FLOAT              0x00000016
-#define     V_038008_COLOR_11_11_10                    0x00000017
-#define     V_038008_COLOR_11_11_10_FLOAT              0x00000018
-#define     V_038008_COLOR_2_10_10_10                  0x00000019
-#define     V_038008_COLOR_8_8_8_8                     0x0000001A
-#define     V_038008_COLOR_10_10_10_2                  0x0000001B
-#define     V_038008_COLOR_X24_8_32_FLOAT              0x0000001C
-#define     V_038008_COLOR_32_32                       0x0000001D
-#define     V_038008_COLOR_32_32_FLOAT                 0x0000001E
-#define     V_038008_COLOR_16_16_16_16                 0x0000001F
-#define     V_038008_COLOR_16_16_16_16_FLOAT           0x00000020
-#define     V_038008_COLOR_32_32_32_32                 0x00000022
-#define     V_038008_COLOR_32_32_32_32_FLOAT           0x00000023
+#define     V_038008_FMT_INVALID                     0x00000000
+#define     V_038008_FMT_8                           0x00000001
+#define     V_038008_FMT_4_4                         0x00000002
+#define     V_038008_FMT_3_3_2                       0x00000003
+#define     V_038008_FMT_16                          0x00000005
+#define     V_038008_FMT_16_FLOAT                    0x00000006
+#define     V_038008_FMT_8_8                         0x00000007
+#define     V_038008_FMT_5_6_5                       0x00000008
+#define     V_038008_FMT_6_5_5                       0x00000009
+#define     V_038008_FMT_1_5_5_5                     0x0000000A
+#define     V_038008_FMT_4_4_4_4                     0x0000000B
+#define     V_038008_FMT_5_5_5_1                     0x0000000C
+#define     V_038008_FMT_32                          0x0000000D
+#define     V_038008_FMT_32_FLOAT                    0x0000000E
+#define     V_038008_FMT_16_16                       0x0000000F
+#define     V_038008_FMT_16_16_FLOAT                 0x00000010
+#define     V_038008_FMT_8_24                        0x00000011
+#define     V_038008_FMT_8_24_FLOAT                  0x00000012
+#define     V_038008_FMT_24_8                        0x00000013
+#define     V_038008_FMT_24_8_FLOAT                  0x00000014
+#define     V_038008_FMT_10_11_11                    0x00000015
+#define     V_038008_FMT_10_11_11_FLOAT              0x00000016
+#define     V_038008_FMT_11_11_10                    0x00000017
+#define     V_038008_FMT_11_11_10_FLOAT              0x00000018
+#define     V_038008_FMT_2_10_10_10                  0x00000019
+#define     V_038008_FMT_8_8_8_8                     0x0000001A
+#define     V_038008_FMT_10_10_10_2                  0x0000001B
+#define     V_038008_FMT_X24_8_32_FLOAT              0x0000001C
+#define     V_038008_FMT_32_32                       0x0000001D
+#define     V_038008_FMT_32_32_FLOAT                 0x0000001E
+#define     V_038008_FMT_16_16_16_16                 0x0000001F
+#define     V_038008_FMT_16_16_16_16_FLOAT           0x00000020
+#define     V_038008_FMT_32_32_32_32                 0x00000022
+#define     V_038008_FMT_32_32_32_32_FLOAT           0x00000023
+#define     V_038008_FMT_8_8_8                       0x0000002c
+#define     V_038008_FMT_16_16_16                    0x0000002d
+#define     V_038008_FMT_16_16_16_FLOAT              0x0000002e
+#define     V_038008_FMT_32_32_32                    0x0000002f
+#define     V_038008_FMT_32_32_32_FLOAT              0x00000030
 #define   S_038008_NUM_FORMAT_ALL(x)                   (((x) & 0x3) << 26)
 #define   G_038008_NUM_FORMAT_ALL(x)                   (((x) >> 26) & 0x3)
 #define   C_038008_NUM_FORMAT_ALL                      0xF3FFFFFF