diff options
author | Brian <brian.paul@tungstengraphics.com> | 2008-01-21 11:16:22 -0700 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2008-01-21 11:16:22 -0700 |
commit | 382b86e90f69fa0493fae3c7e5c9cd482984af8f (patch) | |
tree | 6fc58cd23789615754c828eb509be395ed76a045 /src/mesa/pipe/draw | |
parent | f4b89be70111793a6b5eb511e1c92be72bb6b3d9 (diff) |
gallium: add a src_index[] array to draw's vertex_info for mapping post-xform vertex attribs to hw vertex attribs
Diffstat (limited to 'src/mesa/pipe/draw')
-rw-r--r-- | src/mesa/pipe/draw/draw_vbuf.c | 29 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vertex.h | 7 |
2 files changed, 21 insertions, 15 deletions
diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c index 6cda122c3a..7683e3381c 100644 --- a/src/mesa/pipe/draw/draw_vbuf.c +++ b/src/mesa/pipe/draw/draw_vbuf.c @@ -139,37 +139,38 @@ emit_vertex( struct vbuf_stage *vbuf, vertex->vertex_id = vbuf->nr_vertices++; for (i = 0; i < vinfo->num_attribs; i++) { + uint j = vinfo->src_index[i]; switch (vinfo->format[i]) { case FORMAT_OMIT: /* no-op */ break; case FORMAT_1F: - *vbuf->vertex_ptr++ = fui(vertex->data[i][0]); + *vbuf->vertex_ptr++ = fui(vertex->data[j][0]); count++; break; case FORMAT_2F: - *vbuf->vertex_ptr++ = fui(vertex->data[i][0]); - *vbuf->vertex_ptr++ = fui(vertex->data[i][1]); + *vbuf->vertex_ptr++ = fui(vertex->data[j][0]); + *vbuf->vertex_ptr++ = fui(vertex->data[j][1]); count += 2; break; case FORMAT_3F: - *vbuf->vertex_ptr++ = fui(vertex->data[i][0]); - *vbuf->vertex_ptr++ = fui(vertex->data[i][1]); - *vbuf->vertex_ptr++ = fui(vertex->data[i][2]); + *vbuf->vertex_ptr++ = fui(vertex->data[j][0]); + *vbuf->vertex_ptr++ = fui(vertex->data[j][1]); + *vbuf->vertex_ptr++ = fui(vertex->data[j][2]); count += 3; break; case FORMAT_4F: - *vbuf->vertex_ptr++ = fui(vertex->data[i][0]); - *vbuf->vertex_ptr++ = fui(vertex->data[i][1]); - *vbuf->vertex_ptr++ = fui(vertex->data[i][2]); - *vbuf->vertex_ptr++ = fui(vertex->data[i][3]); + *vbuf->vertex_ptr++ = fui(vertex->data[j][0]); + *vbuf->vertex_ptr++ = fui(vertex->data[j][1]); + *vbuf->vertex_ptr++ = fui(vertex->data[j][2]); + *vbuf->vertex_ptr++ = fui(vertex->data[j][3]); count += 4; break; case FORMAT_4UB: - *vbuf->vertex_ptr++ = pack_ub4(float_to_ubyte( vertex->data[i][2] ), - float_to_ubyte( vertex->data[i][1] ), - float_to_ubyte( vertex->data[i][0] ), - float_to_ubyte( vertex->data[i][3] )); + *vbuf->vertex_ptr++ = pack_ub4(float_to_ubyte( vertex->data[j][2] ), + float_to_ubyte( vertex->data[j][1] ), + float_to_ubyte( vertex->data[j][0] ), + float_to_ubyte( vertex->data[j][3] )); count += 1; break; default: diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h index 8bb328affa..ab0425e106 100644 --- a/src/mesa/pipe/draw/draw_vertex.h +++ b/src/mesa/pipe/draw/draw_vertex.h @@ -70,6 +70,7 @@ struct vertex_info uint hwfmt[4]; /**< hardware format info for this format */ enum interp_mode interp_mode[PIPE_MAX_SHADER_OUTPUTS]; enum attrib_format format[PIPE_MAX_SHADER_OUTPUTS]; /**< FORMAT_x */ + uint src_index[PIPE_MAX_SHADER_OUTPUTS]; uint size; /**< total vertex size in dwords */ }; @@ -77,16 +78,20 @@ struct vertex_info /** * Add another attribute to the given vertex_info object. + * \param src_index indicates which post-transformed vertex attrib slot + * corresponds to this attribute. * \return slot in which the attribute was added */ static INLINE uint draw_emit_vertex_attr(struct vertex_info *vinfo, - enum attrib_format format, enum interp_mode interp) + enum attrib_format format, enum interp_mode interp, + uint src_index) { const uint n = vinfo->num_attribs; assert(n < PIPE_MAX_SHADER_OUTPUTS); vinfo->format[n] = format; vinfo->interp_mode[n] = interp; + vinfo->src_index[n] = src_index; vinfo->num_attribs++; return n; } |