summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/pipe/draw/draw_clip.c2
-rw-r--r--src/mesa/pipe/draw/draw_private.h6
-rw-r--r--src/mesa/pipe/draw/draw_vertex_cache.c4
-rw-r--r--src/mesa/pipe/i915simple/i915_prim_vbuf.c27
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_vbuf.c6
5 files changed, 28 insertions, 17 deletions
diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c
index 222022d6c1..bc62d422a4 100644
--- a/src/mesa/pipe/draw/draw_clip.c
+++ b/src/mesa/pipe/draw/draw_clip.c
@@ -102,7 +102,7 @@ static void interp( const struct clipper *clip,
dst->clipmask = 0;
dst->edgeflag = 0;
dst->pad = 0;
- dst->vertex_id = 0;
+ dst->vertex_id = UNDEFINED_VERTEX_ID;
}
/* Clip coordinates: interpolate normally
diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h
index f52ff0bd44..bdc3a6b9e7 100644
--- a/src/mesa/pipe/draw/draw_private.h
+++ b/src/mesa/pipe/draw/draw_private.h
@@ -52,6 +52,7 @@
struct gallivm_prog;
struct gallivm_cpu_engine;
+
/**
* Basic vertex info.
* Carry some useful information around with the vertices in the prim pipe.
@@ -67,6 +68,9 @@ struct vertex_header {
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))
@@ -299,7 +303,7 @@ dup_vert( struct draw_stage *stage,
{
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;
}
diff --git a/src/mesa/pipe/draw/draw_vertex_cache.c b/src/mesa/pipe/draw/draw_vertex_cache.c
index 511f371ac8..6689907ddf 100644
--- a/src/mesa/pipe/draw/draw_vertex_cache.c
+++ b/src/mesa/pipe/draw/draw_vertex_cache.c
@@ -88,7 +88,7 @@ static struct vertex_header *get_vertex( struct draw_context *draw,
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;
}
@@ -130,7 +130,7 @@ void draw_vertex_cache_reset_vertex_ids( struct draw_context *draw )
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;
}
diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
index c33cc2198c..8881d16c88 100644
--- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c
+++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
@@ -98,15 +98,16 @@ static INLINE struct vbuf_stage *vbuf_stage( struct draw_stage *stage )
}
-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,
@@ -125,7 +126,7 @@ static void check_space( struct vbuf_stage *vbuf )
* 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 )
{
@@ -137,6 +138,15 @@ emit_vertex( struct vbuf_stage *vbuf,
// 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++) {
@@ -190,8 +200,7 @@ static void vbuf_tri( struct draw_stage *stage,
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;
}
@@ -207,8 +216,7 @@ static void vbuf_line(struct draw_stage *stage,
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;
}
@@ -222,8 +230,7 @@ static void vbuf_point(struct draw_stage *stage,
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;
}
diff --git a/src/mesa/pipe/softpipe/sp_prim_vbuf.c b/src/mesa/pipe/softpipe/sp_prim_vbuf.c
index ddf662eead..7cb3da6feb 100644
--- a/src/mesa/pipe/softpipe/sp_prim_vbuf.c
+++ b/src/mesa/pipe/softpipe/sp_prim_vbuf.c
@@ -140,7 +140,7 @@ static void vbuf_tri( struct draw_stage *stage,
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;
@@ -158,7 +158,7 @@ static void vbuf_line(struct draw_stage *stage,
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;
@@ -174,7 +174,7 @@ static void vbuf_point(struct draw_stage *stage,
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;