Simplify draw module's vertex_info.

No longer store the vertex header and clip pos info in the draw module's
vertex_info.  The vertex_info just describes the data[] elements.
This simplifies the code in several places.
This commit is contained in:
Brian 2007-11-21 15:40:20 -07:00
parent 5a6017d496
commit fbe68bf6b2
6 changed files with 21 additions and 35 deletions

View file

@ -128,12 +128,8 @@ static void interp( const struct clipper *clip,
/* Other attributes
* Note: start at 1 to skip winpos (data[0]) since we just computed
* it above.
* Subtract two from nr_attrs since the first two attribs (always
* VF_ATTRIB_VERTEX_HEADER and VF_ATTRIB_CLIP_POS, see
* draw_set_vertex_attributes()) are in the vertex_header struct,
* not in the data[] array.
*/
for (j = 1; j < nr_attrs - 2; j++) {
for (j = 1; j < nr_attrs; j++) {
interp_attr(dst->data[j], t, in->data[j], out->data[j]);
}
}
@ -352,12 +348,8 @@ do_clip_line( struct draw_stage *stage,
static void clip_begin( struct draw_stage *stage )
{
/* sanity checks. If these fail, review the clip/interp code! */
assert(stage->draw->vertex_info.num_attribs >= 3);
#if 0
assert(stage->draw->vertex_info.slot_to_attrib[0] == TGSI_ATTRIB_VERTEX_HEADER);
assert(stage->draw->vertex_info.slot_to_attrib[1] == TGSI_ATTRIB_CLIP_POS);
#endif
/* should always have position, at least */
assert(stage->draw->vertex_info.num_attribs >= 1);
stage->next->begin( stage->next );
}

View file

@ -60,8 +60,9 @@ static INLINE void copy_colors( struct draw_stage *stage,
uint i;
/* Look for constant/flat attribs and duplicate from src to dst vertex */
for (i = 1; i < num_attribs - 2; i++) {
if (interp[i + 2] == INTERP_CONSTANT) {
/* skip attrib[0] which is vert pos */
for (i = 1; i < num_attribs; i++) {
if (interp[i] == INTERP_CONSTANT) {
copy_attr( i, dst, src );
}
}

View file

@ -75,7 +75,6 @@ draw_compute_vertex_size(struct vertex_info *vinfo)
vinfo->size += 3;
break;
case FORMAT_4F:
case FORMAT_4F_VIEWPORT:
vinfo->size += 4;
break;
default:
@ -99,27 +98,26 @@ draw_set_vertex_attributes( struct draw_context *draw,
struct vertex_info *vinfo = &draw->vertex_info;
unsigned i;
#if 0
assert(slot_to_vf_attr[0] == TGSI_ATTRIB_POS);
#endif
assert(interps[0] == INTERP_LINEAR); /* should be vert pos */
assert(nr_attrs <= PIPE_MAX_SHADER_OUTPUTS);
/* Note that draw-module vertices will consist of the attributes passed
* to this function, plus a header/prefix containing the vertex header
* flags and GLfloat[4] clip pos.
*/
memset(vinfo, 0, sizeof(*vinfo));
/*
* First three attribs are always the same: header, clip pos, winpos
*/
emit_vertex_attr(vinfo, FORMAT_1F, INTERP_NONE);
emit_vertex_attr(vinfo, FORMAT_4F, INTERP_LINEAR);
emit_vertex_attr(vinfo, FORMAT_4F_VIEWPORT, INTERP_LINEAR);
/*
* Remaining attribs (color, texcoords, etc)
*/
for (i = 1; i < nr_attrs; i++) {
/* copy attrib info */
for (i = 0; i < nr_attrs; i++) {
emit_vertex_attr(vinfo, FORMAT_4F, interps[i]);
}
draw_compute_vertex_size(vinfo);
/* add extra words for vertex header (uint), clip pos (float[4]) */
vinfo->size += 5;
}

View file

@ -46,7 +46,6 @@ enum attrib_format {
FORMAT_2F,
FORMAT_3F,
FORMAT_4F,
FORMAT_4F_VIEWPORT,
FORMAT_4UB
};

View file

@ -158,10 +158,8 @@ run_vertex_program(struct draw_context *draw,
#endif
/* Remaining attributes are packed into sequential post-transform
* vertex attrib slots.
* Skip 0 since we just did it above.
* Subtract two because of the VERTEX_HEADER, CLIP_POS attribs.
*/
for (slot = 1; slot < draw->vertex_info.num_attribs - 2; slot++) {
for (slot = 1; slot < draw->vertex_info.num_attribs; slot++) {
vOut[j]->data[slot][0] = machine->Outputs[slot].xyzw[0].f[j];
vOut[j]->data[slot][1] = machine->Outputs[slot].xyzw[1].f[j];
vOut[j]->data[slot][2] = machine->Outputs[slot].xyzw[2].f[j];

View file

@ -173,10 +173,8 @@ void draw_vertex_shader_queue_flush_llvm(struct draw_context *draw)
/* Remaining attributes are packed into sequential post-transform
* vertex attrib slots.
* Skip 0 since we just did it above.
* Subtract two because of the VERTEX_HEADER, CLIP_POS attribs.
*/
for (slot = 1; slot < draw->vertex_info.num_attribs - 2; slot++) {
for (slot = 1; slot < draw->vertex_info.num_attribs; slot++) {
vOut->data[slot][0] = dests[slot][0];
vOut->data[slot][1] = dests[slot][1];
vOut->data[slot][2] = dests[slot][2];