struct gallivm_prog;
struct gallivm_cpu_engine;
+
/**
* Basic vertex info.
* Carry some useful information around with the vertices in the prim pipe.
float data[][4]; /* Note variable size */
};
+/* NOTE: It should match vertex_id size above */
+#define UNDEFINED_VERTEX_ID 0xffff
+
/* XXX This is too large */
#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
{
struct vertex_header *tmp = stage->tmp[idx];
memcpy(tmp, vert, stage->draw->vertex_info.size * sizeof(float) );
- tmp->vertex_id = ~0;
+ tmp->vertex_id = UNDEFINED_VERTEX_ID;
return tmp;
}
draw->vcache.vertex[slot]->clipmask = 0;
draw->vcache.vertex[slot]->edgeflag = 1; /*XXX use user's edge flag! */
draw->vcache.vertex[slot]->pad = 0;
- draw->vcache.vertex[slot]->vertex_id = ~0;
+ draw->vcache.vertex[slot]->vertex_id = UNDEFINED_VERTEX_ID;
}
unsigned i;
for (i = 0; i < Elements(draw->vcache.vertex); i++)
- draw->vcache.vertex[i]->vertex_id = ~0;
+ draw->vcache.vertex[i]->vertex_id = UNDEFINED_VERTEX_ID;
}
}
-static inline
-boolean overflow( void *map, void *ptr, unsigned bytes, unsigned bufsz )
+static INLINE boolean
+overflow( void *map, void *ptr, unsigned bytes, unsigned bufsz )
{
unsigned long used = (char *)ptr - (char *)map;
return (used + bytes) > bufsz;
}
-static void check_space( struct vbuf_stage *vbuf )
+static INLINE void
+check_space( struct vbuf_stage *vbuf )
{
if (overflow( vbuf->vertex_map,
vbuf->vertex_ptr,
* have a couple of slots at the beginning (1-dword header, 4-dword
* clip pos) that we ignore here.
*/
-static inline void
+static INLINE void
emit_vertex( struct vbuf_stage *vbuf,
struct vertex_header *vertex )
{
// fprintf(stderr, "emit vertex %d to %p\n",
// vbuf->nr_vertices, vbuf->vertex_ptr);
+ if(vertex->vertex_id != UNDEFINED_VERTEX_ID) {
+ if(vertex->vertex_id < vbuf->nr_vertices)
+ return;
+ else
+ fprintf(stderr, "Bad vertex id 0x%04x (>= 0x%04x)\n",
+ vertex->vertex_id, vbuf->nr_vertices);
+ return;
+ }
+
vertex->vertex_id = vbuf->nr_vertices++;
for (i = 0; i < vinfo->num_attribs; i++) {
check_space( vbuf );
for (i = 0; i < 3; i++) {
- if (prim->v[i]->vertex_id == 0xffff)
- emit_vertex( vbuf, prim->v[i] );
+ emit_vertex( vbuf, prim->v[i] );
vbuf->element_map[vbuf->nr_elements++] = prim->v[i]->vertex_id;
}
check_space( vbuf );
for (i = 0; i < 2; i++) {
- if (prim->v[i]->vertex_id == 0xffff)
- emit_vertex( vbuf, prim->v[i] );
+ emit_vertex( vbuf, prim->v[i] );
vbuf->element_map[vbuf->nr_elements++] = prim->v[i]->vertex_id;
}
check_space( vbuf );
- if (prim->v[0]->vertex_id == 0xffff)
- emit_vertex( vbuf, prim->v[0] );
+ emit_vertex( vbuf, prim->v[0] );
vbuf->element_map[vbuf->nr_elements++] = prim->v[0]->vertex_id;
}
vbuf_flush_elements( stage );
for (i = 0; i < 3; i++) {
- if (prim->v[i]->vertex_id == 0xffff)
+ if (prim->v[i]->vertex_id == UNDEFINED_VERTEX_ID)
emit_vertex( vbuf, prim->v[i] );
vbuf->element_map[vbuf->nr_elements++] = (ushort) prim->v[i]->vertex_id;
vbuf_flush_elements( stage );
for (i = 0; i < 2; i++) {
- if (prim->v[i]->vertex_id == 0xffff)
+ if (prim->v[i]->vertex_id == UNDEFINED_VERTEX_ID)
emit_vertex( vbuf, prim->v[i] );
vbuf->element_map[vbuf->nr_elements++] = (ushort) prim->v[i]->vertex_id;
if (!check_space( vbuf ))
vbuf_flush_elements( stage );
- if (prim->v[0]->vertex_id == 0xffff)
+ if (prim->v[0]->vertex_id == UNDEFINED_VERTEX_ID)
emit_vertex( vbuf, prim->v[0] );
vbuf->element_map[vbuf->nr_elements++] = (ushort) prim->v[0]->vertex_id;