/** * Do error checking and update state for glVertex/Color/TexCoord/...Pointer * functions. * * \param func name of calling function used for error reporting * \param attrib the attribute array index to update * \param legalTypes bitmask of *_BIT above indicating legal datatypes * \param sizeMin min allowable size value * \param sizeMax max allowable size value * \param size components per element (1, 2, 3 or 4) * \param type datatype of each component (GL_FLOAT, GL_INT, etc) * \param stride stride between elements, in elements * \param normalized are integer types converted to floats in [-1, 1]? * \param integer integer-valued values (will not be normalized to [-1,1]) * \param ptr the address (or offset inside VBO) of the array data */ static void update_array(struct gl_context *ctx, const char *func, GLuint attrib, GLbitfield legalTypesMask, GLint sizeMin, GLint sizeMax, GLint size, GLenum type, GLsizei stride, GLboolean normalized, GLboolean integer, const GLvoid *ptr) { struct gl_client_array *array; GLbitfield typeBit; GLsizei elementSize; typeBit = type_to_bit(ctx, type); if (typeBit == 0x0 || (typeBit & legalTypesMask) == 0x0) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", func, _mesa_lookup_enum_by_nr(type)); return; } /* Do size parameter checking. */ if (size < sizeMin || size > sizeMax || size > 4) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d)", func, size); return; } ASSERT(size <= 4); if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "%s(stride=%d)", func, stride ); return; } if (ctx->Array.ArrayObj->ARBsemantics && !_mesa_is_bufferobj(ctx->Array.ArrayBufferObj)) { /* GL_ARB_vertex_array_object requires that all arrays reside in VBOs. * Generate GL_INVALID_OPERATION if that's not true. */ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(non-VBO array)", func); return; } elementSize = _mesa_sizeof_type(type) * size; array = &ctx->Array.ArrayObj->VertexAttrib[attrib]; array->Size = size; array->Type = type; array->Stride = stride; array->StrideB = stride ? stride : elementSize; array->Normalized = normalized; array->Integer = integer; array->Ptr = (const GLubyte *) ptr; array->_ElementSize = elementSize; _mesa_reference_buffer_object(ctx, &array->BufferObj, ctx->Array.ArrayBufferObj); ctx->NewState |= _NEW_ARRAY; ctx->Array.NewState |= VERT_BIT(attrib); }
/** * Do error checking and update state for glVertex/Color/TexCoord/...Pointer * functions. * * \param func name of calling function used for error reporting * \param attrib the attribute array index to update * \param legalTypes bitmask of *_BIT above indicating legal datatypes * \param sizeMin min allowable size value * \param sizeMax max allowable size value * \param size components per element (1, 2, 3 or 4) * \param type datatype of each component (GL_FLOAT, GL_INT, etc) * \param stride stride between elements, in elements * \param normalized are integer types converted to floats in [-1, 1]? * \param integer integer-valued values (will not be normalized to [-1,1]) * \param ptr the address (or offset inside VBO) of the array data */ static void update_array(struct gl_context *ctx, const char *func, GLuint attrib, GLbitfield legalTypesMask, GLint sizeMin, GLint sizeMax, GLint size, GLenum type, GLsizei stride, GLboolean normalized, GLboolean integer, const GLvoid *ptr) { struct gl_client_array *array; GLbitfield typeBit; GLsizei elementSize; typeBit = type_to_bit(ctx, type); if (typeBit == 0x0 || (typeBit & legalTypesMask) == 0x0) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", func, _mesa_lookup_enum_by_nr(type)); return; } /* Do size parameter checking. */ if (size < sizeMin || size > sizeMax || size > 4) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d)", func, size); return; } ASSERT(size <= 4); if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "%s(stride=%d)", func, stride ); return; } elementSize = _mesa_sizeof_type(type) * size; array = &ctx->Array.VertexAttrib[attrib]; array->Size = size; array->Type = type; array->Stride = stride; array->StrideB = stride ? stride : elementSize; array->Normalized = normalized; array->Integer = integer; array->Ptr = (const GLubyte *) ptr; array->_ElementSize = elementSize; ctx->NewState |= _NEW_ARRAY; ctx->Array.NewState |= VERT_BIT(attrib); }
/** * Do error checking and update state for glVertex/Color/TexCoord/...Pointer * functions. * * \param func name of calling function used for error reporting * \param attrib the attribute array index to update * \param legalTypes bitmask of *_BIT above indicating legal datatypes * \param sizeMin min allowable size value * \param sizeMax max allowable size value (may also be BGRA_OR_4) * \param size components per element (1, 2, 3 or 4) * \param type datatype of each component (GL_FLOAT, GL_INT, etc) * \param stride stride between elements, in elements * \param normalized are integer types converted to floats in [-1, 1]? * \param integer integer-valued values (will not be normalized to [-1,1]) * \param ptr the address (or offset inside VBO) of the array data */ static void update_array(struct gl_context *ctx, const char *func, GLuint attrib, GLbitfield legalTypesMask, GLint sizeMin, GLint sizeMax, GLint size, GLenum type, GLsizei stride, GLboolean normalized, GLboolean integer, const GLvoid *ptr) { struct gl_client_array *array; GLbitfield typeBit; GLsizei elementSize; GLenum format = GL_RGBA; if (_mesa_is_gles(ctx)) { /* Once Mesa gets support for GL_OES_vertex_half_float this mask will * change. Adding support for this extension isn't quite as trivial as * we'd like because ES uses a different enum value for GL_HALF_FLOAT. */ legalTypesMask &= ~(FIXED_GL_BIT | HALF_BIT | DOUBLE_BIT); /* GL_INT and GL_UNSIGNED_INT data is not allowed in OpenGL ES until * 3.0. The 2_10_10_10 types are added in OpenGL ES 3.0 or * GL_OES_vertex_type_10_10_10_2. */ if (ctx->Version < 30) { legalTypesMask &= ~(UNSIGNED_INT_BIT | INT_BIT | UNSIGNED_INT_2_10_10_10_REV_BIT | INT_2_10_10_10_REV_BIT); } /* BGRA ordering is not supported in ES contexts. */ if (sizeMax == BGRA_OR_4) sizeMax = 4; } else { legalTypesMask &= ~FIXED_ES_BIT; if (!ctx->Extensions.ARB_ES2_compatibility) legalTypesMask &= ~FIXED_GL_BIT; if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT | INT_2_10_10_10_REV_BIT); } typeBit = type_to_bit(ctx, type); if (typeBit == 0x0 || (typeBit & legalTypesMask) == 0x0) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", func, _mesa_lookup_enum_by_nr(type)); return; } /* Do size parameter checking. * If sizeMax = BGRA_OR_4 it means that size = GL_BGRA is legal and * must be handled specially. */ if (ctx->Extensions.EXT_vertex_array_bgra && sizeMax == BGRA_OR_4 && size == GL_BGRA) { GLboolean bgra_error = GL_FALSE; if (ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) { if (type != GL_UNSIGNED_INT_2_10_10_10_REV && type != GL_INT_2_10_10_10_REV && type != GL_UNSIGNED_BYTE) bgra_error = GL_TRUE; } else if (type != GL_UNSIGNED_BYTE) bgra_error = GL_TRUE; if (bgra_error) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(GL_BGRA/GLubyte)", func); return; } format = GL_BGRA; size = 4; } else if (size < sizeMin || size > sizeMax || size > 4) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d)", func, size); return; } if (ctx->Extensions.ARB_vertex_type_2_10_10_10_rev && (type == GL_UNSIGNED_INT_2_10_10_10_REV || type == GL_INT_2_10_10_10_REV) && size != 4) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(size=%d)", func, size); return; } ASSERT(size <= 4); if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "%s(stride=%d)", func, stride ); return; } if (ctx->Array.ArrayObj->ARBsemantics && !_mesa_is_bufferobj(ctx->Array.ArrayBufferObj)) { /* GL_ARB_vertex_array_object requires that all arrays reside in VBOs. * Generate GL_INVALID_OPERATION if that's not true. */ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(non-VBO array)", func); return; } elementSize = _mesa_sizeof_type(type) * size; array = &ctx->Array.ArrayObj->VertexAttrib[attrib]; array->Size = size; array->Type = type; array->Format = format; array->Stride = stride; array->StrideB = stride ? stride : elementSize; array->Normalized = normalized; array->Integer = integer; array->Ptr = (const GLubyte *) ptr; array->_ElementSize = elementSize; _mesa_reference_buffer_object(ctx, &array->BufferObj, ctx->Array.ArrayBufferObj); ctx->NewState |= _NEW_ARRAY; ctx->Array.ArrayObj->NewArrays |= VERT_BIT(attrib); }
/** * Do error checking and update state for glVertex/Color/TexCoord/...Pointer * functions. * * \param func name of calling function used for error reporting * \param attrib the attribute array index to update * \param legalTypes bitmask of *_BIT above indicating legal datatypes * \param sizeMin min allowable size value * \param sizeMax max allowable size value (may also be BGRA_OR_4) * \param size components per element (1, 2, 3 or 4) * \param type datatype of each component (GL_FLOAT, GL_INT, etc) * \param stride stride between elements, in elements * \param normalized are integer types converted to floats in [-1, 1]? * \param integer integer-valued values (will not be normalized to [-1,1]) * \param ptr the address (or offset inside VBO) of the array data */ static void update_array(struct gl_context *ctx, const char *func, GLuint attrib, GLbitfield legalTypesMask, GLint sizeMin, GLint sizeMax, GLint size, GLenum type, GLsizei stride, GLboolean normalized, GLboolean integer, const GLvoid *ptr) { struct gl_client_array *array; GLbitfield typeBit; GLsizei elementSize; GLenum format = GL_RGBA; if (ctx->API != API_OPENGLES && ctx->API != API_OPENGLES2) { /* fixed point arrays / data is only allowed with OpenGL ES 1.x/2.0 */ legalTypesMask &= ~FIXED_ES_BIT; } if (!ctx->Extensions.ARB_ES2_compatibility) { legalTypesMask &= ~FIXED_GL_BIT; } if (!ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) { legalTypesMask &= ~(UNSIGNED_INT_2_10_10_10_REV_BIT | INT_2_10_10_10_REV_BIT); } typeBit = type_to_bit(ctx, type); if (typeBit == 0x0 || (typeBit & legalTypesMask) == 0x0) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(type = %s)", func, _mesa_lookup_enum_by_nr(type)); return; } /* Do size parameter checking. * If sizeMax = BGRA_OR_4 it means that size = GL_BGRA is legal and * must be handled specially. */ if (ctx->Extensions.EXT_vertex_array_bgra && sizeMax == BGRA_OR_4 && size == GL_BGRA) { GLboolean bgra_error = GL_FALSE; if (ctx->Extensions.ARB_vertex_type_2_10_10_10_rev) { if (type != GL_UNSIGNED_INT_2_10_10_10_REV && type != GL_INT_2_10_10_10_REV && type != GL_UNSIGNED_BYTE) bgra_error = GL_TRUE; } else if (type != GL_UNSIGNED_BYTE) bgra_error = GL_TRUE; if (bgra_error) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(GL_BGRA/GLubyte)", func); return; } format = GL_BGRA; size = 4; } else if (size < sizeMin || size > sizeMax || size > 4) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d)", func, size); return; } if (ctx->Extensions.ARB_vertex_type_2_10_10_10_rev && (type == GL_UNSIGNED_INT_2_10_10_10_REV || type == GL_INT_2_10_10_10_REV) && size != 4) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(size=%d)", func, size); } ASSERT(size <= 4); if (stride < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "%s(stride=%d)", func, stride ); return; } if (ctx->Array.ArrayObj->ARBsemantics && !_mesa_is_bufferobj(ctx->Array.ArrayBufferObj)) { /* GL_ARB_vertex_array_object requires that all arrays reside in VBOs. * Generate GL_INVALID_OPERATION if that's not true. */ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(non-VBO array)", func); return; } elementSize = _mesa_sizeof_type(type) * size; array = &ctx->Array.ArrayObj->VertexAttrib[attrib]; array->Size = size; array->Type = type; array->Format = format; array->Stride = stride; array->StrideB = stride ? stride : elementSize; array->Normalized = normalized; array->Integer = integer; array->Ptr = (const GLubyte *) ptr; array->_ElementSize = elementSize; _mesa_reference_buffer_object(ctx, &array->BufferObj, ctx->Array.ArrayBufferObj); ctx->NewState |= _NEW_ARRAY; ctx->Array.NewState |= VERT_BIT(attrib); }