From 4d36f334c9b3ab6b4e6901802e64ee7391a422ef Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 21 Jan 2004 15:31:46 +0000 Subject: [PATCH] Another mechanism to create vertices with holes - a new EMIT_PAD style --- src/mesa/tnl/t_vertex.c | 50 +++++++++++++++++++++++++++-------------- src/mesa/tnl/t_vertex.h | 1 + 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index 3729e1cc7d7..dc9ea6184c6 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -657,7 +657,12 @@ struct { extract_4chan_4f_rgba, { insert_4chan_4f_rgba_1, insert_4chan_4f_rgba_2, insert_4chan_4f_rgba_3, insert_4chan_4f_rgba_4 }, - 4 * sizeof(GLchan) } + 4 * sizeof(GLchan) }, + + { "pad", + 0, + { 0, 0, 0, 0 }, + 0 } }; @@ -958,36 +963,47 @@ GLuint _tnl_install_attrs( GLcontext *ctx, const struct tnl_attr_map *map, { struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); int offset = 0; - GLuint i; + GLuint i, j; assert(nr < _TNL_ATTRIB_MAX); assert(nr == 0 || map[0].attrib == VERT_ATTRIB_POS); - vtx->attr_count = nr; vtx->emit = choose_emit_func; vtx->interp = choose_interp_func; vtx->copy_pv = choose_copy_pv_func; vtx->new_inputs = ~0; - for (i = 0; i < nr; i++) { + for (j = 0, i = 0; i < nr; i++) { GLuint format = map[i].format; - vtx->attr[i].attrib = map[i].attrib; - vtx->attr[i].vp = vp; - vtx->attr[i].insert = format_info[format].insert; - vtx->attr[i].extract = format_info[format].extract; - vtx->attr[i].vertattrsize = format_info[format].attrsize; + if (format == EMIT_PAD) { + offset += map[i].offset; - if (unpacked_size) - vtx->attr[i].vertoffset = map[i].offset; - else - vtx->attr[i].vertoffset = offset; +/* fprintf(stderr, "%d: pad %d, offset now %d\n", i, */ +/* map[i].offset, offset); */ -/* fprintf(stderr, "%d: %s offset %d\n", i, */ -/* format_info[format].name, vtx->attr[i].vertoffset); */ - - offset += format_info[format].attrsize; + } + else { + vtx->attr[j].attrib = map[i].attrib; + vtx->attr[j].vp = vp; + vtx->attr[j].insert = format_info[format].insert; + vtx->attr[j].extract = format_info[format].extract; + vtx->attr[j].vertattrsize = format_info[format].attrsize; + + if (unpacked_size) + vtx->attr[j].vertoffset = map[i].offset; + else + vtx->attr[j].vertoffset = offset; + +/* fprintf(stderr, "%d: %s offset %d\n", i, */ +/* format_info[format].name, vtx->attr[j].vertoffset); */ + + offset += format_info[format].attrsize; + j++; + } } + vtx->attr_count = j; + if (unpacked_size) vtx->vertex_size = unpacked_size; else diff --git a/src/mesa/tnl/t_vertex.h b/src/mesa/tnl/t_vertex.h index 297b6a4cbe9..6c58ca994b3 100644 --- a/src/mesa/tnl/t_vertex.h +++ b/src/mesa/tnl/t_vertex.h @@ -51,6 +51,7 @@ enum tnl_attr_format { EMIT_4UB_4F_BGRA, /* for color */ EMIT_4UB_4F_RGBA, /* for color */ EMIT_4CHAN_4F_RGBA, /* for swrast color */ + EMIT_PAD, /* leave a hole of 'offset' bytes */ EMIT_MAX }; -- 2.30.2