summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-10-22 22:59:07 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-10-22 22:59:07 +0000
commitc5b1e81de48de5d8830bf5d92ff767ad1985e46e (patch)
tree169c3c09cdc4e69badfb46540db39439bc2d0ef4
parent15c37348a5d47ece17ffef38978aa8253363e6ee (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.
-rw-r--r--src/mesa/array_cache/ac_context.c18
-rw-r--r--src/mesa/main/api_validate.c85
-rw-r--r--src/mesa/main/arbprogram.c2
-rw-r--r--src/mesa/main/get.c16
-rw-r--r--src/mesa/main/mtypes.h6
-rw-r--r--src/mesa/main/nvprogram.c2
-rw-r--r--src/mesa/main/varray.c315
-rw-r--r--src/mesa/swrast_setup/ss_context.c4
-rw-r--r--src/mesa/tnl/t_array_api.c11
-rw-r--r--src/mesa/tnl/t_array_import.c14
-rw-r--r--src/mesa/tnl/t_imm_elt.c8
-rw-r--r--src/mesa/tnl/t_imm_eval.c6
-rw-r--r--src/mesa/tnl/t_vb_light.c10
13 files changed, 268 insertions, 229 deletions
diff --git a/src/mesa/array_cache/ac_context.c b/src/mesa/array_cache/ac_context.c
index e22f771b67..35d341d64e 100644
--- a/src/mesa/array_cache/ac_context.c
+++ b/src/mesa/array_cache/ac_context.c
@@ -336,28 +336,28 @@ void _ac_DestroyContext( GLcontext *ctx )
* not an offset into a buffer object.
*/
if (ac->Cache.Vertex.Ptr && ac->Cache.Vertex.BufferObj == nullObj)
- FREE( ac->Cache.Vertex.Ptr );
+ FREE( (void *) ac->Cache.Vertex.Ptr );
if (ac->Cache.Normal.Ptr && ac->Cache.Normal.BufferObj == nullObj)
- FREE( ac->Cache.Normal.Ptr );
+ FREE( (void *) ac->Cache.Normal.Ptr );
if (ac->Cache.Color.Ptr && ac->Cache.Color.BufferObj == nullObj)
- FREE( ac->Cache.Color.Ptr );
+ FREE( (void *) ac->Cache.Color.Ptr );
if (ac->Cache.SecondaryColor.Ptr && ac->Cache.SecondaryColor.BufferObj == nullObj)
- FREE( ac->Cache.SecondaryColor.Ptr );
+ FREE( (void *) ac->Cache.SecondaryColor.Ptr );
if (ac->Cache.EdgeFlag.Ptr && ac->Cache.EdgeFlag.BufferObj == nullObj)
- FREE( ac->Cache.EdgeFlag.Ptr );
+ FREE( (void *) ac->Cache.EdgeFlag.Ptr );
if (ac->Cache.Index.Ptr && ac->Cache.Index.BufferObj == nullObj)
- FREE( ac->Cache.Index.Ptr );
+ FREE( (void *) ac->Cache.Index.Ptr );
if (ac->Cache.FogCoord.Ptr && ac->Cache.FogCoord.BufferObj == nullObj)
- FREE( ac->Cache.FogCoord.Ptr );
+ FREE( (void *) ac->Cache.FogCoord.Ptr );
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
if (ac->Cache.TexCoord[i].Ptr && ac->Cache.TexCoord[i].BufferObj == nullObj)
- FREE( ac->Cache.TexCoord[i].Ptr );
+ FREE( (void *) ac->Cache.TexCoord[i].Ptr );
}
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
if (ac->Cache.Attrib[i].Ptr && ac->Cache.Attrib[i].BufferObj == nullObj)
- FREE( ac->Cache.Attrib[i].Ptr );
+ FREE( (void *) ac->Cache.Attrib[i].Ptr );
}
if (ac->Elts)
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 945f68c174..23a8012a30 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -26,6 +26,7 @@
#include "glheader.h"
#include "api_validate.h"
#include "context.h"
+#include "image.h" /* for _mesa_sizeof_type() */
#include "imports.h"
#include "mtypes.h"
#include "state.h"
@@ -112,14 +113,40 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
}
+/**
+ * Helper routine for validating vertex array data to be sure the given
+ * element lies within the legal range (i.e. vertex buffer object).
+ */
+static INLINE GLboolean
+validate(GLcontext *ctx, GLint attribArray,
+ const struct gl_client_array *array, GLint element)
+{
+ if (ctx->VertexProgram.Enabled
+ && attribArray >= 0
+ && ctx->Array.VertexAttrib[attribArray].Enabled) {
+ if (element >= ctx->Array.VertexAttrib[attribArray]._MaxElement)
+ return GL_FALSE;
+ }
+ else if (array && array->Enabled) {
+ if (element >= array->_MaxElement)
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+}
+
+/**
+ * Called from the tnl module to error check the function parameters and
+ * verify that we really can draw something.
+ */
GLboolean
_mesa_validate_DrawArrays(GLcontext *ctx,
GLenum mode, GLint start, GLsizei count)
{
+ GLint i;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
- if (count<0) {
+ if (count < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" );
return GL_FALSE;
}
@@ -132,9 +159,57 @@ _mesa_validate_DrawArrays(GLcontext *ctx,
if (ctx->NewState)
_mesa_update_state( ctx );
- if (ctx->Array.Vertex.Enabled
- || (ctx->VertexProgram.Enabled && ctx->Array.VertexAttrib[0].Enabled))
- return GL_TRUE;
- else
+ /* Either the conventional vertex position array, or the 0th
+ * generic vertex attribute array is required to be enabled.
+ */
+ if (ctx->VertexProgram.Enabled
+ && ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled) {
+ if (start + count >= ctx->Array.VertexAttrib[VERT_ATTRIB_POS]._MaxElement)
+ return GL_FALSE;
+ }
+ else if (ctx->Array.Vertex.Enabled) {
+ if (start + count >= ctx->Array.Vertex._MaxElement)
+ return GL_FALSE;
+ }
+ else {
+ /* no vertex position array! */
+ return GL_FALSE;
+ }
+
+ /*
+ * OK, now check all the other enabled arrays to be sure the elements
+ * are in bounds.
+ */
+ if (!validate(ctx, VERT_ATTRIB_WEIGHT, NULL, start + count))
+ return GL_FALSE;
+
+ if (!validate(ctx, VERT_ATTRIB_NORMAL, &ctx->Array.Normal, start + count))
+ return GL_FALSE;
+
+ if (!validate(ctx, VERT_ATTRIB_COLOR0, &ctx->Array.Color, start + count))
+ return GL_FALSE;
+
+ if (!validate(ctx, VERT_ATTRIB_COLOR1, &ctx->Array.SecondaryColor, start + count))
+ return GL_FALSE;
+
+ if (!validate(ctx, VERT_ATTRIB_FOG, &ctx->Array.FogCoord, start + count))
+ return GL_FALSE;
+
+ if (!validate(ctx, VERT_ATTRIB_SIX, NULL, start + count))
return GL_FALSE;
+
+ if (!validate(ctx, VERT_ATTRIB_SEVEN, &ctx->Array.FogCoord, start + count))
+ return GL_FALSE;
+
+ for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
+ if (!validate(ctx, VERT_ATTRIB_TEX0 + i, &ctx->Array.TexCoord[i], start + count))
+ return GL_FALSE;
+
+ if (!validate(ctx, -1, &ctx->Array.Index, start + count))
+ return GL_FALSE;
+
+ if (!validate(ctx, -1, &ctx->Array.EdgeFlag, start + count))
+ return GL_FALSE;
+
+ return GL_TRUE;
}
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c
index 5102758656..56aa615263 100644
--- a/src/mesa/main/arbprogram.c
+++ b/src/mesa/main/arbprogram.c
@@ -178,7 +178,7 @@ _mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer)
return;
}
- *pointer = ctx->Array.VertexAttrib[index].Ptr;;
+ *pointer = (GLvoid *) ctx->Array.VertexAttrib[index].Ptr;;
}
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index d2d5b7892e..b01b581ef3 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -6295,28 +6295,28 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params )
switch (pname) {
case GL_VERTEX_ARRAY_POINTER:
- *params = ctx->Array.Vertex.Ptr;
+ *params = (GLvoid *) ctx->Array.Vertex.Ptr;
break;
case GL_NORMAL_ARRAY_POINTER:
- *params = ctx->Array.Normal.Ptr;
+ *params = (GLvoid *) ctx->Array.Normal.Ptr;
break;
case GL_COLOR_ARRAY_POINTER:
- *params = ctx->Array.Color.Ptr;
+ *params = (GLvoid *) ctx->Array.Color.Ptr;
break;
case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT:
- *params = ctx->Array.SecondaryColor.Ptr;
+ *params = (GLvoid *) ctx->Array.SecondaryColor.Ptr;
break;
case GL_FOG_COORDINATE_ARRAY_POINTER_EXT:
- *params = ctx->Array.FogCoord.Ptr;
+ *params = (GLvoid *) ctx->Array.FogCoord.Ptr;
break;
case GL_INDEX_ARRAY_POINTER:
- *params = ctx->Array.Index.Ptr;
+ *params = (GLvoid *) ctx->Array.Index.Ptr;
break;
case GL_TEXTURE_COORD_ARRAY_POINTER:
- *params = ctx->Array.TexCoord[clientUnit].Ptr;
+ *params = (GLvoid *) ctx->Array.TexCoord[clientUnit].Ptr;
break;
case GL_EDGE_FLAG_ARRAY_POINTER:
- *params = ctx->Array.EdgeFlag.Ptr;
+ *params = (GLvoid *) ctx->Array.EdgeFlag.Ptr;
break;
case GL_FEEDBACK_BUFFER_POINTER:
*params = ctx->Feedback.Buffer;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 2b51a4168a..2692cbb7e3 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1289,13 +1289,15 @@ struct gl_client_array {
GLenum Type;
GLsizei Stride; /**< user-specified stride */
GLsizei StrideB; /**< actual stride in bytes */
- GLubyte *Ptr;
- GLuint Flags;
+ const GLubyte *Ptr;
GLuint Enabled; /**< one of the _NEW_ARRAY_ bits */
GLboolean Normalized; /**< GL_ARB_vertex_program */
/**< GL_ARB_vertex_buffer_object */
struct gl_buffer_object *BufferObj;
+ GLuint _MaxElement;
+
+ GLuint Flags;
};
diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c
index e51a8c24b1..65ce7ca652 100644
--- a/src/mesa/main/nvprogram.c
+++ b/src/mesa/main/nvprogram.c
@@ -484,7 +484,7 @@ _mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer)
return;
}
- *pointer = ctx->Array.VertexAttrib[index].Ptr;;
+ *pointer = (GLvoid *) ctx->Array.VertexAttrib[index].Ptr;;
}
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index c03415fdcf..ddd04b4c81 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -34,9 +34,53 @@
#include "varray.h"
+#ifndef GL_BOOLEAN
+#define GL_BOOLEAN 0x9999
+#endif
+
+
+/**
+ * Update the fields of a vertex array structure.
+ * We need to do a few special things for arrays that live in
+ * vertex buffer objects.
+ */
+static void
+update_array(GLcontext *ctx, struct gl_client_array *array,
+ GLuint dirtyFlag, GLsizei elementSize,
+ GLint size, GLenum type,
+ GLsizei stride, GLboolean normalized, const GLvoid *ptr)
+{
+ array->Size = size;
+ array->Type = type;
+ array->Stride = stride;
+ array->StrideB = stride ? stride : elementSize;
+ array->Normalized = normalized;
+ array->Ptr = (const GLubyte *) ptr;
+#if FEATURE_ARB_vertex_buffer_object
+ array->BufferObj->RefCount--;
+ /* XXX free buffer object if RefCount == 0 ? */
+ array->BufferObj = ctx->Array.ArrayBufferObj;
+ array->BufferObj->RefCount++;
+ /* Compute the index of the last array element that's inside the buffer.
+ * Later in glDrawArrays we'll check if start + count > _MaxElement to
+ * be sure we won't go out of bounds.
+ */
+ if (ctx->Array.ArrayBufferObj->Name)
+ array->_MaxElement = ((GLsizeiptrARB) ctx->Array.ArrayBufferObj->Size
+ - (GLsizeiptrARB) array->Ptr) / array->StrideB;
+ else
+#endif
+ array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */
+
+ ctx->NewState |= _NEW_ARRAY;
+ ctx->Array.NewState |= dirtyFlag;
+}
+
+
void GLAPIENTRY
_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
{
+ GLsizei elementSize;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -56,34 +100,24 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
/* always need to check that <type> is legal */
switch (type) {
case GL_SHORT:
- ctx->Array.Vertex.StrideB = size * sizeof(GLshort);
+ elementSize = size * sizeof(GLshort);
break;
case GL_INT:
- ctx->Array.Vertex.StrideB = size * sizeof(GLint);
+ elementSize = size * sizeof(GLint);
break;
case GL_FLOAT:
- ctx->Array.Vertex.StrideB = size * sizeof(GLfloat);
+ elementSize = size * sizeof(GLfloat);
break;
case GL_DOUBLE:
- ctx->Array.Vertex.StrideB = size * sizeof(GLdouble);
+ elementSize = size * sizeof(GLdouble);
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type)" );
return;
}
- if (stride)
- ctx->Array.Vertex.StrideB = stride;
-
- ctx->Array.Vertex.Size = size;
- ctx->Array.Vertex.Type = type;
- ctx->Array.Vertex.Stride = stride;
- ctx->Array.Vertex.Ptr = (GLubyte *) ptr;
-#if FEATURE_ARB_vertex_buffer_object
- ctx->Array.Vertex.BufferObj = ctx->Array.ArrayBufferObj;
-#endif
- ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
+ update_array(ctx, &ctx->Array.Vertex, _NEW_ARRAY_VERTEX,
+ elementSize, size, type, stride, GL_FALSE, ptr);
if (ctx->Driver.VertexPointer)
ctx->Driver.VertexPointer( ctx, size, type, stride, ptr );
@@ -93,6 +127,7 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
void GLAPIENTRY
_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
{
+ GLsizei elementSize;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -107,36 +142,27 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
switch (type) {
case GL_BYTE:
- ctx->Array.Normal.StrideB = 3 * sizeof(GLbyte);
+ elementSize = 3 * sizeof(GLbyte);
break;
case GL_SHORT:
- ctx->Array.Normal.StrideB = 3 * sizeof(GLshort);
+ elementSize = 3 * sizeof(GLshort);
break;
case GL_INT:
- ctx->Array.Normal.StrideB = 3 * sizeof(GLint);
+ elementSize = 3 * sizeof(GLint);
break;
case GL_FLOAT:
- ctx->Array.Normal.StrideB = 3 * sizeof(GLfloat);
+ elementSize = 3 * sizeof(GLfloat);
break;
case GL_DOUBLE:
- ctx->Array.Normal.StrideB = 3 * sizeof(GLdouble);
+ elementSize = 3 * sizeof(GLdouble);
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type)" );
return;
}
- if (stride)
- ctx->Array.Normal.StrideB = stride;
- ctx->Array.Normal.Size = 3;
- ctx->Array.Normal.Type = type;
- ctx->Array.Normal.Stride = stride;
- ctx->Array.Normal.Ptr = (GLubyte *) ptr;
-#if FEATURE_ARB_vertex_buffer_object
- ctx->Array.Normal.BufferObj = ctx->Array.ArrayBufferObj;
-#endif
- ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_NORMAL;
+ update_array(ctx, &ctx->Array.Normal, _NEW_ARRAY_NORMAL,
+ elementSize, 3, type, stride, GL_FALSE, ptr);
if (ctx->Driver.NormalPointer)
ctx->Driver.NormalPointer( ctx, type, stride, ptr );
@@ -146,6 +172,7 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
void GLAPIENTRY
_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
{
+ GLsizei elementSize;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -153,7 +180,7 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
_mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" );
return;
}
- if (stride<0) {
+ if (stride < 0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
return;
}
@@ -164,46 +191,36 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
switch (type) {
case GL_BYTE:
- ctx->Array.Color.StrideB = size * sizeof(GLbyte);
+ elementSize = size * sizeof(GLbyte);
break;
case GL_UNSIGNED_BYTE:
- ctx->Array.Color.StrideB = size * sizeof(GLubyte);
+ elementSize = size * sizeof(GLubyte);
break;
case GL_SHORT:
- ctx->Array.Color.StrideB = size * sizeof(GLshort);
+ elementSize = size * sizeof(GLshort);
break;
case GL_UNSIGNED_SHORT:
- ctx->Array.Color.StrideB = size * sizeof(GLushort);
+ elementSize = size * sizeof(GLushort);
break;
case GL_INT:
- ctx->Array.Color.StrideB = size * sizeof(GLint);
+ elementSize = size * sizeof(GLint);
break;
case GL_UNSIGNED_INT:
- ctx->Array.Color.StrideB = size * sizeof(GLuint);
+ elementSize = size * sizeof(GLuint);
break;
case GL_FLOAT:
- ctx->Array.Color.StrideB = size * sizeof(GLfloat);
+ elementSize = size * sizeof(GLfloat);
break;
case GL_DOUBLE:
- ctx->Array.Color.StrideB = size * sizeof(GLdouble);
+ elementSize = size * sizeof(GLdouble);
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type)" );
return;
}
- if (stride)
- ctx->Array.Color.StrideB = stride;
-
- ctx->Array.Color.Size = size;
- ctx->Array.Color.Type = type;
- ctx->Array.Color.Stride = stride;
- ctx->Array.Color.Ptr = (GLubyte *) ptr;
-#if FEATURE_ARB_vertex_buffer_object
- ctx->Array.Color.BufferObj = ctx->Array.ArrayBufferObj;
-#endif
- ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_COLOR0;
+ update_array(ctx, &ctx->Array.Color, _NEW_ARRAY_COLOR0,
+ elementSize, size, type, stride, GL_FALSE, ptr);
if (ctx->Driver.ColorPointer)
ctx->Driver.ColorPointer( ctx, size, type, stride, ptr );
@@ -213,6 +230,7 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
void GLAPIENTRY
_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
{
+ GLint elementSize;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -223,28 +241,18 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
switch (type) {
case GL_FLOAT:
- ctx->Array.FogCoord.StrideB = sizeof(GLfloat);
+ elementSize = sizeof(GLfloat);
break;
case GL_DOUBLE:
- ctx->Array.FogCoord.StrideB = sizeof(GLdouble);
+ elementSize = sizeof(GLdouble);
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" );
return;
}
- if (stride)
- ctx->Array.FogCoord.StrideB = stride;
-
- ctx->Array.FogCoord.Size = 1;
- ctx->Array.FogCoord.Type = type;
- ctx->Array.FogCoord.Stride = stride;
- ctx->Array.FogCoord.Ptr = (GLubyte *) ptr;
-#if FEATURE_ARB_vertex_buffer_object
- ctx->Array.FogCoord.BufferObj = ctx->Array.ArrayBufferObj;
-#endif
- ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_FOGCOORD;
+ update_array(ctx, &ctx->Array.FogCoord, _NEW_ARRAY_FOGCOORD,
+ elementSize, 1, type, stride, GL_FALSE, ptr);
if (ctx->Driver.FogCoordPointer)
ctx->Driver.FogCoordPointer( ctx, type, stride, ptr );
@@ -254,6 +262,7 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
void GLAPIENTRY
_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
{
+ GLsizei elementSize;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -264,37 +273,27 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
switch (type) {
case GL_UNSIGNED_BYTE:
- ctx->Array.Index.StrideB = sizeof(GLubyte);
+ elementSize = sizeof(GLubyte);
break;
case GL_SHORT:
- ctx->Array.Index.StrideB = sizeof(GLshort);
+ elementSize = sizeof(GLshort);
break;
case GL_INT:
- ctx->Array.Index.StrideB = sizeof(GLint);
+ elementSize = sizeof(GLint);
break;
case GL_FLOAT:
- ctx->Array.Index.StrideB = sizeof(GLfloat);
+ elementSize = sizeof(GLfloat);
break;
case GL_DOUBLE:
- ctx->Array.Index.StrideB = sizeof(GLdouble);
+ elementSize = sizeof(GLdouble);
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" );
return;
}
- if (stride)
- ctx->Array.Index.StrideB = stride;
-
- ctx->Array.Index.Size = 1;
- ctx->Array.Index.Type = type;
- ctx->Array.Index.Stride = stride;
- ctx->Array.Index.Ptr = (GLubyte *) ptr;
-#if FEATURE_ARB_vertex_buffer_object
- ctx->Array.Index.BufferObj = ctx->Array.ArrayBufferObj;
-#endif
- ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_INDEX;
+ update_array(ctx, &ctx->Array.Index, _NEW_ARRAY_INDEX,
+ elementSize, 1, type, stride, GL_FALSE, ptr);
if (ctx->Driver.IndexPointer)
ctx->Driver.IndexPointer( ctx, type, stride, ptr );
@@ -305,6 +304,7 @@ void GLAPIENTRY
_mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
GLsizei stride, const GLvoid *ptr)
{
+ GLsizei elementSize;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -323,46 +323,36 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
switch (type) {
case GL_BYTE:
- ctx->Array.SecondaryColor.StrideB = size * sizeof(GLbyte);
+ elementSize = size * sizeof(GLbyte);
break;
case GL_UNSIGNED_BYTE:
- ctx->Array.SecondaryColor.StrideB = size * sizeof(GLubyte);
+ elementSize = size * sizeof(GLubyte);
break;
case GL_SHORT:
- ctx->Array.SecondaryColor.StrideB = size * sizeof(GLshort);
+ elementSize = size * sizeof(GLshort);
break;
case GL_UNSIGNED_SHORT:
- ctx->Array.SecondaryColor.StrideB = size * sizeof(GLushort);
+ elementSize = size * sizeof(GLushort);
break;
case GL_INT:
- ctx->Array.SecondaryColor.StrideB = size * sizeof(GLint);
+ elementSize = size * sizeof(GLint);
break;
case GL_UNSIGNED_INT:
- ctx->Array.SecondaryColor.StrideB = size * sizeof(GLuint);
+ elementSize = size * sizeof(GLuint);
break;
case GL_FLOAT:
- ctx->Array.SecondaryColor.StrideB = size * sizeof(GLfloat);
+ elementSize = size * sizeof(GLfloat);
break;
case GL_DOUBLE:
- ctx->Array.SecondaryColor.StrideB = size * sizeof(GLdouble);
+ elementSize = size * sizeof(GLdouble);
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type)" );
return;
}
- if (stride)
- ctx->Array.SecondaryColor.StrideB = stride;
-
- ctx->Array.SecondaryColor.Size = 3; /* hardwire */
- ctx->Array.SecondaryColor.Type = type;
- ctx->Array.SecondaryColor.Stride = stride;
- ctx->Array.SecondaryColor.Ptr = (GLubyte *) ptr;
-#if FEATURE_ARB_vertex_buffer_object
- ctx->Array.SecondaryColor.BufferObj = ctx->Array.ArrayBufferObj;
-#endif
- ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_COLOR1;
+ update_array(ctx, &ctx->Array.SecondaryColor, _NEW_ARRAY_COLOR1,
+ elementSize, size, type, stride, GL_FALSE, ptr);
if (ctx->Driver.SecondaryColorPointer)
ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr );
@@ -373,8 +363,9 @@ void GLAPIENTRY
_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
const GLvoid *ptr)
{
+ GLint elementSize;
GET_CURRENT_CONTEXT(ctx);
- GLuint texUnit = ctx->Array.ActiveTexture;
+ const GLuint unit = ctx->Array.ActiveTexture;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
if (size < 1 || size > 4) {
@@ -388,39 +379,29 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
_mesa_debug(ctx, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
- texUnit, size, _mesa_lookup_enum_by_nr( type ), stride);
+ unit, size, _mesa_lookup_enum_by_nr( type ), stride);
/* always need to check that <type> is legal */
switch (type) {
case GL_SHORT:
- ctx->Array.TexCoord[texUnit].StrideB = size * sizeof(GLshort);
+ elementSize = size * sizeof(GLshort);
break;
case GL_INT:
- ctx->Array.TexCoord[texUnit].StrideB = size * sizeof(GLint);
+ elementSize = size * sizeof(GLint);
break;
case GL_FLOAT:
- ctx->Array.TexCoord[texUnit].StrideB = size * sizeof(GLfloat);
+ elementSize = size * sizeof(GLfloat);
break;
case GL_DOUBLE:
- ctx->Array.TexCoord[texUnit].StrideB = size * sizeof(GLdouble);
+ elementSize = size * sizeof(GLdouble);
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type)" );
return;
}
- if (stride)
- ctx->Array.TexCoord[texUnit].StrideB = stride;
-
- ctx->Array.TexCoord[texUnit].Size = size;
- ctx->Array.TexCoord[texUnit].Type = type;
- ctx->Array.TexCoord[texUnit].Stride = stride;
- ctx->Array.TexCoord[texUnit].Ptr = (GLubyte *) ptr;
-#if FEATURE_ARB_vertex_buffer_object
- ctx->Array.TexCoord[texUnit].BufferObj = ctx->Array.ArrayBufferObj;
-#endif
- ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_TEXCOORD(texUnit);
+ update_array(ctx, &ctx->Array.TexCoord[unit], _NEW_ARRAY_TEXCOORD(unit),
+ elementSize, size, type, stride, GL_FALSE, ptr);
if (ctx->Driver.TexCoordPointer)
ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr );
@@ -428,24 +409,18 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
void GLAPIENTRY
-_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *vptr)
+_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr)
{
GET_CURRENT_CONTEXT(ctx);
- const GLboolean *ptr = (GLboolean *)vptr;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (stride<0) {
+ if (stride < 0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" );
return;
}
- ctx->Array.EdgeFlag.Stride = stride;
- ctx->Array.EdgeFlag.StrideB = stride ? stride : sizeof(GLboolean);
- ctx->Array.EdgeFlag.Ptr = (GLboolean *) ptr;
-#if FEATURE_ARB_vertex_buffer_object
- ctx->Array.EdgeFlag.BufferObj = ctx->Array.ArrayBufferObj;
-#endif
- ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_EDGEFLAG;
+
+ update_array(ctx, &ctx->Array.EdgeFlag, _NEW_ARRAY_EDGEFLAG,
+ sizeof(GLboolean), 1, GL_BOOLEAN, stride, GL_FALSE, ptr);
if (ctx->Driver.EdgeFlagPointer)
ctx->Driver.EdgeFlagPointer( ctx, stride, ptr );
@@ -457,6 +432,7 @@ void GLAPIENTRY
_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
GLsizei stride, const GLvoid *ptr)
{
+ GLsizei elementSize;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -483,34 +459,24 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
/* check for valid 'type' and compute StrideB right away */
switch (type) {
case GL_UNSIGNED_BYTE:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLubyte);
+ elementSize = size * sizeof(GLubyte);
break;
case GL_SHORT:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLshort);
+ elementSize = size * sizeof(GLshort);
break;
case GL_FLOAT:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLfloat);
+ elementSize = size * sizeof(GLfloat);
break;
case GL_DOUBLE:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLdouble);
+ elementSize = size * sizeof(GLdouble);
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type)" );
return;
}
- if (stride)
- ctx->Array.VertexAttrib[index].StrideB = stride;
-
- ctx->Array.VertexAttrib[index].Stride = stride;
- ctx->Array.VertexAttrib[index].Size = size;
- ctx->Array.VertexAttrib[index].Type = type;
- ctx->Array.VertexAttrib[index].Ptr = (GLubyte *) ptr;
-#if FEATURE_ARB_vertex_buffer_object
- ctx->Array.VertexAttrib[index].BufferObj = ctx->Array.ArrayBufferObj;
-#endif
- ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
+ update_array(ctx, &ctx->Array.VertexAttrib[index], _NEW_ARRAY_ATTRIB(index),
+ elementSize, size, type, stride, GL_FALSE, ptr);
if (ctx->Driver.VertexAttribPointer)
ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
@@ -524,6 +490,7 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
GLboolean normalized,
GLsizei stride, const GLvoid *ptr)
{
+ GLsizei elementSize;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -551,47 +518,36 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
/* NOTE: more types are supported here than in the NV extension */
switch (type) {
case GL_BYTE:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLbyte);
+ elementSize = size * sizeof(GLbyte);
break;
case GL_UNSIGNED_BYTE:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLubyte);
+ elementSize = size * sizeof(GLubyte);
break;
case GL_SHORT:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLshort);
+ elementSize = size * sizeof(GLshort);
break;
case GL_UNSIGNED_SHORT:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLushort);
+ elementSize = size * sizeof(GLushort);
break;
case GL_INT:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLint);
+ elementSize = size * sizeof(GLint);
break;
case GL_UNSIGNED_INT:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLuint);
+ elementSize = size * sizeof(GLuint);
break;
case GL_FLOAT:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLfloat);
+ elementSize = size * sizeof(GLfloat);
break;
case GL_DOUBLE:
- ctx->Array.VertexAttrib[index].StrideB = size * sizeof(GLdouble);
+ elementSize = size * sizeof(GLdouble);
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerARB(type)" );
return;
}
- if (stride)
- ctx->Array.VertexAttrib[index].StrideB = stride;
-
- ctx->Array.VertexAttrib[index].Stride = stride;
- ctx->Array.VertexAttrib[index].Size = size;
- ctx->Array.VertexAttrib[index].Type = type;
- ctx->Array.VertexAttrib[index].Normalized = normalized;
- ctx->Array.VertexAttrib[index].Ptr = (GLubyte *) ptr;
-#if FEATURE_ARB_vertex_buffer_object
- ctx->Array.VertexAttrib[index].BufferObj = ctx->Array.ArrayBufferObj;
-#endif
- ctx->NewState |= _NEW_ARRAY;
- ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
+ update_array(ctx, &ctx->Array.VertexAttrib[index], _NEW_ARRAY_ATTRIB(index),
+ elementSize, size, type, stride, normalized, ptr);
/* XXX fix
if (ctx->Driver.VertexAttribPointer)
@@ -660,7 +616,6 @@ _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
GET_CURRENT_CONTEXT(ctx);
GLboolean tflag, cflag, nflag; /* enable/disable flags */
GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */
-
GLenum ctype = 0; /* color type */
GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */
GLint defstride; /* default stride */
@@ -670,9 +625,9 @@ _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
f = sizeof(GLfloat);
- c = f * ((4*sizeof(GLubyte) + (f-1)) / f);
+ c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f);
- if (stride<0) {
+ if (stride < 0) {
_mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" );
return;
}
@@ -1047,12 +1002,12 @@ _mesa_init_varray( GLcontext * ctx )
ctx->Array.EdgeFlag.Flags = CA_CLIENT_DATA;
ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- ctx->Array.TexCoord[i].Size = 4;
- ctx->Array.TexCoord[i].Type = GL_FLOAT;
- ctx->Array.TexCoord[i].Stride = 0;
- ctx->Array.TexCoord[i].StrideB = 0;
- ctx->Array.TexCoord[i].Ptr = NULL;
- ctx->Array.TexCoord[i].Enabled = GL_FALSE;
- ctx->Array.TexCoord[i].Flags = CA_CLIENT_DATA;
+ ctx->Array.VertexAttrib[i].Size = 4;
+ ctx->Array.VertexAttrib[i].Type = GL_FLOAT;
+ ctx->Array.VertexAttrib[i].Stride = 0;
+ ctx->Array.VertexAttrib[i].StrideB = 0;
+ ctx->Array.VertexAttrib[i].Ptr = NULL;
+ ctx->Array.VertexAttrib[i].Enabled = GL_FALSE;
+ ctx->Array.VertexAttrib[i].Flags = CA_CLIENT_DATA;
}
}
diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c
index c000e41943..eb133f969c 100644
--- a/src/mesa/swrast_setup/ss_context.c
+++ b/src/mesa/swrast_setup/ss_context.c
@@ -83,10 +83,10 @@ _swsetup_DestroyContext( GLcontext *ctx )
ALIGN_FREE(swsetup->verts);
if (swsetup->ChanSecondaryColor.Ptr)
- ALIGN_FREE(swsetup->ChanSecondaryColor.Ptr);
+ ALIGN_FREE((void *) swsetup->ChanSecondaryColor.Ptr);
if (swsetup->ChanColor.Ptr)
- ALIGN_FREE(swsetup->ChanColor.Ptr);
+ ALIGN_FREE((void *) swsetup->ChanColor.Ptr);
FREE(swsetup);
ctx->swsetup_context = 0;
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] );