diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2003-10-22 22:59:07 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2003-10-22 22:59:07 +0000 |
commit | c5b1e81de48de5d8830bf5d92ff767ad1985e46e (patch) | |
tree | 169c3c09cdc4e69badfb46540db39439bc2d0ef4 /src/mesa/tnl | |
parent | 15c37348a5d47ece17ffef38978aa8253363e6ee (diff) |
Initial work for bounds checking of vertex arrays and vertex buffer objects.
Only glDrawArrays() done so far.
Simplified glVertex/Color/etcPointer functions.
Misc casts added here and there.
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r-- | src/mesa/tnl/t_array_api.c | 11 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 14 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_elt.c | 8 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_eval.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_light.c | 10 |
5 files changed, 28 insertions, 21 deletions
diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index 85fada8c28..4f6cb7ef14 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -268,7 +268,11 @@ _tnl_DrawRangeElements(GLenum mode, if (ctx->Array.ElementArrayBufferObj->Name) { /* use indices in the buffer object */ - ASSERT(ctx->Array.ElementArrayBufferObj->Data); + if (!ctx->Array.ElementArrayBufferObj->Data) { + _mesa_warning(ctx, + "DrawRangeElements with empty vertex elements buffer!"); + return; + } indices = (GLuint *) ctx->Array.ElementArrayBufferObj->Data; } @@ -341,7 +345,10 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, if (ctx->Array.ElementArrayBufferObj->Name) { /* use indices in the buffer object */ - ASSERT(ctx->Array.ElementArrayBufferObj->Data); + if (!ctx->Array.ElementArrayBufferObj->Data) { + _mesa_warning(ctx, "DrawElements with empty vertex elements buffer!"); + return; + } indices = (const GLvoid *) ctx->Array.ElementArrayBufferObj->Data; } diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 0a8197c10a..a888894f74 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -47,7 +47,7 @@ static void _tnl_import_vertex( GLcontext *ctx, struct gl_client_array *tmp; GLboolean is_writeable = 0; struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - GLubyte *data; + const GLubyte *data; tmp = _ac_import_vertex(ctx, GL_FLOAT, @@ -80,7 +80,7 @@ static void _tnl_import_normal( GLcontext *ctx, struct gl_client_array *tmp; GLboolean is_writeable = 0; struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - GLubyte *data; + const GLubyte *data; tmp = _ac_import_normal(ctx, GL_FLOAT, stride ? 3*sizeof(GLfloat) : 0, writeable, @@ -148,7 +148,7 @@ static void _tnl_import_fogcoord( GLcontext *ctx, struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; - GLubyte *data; + const GLubyte *data; tmp = _ac_import_fogcoord(ctx, GL_FLOAT, stride ? sizeof(GLfloat) : 0, writeable, @@ -176,7 +176,7 @@ static void _tnl_import_index( GLcontext *ctx, struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; - GLubyte *data; + const GLubyte *data; tmp = _ac_import_index(ctx, GL_UNSIGNED_INT, stride ? sizeof(GLuint) : 0, writeable, @@ -206,7 +206,7 @@ static void _tnl_import_texcoord( GLcontext *ctx, struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; - GLubyte *data; + const GLubyte *data; tmp = _ac_import_texcoord(ctx, unit, GL_FLOAT, stride ? 4 * sizeof(GLfloat) : 0, @@ -238,7 +238,7 @@ static void _tnl_import_edgeflag( GLcontext *ctx, struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; - GLubyte *data; + const GLubyte *data; tmp = _ac_import_edgeflag(ctx, GL_UNSIGNED_BYTE, stride ? sizeof(GLubyte) : 0, @@ -270,7 +270,7 @@ static void _tnl_import_attrib( GLcontext *ctx, struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; struct gl_client_array *tmp; GLboolean is_writeable = 0; - GLubyte *data; + const GLubyte *data; tmp = _ac_import_attrib(ctx, index, GL_FLOAT, stride ? 4 * sizeof(GLfloat) : 0, diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c index 9157ca4871..50f97a3f20 100644 --- a/src/mesa/tnl/t_imm_elt.c +++ b/src/mesa/tnl/t_imm_elt.c @@ -516,7 +516,7 @@ static void _tnl_trans_elt_1ui(GLuint *to, GLuint start, GLuint n ) { - GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); + const GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); _tnl_trans_elt_1ui_tab[TYPE_IDX(from->Type)]( to, fromData, from->StrideB, @@ -537,7 +537,7 @@ static void _tnl_trans_elt_1ub(GLubyte *to, GLuint start, GLuint n ) { - GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); + const GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); _tnl_trans_elt_1ub_tab[TYPE_IDX(from->Type)]( to, fromData, from->StrideB, @@ -557,7 +557,7 @@ static void _tnl_trans_elt_4f(GLfloat (*to)[4], GLuint start, GLuint n ) { - GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); + const GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); _tnl_trans_elt_4f_tab[from->Size][TYPE_IDX(from->Type)]( to, fromData, from->StrideB, @@ -578,7 +578,7 @@ static void _tnl_trans_elt_4fc(GLfloat (*to)[4], GLuint start, GLuint n ) { - GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); + const GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data ); _tnl_trans_elt_4fc_tab[from->Size][TYPE_IDX(from->Type)]( to, fromData, from->StrideB, diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c index 69bbbffce8..f72ada7835 100644 --- a/src/mesa/tnl/t_imm_eval.c +++ b/src/mesa/tnl/t_imm_eval.c @@ -119,7 +119,7 @@ static void eval1_4f_ca( struct gl_client_array *dest, { const GLfloat u1 = map->u1; const GLfloat du = map->du; - GLubyte *destData = ADD_POINTERS(dest->Ptr, dest->BufferObj->Data); + const GLubyte *destData = ADD_POINTERS(dest->Ptr, dest->BufferObj->Data); GLfloat (*to)[4] = (GLfloat (*)[4]) destData; GLuint i; @@ -258,7 +258,7 @@ static void eval2_4f_ca( struct gl_client_array *dest, const GLfloat du = map->du; const GLfloat v1 = map->v1; const GLfloat dv = map->dv; - GLubyte *destData = ADD_POINTERS(dest->Ptr, dest->BufferObj->Data); + const GLubyte *destData = ADD_POINTERS(dest->Ptr, dest->BufferObj->Data); GLfloat (*to)[4] = (GLfloat (*)[4]) destData; GLuint i; @@ -542,7 +542,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) GLuint generated = 0; if (copycount) { - GLubyte *destData = ADD_POINTERS(tmp->Color.Ptr, tmp->Color.BufferObj->Data); + const GLubyte *destData = ADD_POINTERS(tmp->Color.Ptr, tmp->Color.BufferObj->Data); copy_4f_stride( store->Attrib[VERT_ATTRIB_COLOR0] + IM->CopyStart, (GLfloat *) destData, tmp->Color.StrideB, diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index ccbcba1f2a..3252df9b30 100644 --- a/src/mesa/tnl/t_vb_light.c +++ b/src/mesa/tnl/t_vb_light.c @@ -323,13 +323,13 @@ static void dtr( struct gl_pipeline_stage *stage ) struct light_stage_data *store = LIGHT_STAGE_DATA(stage); if (store) { - ALIGN_FREE( store->LitColor[0].Ptr ); - ALIGN_FREE( store->LitColor[1].Ptr ); - ALIGN_FREE( store->LitSecondary[0].Ptr ); - ALIGN_FREE( store->LitSecondary[1].Ptr ); + ALIGN_FREE( (void *) store->LitColor[0].Ptr ); + ALIGN_FREE( (void *) store->LitColor[1].Ptr ); + ALIGN_FREE( (void *) store->LitSecondary[0].Ptr ); + ALIGN_FREE( (void *) store->LitSecondary[1].Ptr ); if (store->FloatColor.Ptr) - ALIGN_FREE( store->FloatColor.Ptr ); + ALIGN_FREE( (void *) store->FloatColor.Ptr ); _mesa_vector1ui_free( &store->LitIndex[0] ); _mesa_vector1ui_free( &store->LitIndex[1] ); |