diff options
author | Brian <[email protected]> | 2007-07-13 12:28:42 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-07-13 12:28:42 -0600 |
commit | 2bf4a500de24347476ce96cdd48d68ddeecbb019 (patch) | |
tree | a07b8cb70259037f5027e94d628bfaa19abe504d /src/mesa/pipe/draw | |
parent | 5810b40d6e9aae6b184879a99c67f83107fc6637 (diff) |
Fix for-loop in interp() so we don't go out of bounds.
Improved comments for that loop.
Added some sanity check assertions regarding vertex layout.
Diffstat (limited to 'src/mesa/pipe/draw')
-rw-r--r-- | src/mesa/pipe/draw/draw_clip.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c index 7ede51fc6cd..b220cc3643f 100644 --- a/src/mesa/pipe/draw/draw_clip.c +++ b/src/mesa/pipe/draw/draw_clip.c @@ -110,13 +110,15 @@ static void interp( const struct clipper *clip, dst->data[0][3] = oow; } - /* Other attributes - * Note: start at 1 to skip winpos (data[0]) and subtract one - * since there's two vertex attrib slots we want to ignore (the header - * and the clippos. + * 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-1; j++) { + for (j = 1; j < nr_attrs - 2; j++) { interp_attr(dst->data[j], t, in->data[j], out->data[j]); } } @@ -365,6 +367,11 @@ static void clip_begin( struct draw_stage *stage ) struct clipper *clipper = clipper_stage(stage); GLuint nr = stage->draw->nr_planes; + /* sanity checks. If these fail, review the clip/interp code! */ + assert(stage->draw->nr_attrs >= 3); + assert(stage->draw->attrs[0].attrib == VF_ATTRIB_VERTEX_HEADER); + assert(stage->draw->attrs[1].attrib == VF_ATTRIB_CLIP_POS); + /* Hacky bitmask to use when we hit CLIP_USER_BIT: */ clipper->active_user_planes = ((1<<nr)-1) & ~((1<<6)-1); |