gallium: remove redundant nr_components field from pipe_vertex_element
authorRoland Scheidegger <sroland@vmware.com>
Wed, 17 Feb 2010 15:44:38 +0000 (16:44 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Wed, 17 Feb 2010 15:44:38 +0000 (16:44 +0100)
This is a property of the associated src_format pipe format.
Hence use util_format_get_nr_components to query this when necessary instead.

13 files changed:
progs/gallium/python/retrace/interpreter.py
src/gallium/auxiliary/draw/draw_pt.c
src/gallium/auxiliary/util/u_draw_quad.c
src/gallium/auxiliary/util/u_dump_state.c
src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
src/gallium/drivers/i965/brw_draw_upload.c
src/gallium/drivers/nv50/nv50_vbo.c
src/gallium/drivers/trace/tr_dump_state.c
src/gallium/include/pipe/p_state.h
src/gallium/state_trackers/vega/polygon.c
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_draw_feedback.c

index 2db71a212f623e905eab9ae3b22b8c938b0e298b..52c08abdd37b3c3f71e0a421db151f297a159af0 100755 (executable)
@@ -551,7 +551,6 @@ class Context(Object):
                 data = vbuf.buffer.read()
                 values = unpack_from(format, data, offset)
                 sys.stdout.write('\t\t{' + ', '.join(map(str, values)) + '},\n')
-                assert len(values) == velem.nr_components
             sys.stdout.write('\t},\n')
         sys.stdout.flush()
 
index 341353f6289002030ecdda2a78e859f42423cb66..51beba50e4d1831ee3393fa561d39e4450a5942f 100644 (file)
@@ -309,9 +309,8 @@ draw_arrays_instanced(struct draw_context *draw,
       tgsi_dump(draw->vs.vertex_shader->state.tokens, 0);
       debug_printf("Elements:\n");
       for (i = 0; i < draw->pt.nr_vertex_elements; i++) {
-         debug_printf("  format=%s comps=%u\n",
-                      util_format_name(draw->pt.vertex_element[i].src_format),
-                      draw->pt.vertex_element[i].nr_components);
+         debug_printf("  format=%s\n",
+                      util_format_name(draw->pt.vertex_element[i].src_format));
       }
       debug_printf("Buffers:\n");
       for (i = 0; i < draw->pt.nr_vertex_buffers; i++) {
index 14506e8451968b238373eba26675b8d238cff26a..36e9a4941f466df9500b455f3d83f7f8d7af8378 100644 (file)
@@ -64,7 +64,6 @@ util_draw_vertex_buffer(struct pipe_context *pipe,
       velements[i].instance_divisor = 0;
       velements[i].vertex_buffer_index = 0;
       velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
-      velements[i].nr_components = 4;
    }
    pipe->set_vertex_elements(pipe, num_attribs, velements);
 
index eaf4ec90f254a08c59a12b641076368532bdd88b..196c5e06e954398bfb239695ca20739de40694a0 100644 (file)
@@ -701,7 +701,6 @@ util_dump_vertex_element(struct os_stream *stream, const struct pipe_vertex_elem
    util_dump_member(stream, uint, state, src_offset);
 
    util_dump_member(stream, uint, state, vertex_buffer_index);
-   util_dump_member(stream, uint, state, nr_components);
 
    util_dump_member(stream, format, state, src_format);
 
index ba23435f698240257bf29fe798937e66dab6dbed..5d61423f9d347bb5d74ce27d0d999778b37e1f6a 100644 (file)
@@ -317,7 +317,6 @@ init_buffers(struct vl_compositor *c)
    c->vertex_elems[0].src_offset = 0;
    c->vertex_elems[0].instance_divisor = 0;
    c->vertex_elems[0].vertex_buffer_index = 0;
-   c->vertex_elems[0].nr_components = 2;
    c->vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
    /*
@@ -347,7 +346,6 @@ init_buffers(struct vl_compositor *c)
    c->vertex_elems[1].src_offset = 0;
    c->vertex_elems[1].instance_divisor = 0;
    c->vertex_elems[1].vertex_buffer_index = 1;
-   c->vertex_elems[1].nr_components = 2;
    c->vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
    /*
index f323de0ea55d0bfe2ac84ddcdd3c10af52a29d25..6b9ecd42685db66bd0522be7395be1543f95d6c7 100644 (file)
@@ -892,56 +892,48 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
    r->vertex_elems[0].src_offset = 0;
    r->vertex_elems[0].instance_divisor = 0;
    r->vertex_elems[0].vertex_buffer_index = 0;
-   r->vertex_elems[0].nr_components = 2;
    r->vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
    /* Luma, texcoord element */
    r->vertex_elems[1].src_offset = sizeof(struct vertex2f);
    r->vertex_elems[1].instance_divisor = 0;
    r->vertex_elems[1].vertex_buffer_index = 0;
-   r->vertex_elems[1].nr_components = 2;
    r->vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
    /* Chroma Cr texcoord element */
    r->vertex_elems[2].src_offset = sizeof(struct vertex2f) * 2;
    r->vertex_elems[2].instance_divisor = 0;
    r->vertex_elems[2].vertex_buffer_index = 0;
-   r->vertex_elems[2].nr_components = 2;
    r->vertex_elems[2].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
    /* Chroma Cb texcoord element */
    r->vertex_elems[3].src_offset = sizeof(struct vertex2f) * 3;
    r->vertex_elems[3].instance_divisor = 0;
    r->vertex_elems[3].vertex_buffer_index = 0;
-   r->vertex_elems[3].nr_components = 2;
    r->vertex_elems[3].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
    /* First ref surface top field texcoord element */
    r->vertex_elems[4].src_offset = 0;
    r->vertex_elems[4].instance_divisor = 0;
    r->vertex_elems[4].vertex_buffer_index = 1;
-   r->vertex_elems[4].nr_components = 2;
    r->vertex_elems[4].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
    /* First ref surface bottom field texcoord element */
    r->vertex_elems[5].src_offset = sizeof(struct vertex2f);
    r->vertex_elems[5].instance_divisor = 0;
    r->vertex_elems[5].vertex_buffer_index = 1;
-   r->vertex_elems[5].nr_components = 2;
    r->vertex_elems[5].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
    /* Second ref surface top field texcoord element */
    r->vertex_elems[6].src_offset = 0;
    r->vertex_elems[6].instance_divisor = 0;
    r->vertex_elems[6].vertex_buffer_index = 2;
-   r->vertex_elems[6].nr_components = 2;
    r->vertex_elems[6].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
    /* Second ref surface bottom field texcoord element */
    r->vertex_elems[7].src_offset = sizeof(struct vertex2f);
    r->vertex_elems[7].instance_divisor = 0;
    r->vertex_elems[7].vertex_buffer_index = 2;
-   r->vertex_elems[7].nr_components = 2;
    r->vertex_elems[7].src_format = PIPE_FORMAT_R32G32_FLOAT;
 
    r->vs_const_buf = pipe_buffer_create
index d59261557b58ba2f9cbcb35d457448e902193b04..9eafdd408551857ed364af1fc108fae400e560d4 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "util/u_upload_mgr.h"
 #include "util/u_math.h"
+#include "util/u_format.h"
 
 #include "brw_draw.h"
 #include "brw_defines.h"
@@ -352,13 +353,15 @@ static int brw_emit_vertex_elements(struct brw_context *brw)
    OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | ((1 + nr * 2) - 2));
    for (i = 0; i < nr; i++) {
       const struct pipe_vertex_element *input = &brw->curr.vertex_element[i];
+      unsigned nr_components = util_format_get_nr_components(input->src_format);
+
       uint32_t format = brw_translate_surface_format( input->src_format );
       uint32_t comp0 = BRW_VE1_COMPONENT_STORE_SRC;
       uint32_t comp1 = BRW_VE1_COMPONENT_STORE_SRC;
       uint32_t comp2 = BRW_VE1_COMPONENT_STORE_SRC;
       uint32_t comp3 = BRW_VE1_COMPONENT_STORE_SRC;
 
-      switch (input->nr_components) {
+      switch (nr_components) {
       case 0: comp0 = BRW_VE1_COMPONENT_STORE_0;
       case 1: comp1 = BRW_VE1_COMPONENT_STORE_0;
       case 2: comp2 = BRW_VE1_COMPONENT_STORE_0;
index 1c8ee0b9adf83364c5720ef7f3a4c8d293c3e91f..909d323e0570d8d7e329d5b160b4b198a34bfb2b 100644 (file)
@@ -139,15 +139,16 @@ nv50_vbo_vtxelt_to_hw(struct pipe_vertex_element *ve)
        uint32_t hw_type, hw_size;
        enum pipe_format pf = ve->src_format;
        const struct util_format_description *desc;
-       unsigned size;
+       unsigned size, nr_components;
 
        desc = util_format_description(pf);
        assert(desc);
 
        size = util_format_get_component_bits(pf, UTIL_FORMAT_COLORSPACE_RGB, 0);
+       nr_components = util_format_get_nr_components(pf);
 
        hw_type = nv50_vbo_type_to_hw(pf);
-       hw_size = nv50_vbo_size_to_hw(size, ve->nr_components);
+       hw_size = nv50_vbo_size_to_hw(size, nr_components);
 
        if (!hw_type || !hw_size) {
                NOUVEAU_ERR("unsupported vbo format: %s\n", util_format_name(pf));
@@ -222,11 +223,13 @@ nv50_set_static_vtxattr(struct nv50_context *nv50, unsigned i, void *data)
        struct nouveau_grobj *tesla = nv50->screen->tesla;
        struct nouveau_channel *chan = tesla->channel;
        float v[4];
+       unsigned nr_components = util_format_get_nr_components(nv50->vtxelt[i].src_format);
+       
 
        util_format_read_4f(nv50->vtxelt[i].src_format,
                            v, 0, data, 0, 0, 0, 1, 1);
 
-       switch (nv50->vtxelt[i].nr_components) {
+       switch (nr_components) {
        case 4:
                BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_4F_X(i), 4);
                OUT_RINGf (chan, v[0]);
@@ -726,6 +729,7 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib,
        struct nouveau_bo *bo = nouveau_bo(vb->buffer);
        float v[4];
        int ret;
+       unsigned nr_components = util_format_get_nr_components(ve->src_format);
 
        ret = nouveau_bo_map(bo, NOUVEAU_BO_RD);
        if (ret)
@@ -738,7 +742,7 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib,
        if (!so)
                *pso = so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 4, 0);
 
-       switch (ve->nr_components) {
+       switch (nr_components) {
        case 4:
                so_method(so, tesla, NV50TCL_VTX_ATTR_4F_X(attrib), 4);
                so_data  (so, fui(v[0]));
@@ -1019,7 +1023,7 @@ emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit,
        for (i = 0; i < nv50->vtxelt_nr; ++i) {
                struct pipe_vertex_element *ve;
                struct pipe_vertex_buffer *vb;
-               unsigned n, size;
+               unsigned n, size, nr_components;
                const struct util_format_description *desc;
 
                ve = &nv50->vtxelt[i];
@@ -1038,8 +1042,9 @@ emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit,
 
                size = util_format_get_component_bits(
                        ve->src_format, UTIL_FORMAT_COLORSPACE_RGB, 0);
+               nr_components = util_format_get_nr_components(ve->src_format);
 
-               assert(ve->nr_components > 0 && ve->nr_components <= 4);
+               assert(nr_components > 0 && nr_components <= 4);
 
                /* It shouldn't be necessary to push the implicit 1s
                 * for case 3 and size 8 cases 1, 2, 3.
@@ -1049,25 +1054,25 @@ emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit,
                        NOUVEAU_ERR("unsupported vtxelt size: %u\n", size);
                        return FALSE;
                case 32:
-                       switch (ve->nr_components) {
+                       switch (nr_components) {
                        case 1: emit->push[n] = emit_b32_1; break;
                        case 2: emit->push[n] = emit_b32_2; break;
                        case 3: emit->push[n] = emit_b32_3; break;
                        case 4: emit->push[n] = emit_b32_4; break;
                        }
-                       emit->vtx_dwords += ve->nr_components;
+                       emit->vtx_dwords += nr_components;
                        break;
                case 16:
-                       switch (ve->nr_components) {
+                       switch (nr_components) {
                        case 1: emit->push[n] = emit_b16_1; break;
                        case 2: emit->push[n] = emit_b32_1; break;
                        case 3: emit->push[n] = emit_b16_3; break;
                        case 4: emit->push[n] = emit_b32_2; break;
                        }
-                       emit->vtx_dwords += (ve->nr_components + 1) >> 1;
+                       emit->vtx_dwords += (nr_components + 1) >> 1;
                        break;
                case 8:
-                       switch (ve->nr_components) {
+                       switch (nr_components) {
                        case 1: emit->push[n] = emit_b08_1; break;
                        case 2: emit->push[n] = emit_b16_1; break;
                        case 3: emit->push[n] = emit_b08_3; break;
index 6da186a655523b73f730a2816848ca3d60446765..b9ccc0ca6945566b92a3f0c7add4c73e6bf791cf 100644 (file)
@@ -480,7 +480,6 @@ void trace_dump_vertex_element(const struct pipe_vertex_element *state)
    trace_dump_member(uint, state, src_offset);
 
    trace_dump_member(uint, state, vertex_buffer_index);
-   trace_dump_member(uint, state, nr_components);
 
    trace_dump_member(format, state, src_format);
 
index 5ac5c878135db10ae652438c1c5576cc6e626251..5670f7a0887d7b935b96125e5c2804b66ed056bd 100644 (file)
@@ -383,7 +383,6 @@ struct pipe_vertex_element
     * this attribute live in?
     */
    unsigned vertex_buffer_index:8;
-   unsigned nr_components:8;
  
    enum pipe_format src_format;           /**< PIPE_FORMAT_* */
 };
index c06dbf52069be78348a35eef7c6e794bee5dd524..96fbbfc85a1858975f28d1ee1cde8614f50177ea 100644 (file)
@@ -296,7 +296,6 @@ static void draw_polygon(struct vg_context *ctx,
    velement.instance_divisor = 0;
    velement.vertex_buffer_index = 0;
    velement.src_format = PIPE_FORMAT_R32G32_FLOAT;
-   velement.nr_components = COMPONENTS;
    pipe->set_vertex_elements(pipe, 1, &velement);
 
    /* draw */
index 4b48c168e9cc037d484f76594ff14d5e13d16840..397dddbb476d26b09a431a37a988ff8c89412e16 100644 (file)
@@ -368,7 +368,6 @@ setup_interleaved_attribs(GLcontext *ctx,
          (unsigned) (arrays[mesaAttr]->Ptr - offset0);
       velements[attr].instance_divisor = 0;
       velements[attr].vertex_buffer_index = 0;
-      velements[attr].nr_components = arrays[mesaAttr]->Size;
       velements[attr].src_format =
          st_pipe_vertex_format(arrays[mesaAttr]->Type,
                                arrays[mesaAttr]->Size,
@@ -458,7 +457,6 @@ setup_non_interleaved_attribs(GLcontext *ctx,
       vbuffer[attr].max_index = max_index;
       velements[attr].instance_divisor = 0;
       velements[attr].vertex_buffer_index = attr;
-      velements[attr].nr_components = arrays[mesaAttr]->Size;
       velements[attr].src_format
          = st_pipe_vertex_format(arrays[mesaAttr]->Type,
                                  arrays[mesaAttr]->Size,
@@ -596,7 +594,6 @@ st_draw_vbo(GLcontext *ctx,
       for (i = 0; i < num_velements; i++) {
          printf("vlements[%d].vbuffer_index = %u\n", i, velements[i].vertex_buffer_index);
          printf("vlements[%d].src_offset = %u\n", i, velements[i].src_offset);
-         printf("vlements[%d].nr_comps = %u\n", i, velements[i].nr_components);
          printf("vlements[%d].format = %s\n", i, util_format_name(velements[i].src_format));
       }
    }
index 087f2f22bbf70da581bf688a299bae4eae1b412a..26a5b3fcd637d102e566379add00ca18216729db 100644 (file)
@@ -178,7 +178,6 @@ st_feedback_draw_vbo(GLcontext *ctx,
       vbuffers[attr].max_index = max_index;
       velements[attr].instance_divisor = 0;
       velements[attr].vertex_buffer_index = attr;
-      velements[attr].nr_components = arrays[mesaAttr]->Size;
       velements[attr].src_format = 
          st_pipe_vertex_format(arrays[mesaAttr]->Type,
                                arrays[mesaAttr]->Size,