* Do error checking for glVertex/Color/TexCoord/...Pointer functions.
*
* \param func name of calling function used for error reporting
+ * \param vao the vao to update
+ * \param obj the bound buffer object
* \param attrib the attribute array index to update
* \param legalTypes bitmask of *_BIT above indicating legal datatypes
* \param sizeMin min allowable size value
*/
static void
validate_array(struct gl_context *ctx, const char *func,
+ struct gl_vertex_array_object *vao,
+ struct gl_buffer_object *obj,
GLuint attrib, GLbitfield legalTypesMask,
GLint sizeMin, GLint sizeMax,
GLint size, GLenum type, GLsizei stride,
GLboolean normalized, GLboolean integer, GLboolean doubles,
const GLvoid *ptr)
{
- struct gl_vertex_array_object *vao = ctx->Array.VAO;
-
/* Page 407 (page 423 of the PDF) of the OpenGL 3.0 spec says:
*
* "Client vertex arrays - all vertex array attribute pointers must
* 2.9.6), and the pointer argument is not NULL."
*/
if (ptr != NULL && vao != ctx->Array.DefaultVAO &&
- !_mesa_is_bufferobj(ctx->Array.ArrayBufferObj)) {
+ !_mesa_is_bufferobj(obj)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(non-VBO array)", func);
return;
}
static bool
validate_array_and_format(struct gl_context *ctx, const char *func,
+ struct gl_vertex_array_object *vao,
+ struct gl_buffer_object *obj,
GLuint attrib, GLbitfield legalTypes,
GLint sizeMin, GLint sizeMax,
GLint size, GLenum type, GLsizei stride,
GLboolean normalized, GLboolean integer,
- GLboolean doubles, GLenum format, const GLvoid *ptr,
- struct gl_vertex_array_object *vao)
+ GLboolean doubles, GLenum format, const GLvoid *ptr)
{
- validate_array(ctx, func, attrib, legalTypes, sizeMin, sizeMax, size,
- type, stride, normalized, integer, doubles, ptr);
+ validate_array(ctx, func, vao, obj, attrib, legalTypes, sizeMin, sizeMax,
+ size, type, stride, normalized, integer, doubles, ptr);
return validate_array_format(ctx, func, vao, attrib, legalTypes, sizeMin,
sizeMax, size, type, normalized, integer,
/**
* Update state for glVertex/Color/TexCoord/...Pointer functions.
*
+ * \param vao the vao to update
+ * \param obj the bound buffer object
* \param attrib the attribute array index to update
* \param format Either GL_RGBA or GL_BGRA.
* \param sizeMax max allowable size value (may also be BGRA_OR_4)
*/
static void
update_array(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ struct gl_buffer_object *obj,
GLuint attrib, GLenum format,
GLint sizeMax,
GLint size, GLenum type, GLsizei stride,
GLboolean normalized, GLboolean integer, GLboolean doubles,
const GLvoid *ptr)
{
- struct gl_vertex_array_object *vao = ctx->Array.VAO;
-
_mesa_update_array_format(ctx, vao, attrib, size, type, format,
normalized, integer, doubles, 0);
GLsizei effectiveStride = stride != 0 ?
stride : array->Format._ElementSize;
_mesa_bind_vertex_buffer(ctx, vao, attrib,
- ctx->Array.ArrayBufferObj, (GLintptr) ptr,
+ obj, (GLintptr) ptr,
effectiveStride);
}
{
GET_CURRENT_CONTEXT(ctx);
- update_array(ctx, VERT_ATTRIB_POS, GL_RGBA, 4, size, type, stride,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_POS, GL_RGBA, 4, size, type, stride,
GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
UNSIGNED_INT_2_10_10_10_REV_BIT |
INT_2_10_10_10_REV_BIT);
- if (!validate_array_and_format(ctx, "glVertexPointer", VERT_ATTRIB_POS,
- legalTypes, 2, 4, size, type, stride,
- GL_FALSE, GL_FALSE, GL_FALSE, format,
- ptr, ctx->Array.VAO))
+ if (!validate_array_and_format(ctx, "glVertexPointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_POS, legalTypes, 2, 4, size,
+ type, stride, GL_FALSE, GL_FALSE, GL_FALSE,
+ format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_POS, format, 4, size, type, stride,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_POS, format, 4, size, type, stride,
GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
{
GET_CURRENT_CONTEXT(ctx);
- update_array(ctx, VERT_ATTRIB_NORMAL, GL_RGBA, 3, 3, type, stride, GL_TRUE,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_NORMAL, GL_RGBA, 3, 3, type, stride, GL_TRUE,
GL_FALSE, GL_FALSE, ptr);
}
INT_2_10_10_10_REV_BIT);
if (!validate_array_and_format(ctx, "glNormalPointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_NORMAL, legalTypes, 3, 3, 3,
type, stride, GL_TRUE, GL_FALSE,
- GL_FALSE, format, ptr, ctx->Array.VAO))
+ GL_FALSE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_NORMAL, format, 3, 3, type, stride, GL_TRUE,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_NORMAL, format, 3, 3, type, stride, GL_TRUE,
GL_FALSE, GL_FALSE, ptr);
}
GET_CURRENT_CONTEXT(ctx);
GLenum format = get_array_format(ctx, BGRA_OR_4, &size);
- update_array(ctx, VERT_ATTRIB_COLOR0, format, BGRA_OR_4, size,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_COLOR0, format, BGRA_OR_4, size,
type, stride, GL_TRUE, GL_FALSE, GL_FALSE, ptr);
}
INT_2_10_10_10_REV_BIT);
if (!validate_array_and_format(ctx, "glColorPointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_COLOR0, legalTypes, sizeMin,
BGRA_OR_4, size, type, stride, GL_TRUE,
- GL_FALSE, GL_FALSE, format, ptr,
- ctx->Array.VAO))
+ GL_FALSE, GL_FALSE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_COLOR0, format, BGRA_OR_4, size,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_COLOR0, format, BGRA_OR_4, size,
type, stride, GL_TRUE, GL_FALSE, GL_FALSE, ptr);
}
{
GET_CURRENT_CONTEXT(ctx);
- update_array(ctx, VERT_ATTRIB_FOG, GL_RGBA, 1, 1, type, stride, GL_FALSE,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_FOG, GL_RGBA, 1, 1, type, stride, GL_FALSE,
GL_FALSE, GL_FALSE, ptr);
}
const GLbitfield legalTypes = (HALF_BIT | FLOAT_BIT | DOUBLE_BIT);
if (!validate_array_and_format(ctx, "glFogCoordPointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_FOG, legalTypes, 1, 1, 1,
type, stride, GL_FALSE, GL_FALSE,
- GL_FALSE, format, ptr, ctx->Array.VAO))
+ GL_FALSE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_FOG, format, 1, 1, type, stride, GL_FALSE,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_FOG, format, 1, 1, type, stride, GL_FALSE,
GL_FALSE, GL_FALSE, ptr);
}
{
GET_CURRENT_CONTEXT(ctx);
- update_array(ctx, VERT_ATTRIB_COLOR_INDEX, GL_RGBA, 1, 1, type, stride,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_COLOR_INDEX, GL_RGBA, 1, 1, type, stride,
GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
FLOAT_BIT | DOUBLE_BIT);
if (!validate_array_and_format(ctx, "glIndexPointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_COLOR_INDEX,
legalTypes, 1, 1, 1, type, stride,
- GL_FALSE, GL_FALSE, GL_FALSE, format,
- ptr, ctx->Array.VAO))
+ GL_FALSE, GL_FALSE, GL_FALSE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_COLOR_INDEX, format, 1, 1, type, stride,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_COLOR_INDEX, format, 1, 1, type, stride,
GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
GET_CURRENT_CONTEXT(ctx);
GLenum format = get_array_format(ctx, BGRA_OR_4, &size);
- update_array(ctx, VERT_ATTRIB_COLOR1, format, BGRA_OR_4, size, type,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_COLOR1, format, BGRA_OR_4, size, type,
stride, GL_TRUE, GL_FALSE, GL_FALSE, ptr);
}
INT_2_10_10_10_REV_BIT);
if (!validate_array_and_format(ctx, "glSecondaryColorPointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_COLOR1, legalTypes, 3,
BGRA_OR_4, size, type, stride,
- GL_TRUE, GL_FALSE, GL_FALSE, format, ptr,
- ctx->Array.VAO))
+ GL_TRUE, GL_FALSE, GL_FALSE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_COLOR1, format, BGRA_OR_4, size, type,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_COLOR1, format, BGRA_OR_4, size, type,
stride, GL_TRUE, GL_FALSE, GL_FALSE, ptr);
}
GET_CURRENT_CONTEXT(ctx);
const GLuint unit = ctx->Array.ActiveTexture;
- update_array(ctx, VERT_ATTRIB_TEX(unit), GL_RGBA, 4, size, type,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_TEX(unit), GL_RGBA, 4, size, type,
stride, GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
INT_2_10_10_10_REV_BIT);
if (!validate_array_and_format(ctx, "glTexCoordPointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_TEX(unit), legalTypes,
sizeMin, 4, size, type, stride,
- GL_FALSE, GL_FALSE, GL_FALSE, format, ptr,
- ctx->Array.VAO))
+ GL_FALSE, GL_FALSE, GL_FALSE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_TEX(unit), format, 4, size, type,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_TEX(unit), format, 4, size, type,
stride, GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
const GLboolean integer = GL_FALSE;
GET_CURRENT_CONTEXT(ctx);
- update_array(ctx, VERT_ATTRIB_EDGEFLAG, GL_RGBA, 1, 1, GL_UNSIGNED_BYTE,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_EDGEFLAG, GL_RGBA, 1, 1, GL_UNSIGNED_BYTE,
stride, GL_FALSE, integer, GL_FALSE, ptr);
}
const GLbitfield legalTypes = UNSIGNED_BYTE_BIT;
if (!validate_array_and_format(ctx, "glEdgeFlagPointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_EDGEFLAG, legalTypes,
1, 1, 1, GL_UNSIGNED_BYTE, stride,
- GL_FALSE, integer, GL_FALSE, format, ptr,
- ctx->Array.VAO))
+ GL_FALSE, integer, GL_FALSE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_EDGEFLAG, format, 1, 1, GL_UNSIGNED_BYTE,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_EDGEFLAG, format, 1, 1, GL_UNSIGNED_BYTE,
stride, GL_FALSE, integer, GL_FALSE, ptr);
}
{
GET_CURRENT_CONTEXT(ctx);
- update_array(ctx, VERT_ATTRIB_POINT_SIZE, GL_RGBA, 1, 1, type, stride,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_POINT_SIZE, GL_RGBA, 1, 1, type, stride,
GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
const GLbitfield legalTypes = (FLOAT_BIT | FIXED_ES_BIT);
if (!validate_array_and_format(ctx, "glPointSizePointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_POINT_SIZE, legalTypes,
1, 1, 1, type, stride, GL_FALSE, GL_FALSE,
- GL_FALSE, format, ptr, ctx->Array.VAO))
+ GL_FALSE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_POINT_SIZE, format, 1, 1, type, stride,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_POINT_SIZE, format, 1, 1, type, stride,
GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
GET_CURRENT_CONTEXT(ctx);
GLenum format = get_array_format(ctx, BGRA_OR_4, &size);
- update_array(ctx, VERT_ATTRIB_GENERIC(index), format, BGRA_OR_4,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_GENERIC(index), format, BGRA_OR_4,
size, type, stride, normalized, GL_FALSE, GL_FALSE, ptr);
}
UNSIGNED_INT_10F_11F_11F_REV_BIT);
if (!validate_array_and_format(ctx, "glVertexAttribPointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_GENERIC(index), legalTypes,
1, BGRA_OR_4, size, type, stride,
- normalized, GL_FALSE, GL_FALSE, format,
- ptr, ctx->Array.VAO))
+ normalized, GL_FALSE, GL_FALSE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_GENERIC(index), format, BGRA_OR_4,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_GENERIC(index), format, BGRA_OR_4,
size, type, stride, normalized, GL_FALSE, GL_FALSE, ptr);
}
const GLboolean integer = GL_TRUE;
GET_CURRENT_CONTEXT(ctx);
- update_array(ctx, VERT_ATTRIB_GENERIC(index), GL_RGBA, 4, size, type,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_GENERIC(index), GL_RGBA, 4, size, type,
stride, normalized, integer, GL_FALSE, ptr);
}
INT_BIT | UNSIGNED_INT_BIT);
if (!validate_array_and_format(ctx, "glVertexAttribIPointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_GENERIC(index), legalTypes,
1, 4, size, type, stride,
- normalized, integer, GL_FALSE, format,
- ptr, ctx->Array.VAO))
+ normalized, integer, GL_FALSE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_GENERIC(index), format, 4, size, type,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_GENERIC(index), format, 4, size, type,
stride, normalized, integer, GL_FALSE, ptr);
}
{
GET_CURRENT_CONTEXT(ctx);
- update_array(ctx, VERT_ATTRIB_GENERIC(index), GL_RGBA, 4, size, type,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_GENERIC(index), GL_RGBA, 4, size, type,
stride, GL_FALSE, GL_FALSE, GL_TRUE, ptr);
}
const GLbitfield legalTypes = DOUBLE_BIT;
if (!validate_array_and_format(ctx, "glVertexAttribLPointer",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_GENERIC(index), legalTypes,
1, 4, size, type, stride,
- GL_FALSE, GL_FALSE, GL_TRUE, format,
- ptr, ctx->Array.VAO))
+ GL_FALSE, GL_FALSE, GL_TRUE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_GENERIC(index), format, 4, size, type,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_GENERIC(index), format, 4, size, type,
stride, GL_FALSE, GL_FALSE, GL_TRUE, ptr);
}
INT_2_10_10_10_REV_BIT);
if (!validate_array_and_format(ctx, "glMultiTexCoordPointerEXT",
+ ctx->Array.VAO, ctx->Array.ArrayBufferObj,
VERT_ATTRIB_TEX(unit), legalTypes,
sizeMin, 4, size, type, stride,
- GL_FALSE, GL_FALSE, GL_FALSE, format, ptr,
- ctx->Array.VAO))
+ GL_FALSE, GL_FALSE, GL_FALSE, format, ptr))
return;
- update_array(ctx, VERT_ATTRIB_TEX(unit), format, 4, size, type,
+ update_array(ctx, ctx->Array.VAO, ctx->Array.ArrayBufferObj,
+ VERT_ATTRIB_TEX(unit), format, 4, size, type,
stride, GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}