vertex_attrib_binding(struct gl_context *ctx, GLuint attribIndex,
GLuint bindingIndex)
{
- struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
- struct gl_vertex_attrib_array *array = &arrayObj->VertexAttrib[attribIndex];
+ struct gl_vertex_array_object *vao = ctx->Array.VAO;
+ struct gl_vertex_attrib_array *array = &vao->VertexAttrib[attribIndex];
if (array->VertexBinding != bindingIndex) {
const GLbitfield64 array_bit = VERT_BIT(attribIndex);
FLUSH_VERTICES(ctx, _NEW_ARRAY);
- arrayObj->VertexBinding[array->VertexBinding]._BoundArrays &= ~array_bit;
- arrayObj->VertexBinding[bindingIndex]._BoundArrays |= array_bit;
+ vao->VertexBinding[array->VertexBinding]._BoundArrays &= ~array_bit;
+ vao->VertexBinding[bindingIndex]._BoundArrays |= array_bit;
array->VertexBinding = bindingIndex;
- arrayObj->NewArrays |= array_bit;
+ vao->NewArrays |= array_bit;
}
}
struct gl_buffer_object *vbo,
GLintptr offset, GLsizei stride)
{
- struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
- struct gl_vertex_buffer_binding *binding = &arrayObj->VertexBinding[index];
+ struct gl_vertex_array_object *vao = ctx->Array.VAO;
+ struct gl_vertex_buffer_binding *binding = &vao->VertexBinding[index];
if (binding->BufferObj != vbo ||
binding->Offset != offset ||
binding->Offset = offset;
binding->Stride = stride;
- arrayObj->NewArrays |= binding->_BoundArrays;
+ vao->NewArrays |= binding->_BoundArrays;
}
}
vertex_binding_divisor(struct gl_context *ctx, GLuint bindingIndex,
GLuint divisor)
{
- struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
+ struct gl_vertex_array_object *vao = ctx->Array.VAO;
struct gl_vertex_buffer_binding *binding =
- &arrayObj->VertexBinding[bindingIndex];
+ &vao->VertexBinding[bindingIndex];
if (binding->InstanceDivisor != divisor) {
FLUSH_VERTICES(ctx, _NEW_ARRAY);
binding->InstanceDivisor = divisor;
- arrayObj->NewArrays |= binding->_BoundArrays;
+ vao->NewArrays |= binding->_BoundArrays;
}
}
elementSize = _mesa_bytes_per_vertex_attrib(size, type);
assert(elementSize != -1);
- array = &ctx->Array.ArrayObj->VertexAttrib[attrib];
+ array = &ctx->Array.VAO->VertexAttrib[attrib];
array->Size = size;
array->Type = type;
array->Format = format;
array->RelativeOffset = relativeOffset;
array->_ElementSize = elementSize;
- ctx->Array.ArrayObj->NewArrays |= VERT_BIT(attrib);
+ ctx->Array.VAO->NewArrays |= VERT_BIT(attrib);
ctx->NewState |= _NEW_ARRAY;
return true;
* The check for VBOs is handled below.
*/
if (ctx->API == API_OPENGL_CORE
- && (ctx->Array.ArrayObj == ctx->Array.DefaultArrayObj)) {
+ && (ctx->Array.VAO == ctx->Array.DefaultVAO)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(no array object bound)",
func);
return;
}
- if (!update_array_format(ctx, func, attrib, legalTypesMask, sizeMin, sizeMax,
- size, type, normalized, integer, 0)) {
- return;
- }
-
if (stride < 0) {
_mesa_error( ctx, GL_INVALID_VALUE, "%s(stride=%d)", func, stride );
return;
* to the ARRAY_BUFFER buffer object binding point (see section
* 2.9.6), and the pointer argument is not NULL."
*/
- if (ptr != NULL && ctx->Array.ArrayObj->ARBsemantics &&
+ if (ptr != NULL && ctx->Array.VAO->ARBsemantics &&
!_mesa_is_bufferobj(ctx->Array.ArrayBufferObj)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(non-VBO array)", func);
return;
}
+ if (!update_array_format(ctx, func, attrib, legalTypesMask, sizeMin,
+ sizeMax, size, type, normalized, integer, 0)) {
+ return;
+ }
+
/* Reset the vertex attrib binding */
vertex_attrib_binding(ctx, attrib, attrib);
/* The Stride and Ptr fields are not set by update_array_format() */
- array = &ctx->Array.ArrayObj->VertexAttrib[attrib];
+ array = &ctx->Array.VAO->VertexAttrib[attrib];
array->Stride = stride;
array->Ptr = (const GLvoid *) ptr;
_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr)
{
const GLbitfield legalTypes = UNSIGNED_BYTE_BIT;
- /* see table 2.4 edits in GL_EXT_gpu_shader4 spec: */
- const GLboolean integer = GL_TRUE;
+ /* this is the same type that glEdgeFlag uses */
+ const GLboolean integer = GL_FALSE;
GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
UNSIGNED_INT_10F_11F_11F_REV_BIT);
GET_CURRENT_CONTEXT(ctx);
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)");
return;
}
const GLboolean integer = GL_TRUE;
GET_CURRENT_CONTEXT(ctx);
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribIPointer(index)");
return;
}
void GLAPIENTRY
_mesa_EnableVertexAttribArray(GLuint index)
{
- struct gl_array_object *arrayObj;
+ struct gl_vertex_array_object *vao;
GET_CURRENT_CONTEXT(ctx);
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glEnableVertexAttribArrayARB(index)");
return;
}
- arrayObj = ctx->Array.ArrayObj;
+ vao = ctx->Array.VAO;
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(arrayObj->_VertexAttrib));
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(vao->_VertexAttrib));
- if (!arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
+ if (!vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
/* was disabled, now being enabled */
FLUSH_VERTICES(ctx, _NEW_ARRAY);
- arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE;
- arrayObj->_Enabled |= VERT_BIT_GENERIC(index);
- arrayObj->NewArrays |= VERT_BIT_GENERIC(index);
+ vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE;
+ vao->_Enabled |= VERT_BIT_GENERIC(index);
+ vao->NewArrays |= VERT_BIT_GENERIC(index);
}
}
void GLAPIENTRY
_mesa_DisableVertexAttribArray(GLuint index)
{
- struct gl_array_object *arrayObj;
+ struct gl_vertex_array_object *vao;
GET_CURRENT_CONTEXT(ctx);
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glDisableVertexAttribArrayARB(index)");
return;
}
- arrayObj = ctx->Array.ArrayObj;
+ vao = ctx->Array.VAO;
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(arrayObj->_VertexAttrib));
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(vao->_VertexAttrib));
- if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
+ if (vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
/* was enabled, now being disabled */
FLUSH_VERTICES(ctx, _NEW_ARRAY);
- arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE;
- arrayObj->_Enabled &= ~VERT_BIT_GENERIC(index);
- arrayObj->NewArrays |= VERT_BIT_GENERIC(index);
+ vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE;
+ vao->_Enabled &= ~VERT_BIT_GENERIC(index);
+ vao->NewArrays |= VERT_BIT_GENERIC(index);
}
}
get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname,
const char *caller)
{
- const struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
+ const struct gl_vertex_array_object *vao = ctx->Array.VAO;
const struct gl_vertex_attrib_array *array;
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", caller, index);
return 0;
}
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(arrayObj->VertexAttrib));
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib));
- array = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)];
+ array = &vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)];
switch (pname) {
case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB:
return array->Normalized;
case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
- return arrayObj->VertexBinding[array->VertexBinding].BufferObj->Name;
+ return vao->VertexBinding[array->VertexBinding].BufferObj->Name;
case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
if ((_mesa_is_desktop_gl(ctx)
&& (ctx->Version >= 30 || ctx->Extensions.EXT_gpu_shader4))
case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB:
if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_instanced_arrays)
|| _mesa_is_gles3(ctx)) {
- return arrayObj->VertexBinding[array->VertexBinding].InstanceDivisor;
+ return vao->VertexBinding[array->VertexBinding].InstanceDivisor;
}
goto error;
case GL_VERTEX_ATTRIB_BINDING:
return NULL;
}
}
- else if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ else if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(index>=GL_MAX_VERTEX_ATTRIBS)", function);
return NULL;
}
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->_VertexAttrib));
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.VAO->_VertexAttrib));
FLUSH_CURRENT(ctx, 0);
return ctx->Current.Attrib[VERT_ATTRIB_GENERIC(index)];
{
GET_CURRENT_CONTEXT(ctx);
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)");
return;
}
return;
}
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->_VertexAttrib));
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.VAO->_VertexAttrib));
- *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr;
+ *pointer = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr;
}
for (i = 0; i < primcount; i++) {
if (count[i] > 0) {
- CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i]));
+ CALL_DrawArrays(ctx->CurrentDispatch, (mode, first[i], count[i]));
}
}
}
for ( i = 0 ; i < primcount ; i++ ) {
if ( count[i] > 0 ) {
GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
- CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] ));
+ CALL_DrawArrays(ctx->CurrentDispatch, ( m, first[i], count[i] ));
}
}
}
for ( i = 0 ; i < primcount ; i++ ) {
if ( count[i] > 0 ) {
GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
- CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] ));
+ CALL_DrawElements(ctx->CurrentDispatch, ( m, count[i], type,
+ indices[i] ));
}
}
}
return;
}
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribDivisor(index = %u)",
index);
return;
}
- ASSERT(genericIndex < Elements(ctx->Array.ArrayObj->VertexAttrib));
+ ASSERT(genericIndex < Elements(ctx->Array.VAO->VertexAttrib));
/* The ARB_vertex_attrib_binding spec says:
*
GLsizei stride)
{
GET_CURRENT_CONTEXT(ctx);
- const struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
+ const struct gl_vertex_array_object *vao = ctx->Array.VAO;
struct gl_buffer_object *vbo;
ASSERT_OUTSIDE_BEGIN_END(ctx);
* is bound."
*/
if (ctx->API == API_OPENGL_CORE &&
- ctx->Array.ArrayObj == ctx->Array.DefaultArrayObj) {
+ ctx->Array.VAO == ctx->Array.DefaultVAO) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBindVertexBuffer(No array object bound)");
return;
return;
}
- if (buffer == arrayObj->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj->Name) {
- vbo = arrayObj->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj;
+ if (buffer == vao->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj->Name) {
+ vbo = vao->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj;
} else if (buffer != 0) {
vbo = _mesa_lookup_bufferobj(ctx, buffer);
* - ..."
*/
if (ctx->API == API_OPENGL_CORE &&
- ctx->Array.ArrayObj == ctx->Array.DefaultArrayObj) {
+ ctx->Array.VAO == ctx->Array.DefaultVAO) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glVertexAttribFormat(No array object bound)");
return;
* "The error INVALID_VALUE is generated if index is greater than or equal
* to the value of MAX_VERTEX_ATTRIBS."
*/
- if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glVertexAttribFormat(attribindex=%u > "
"GL_MAX_VERTEX_ATTRIBS)",
* - ..."
*/
if (ctx->API == API_OPENGL_CORE &&
- ctx->Array.ArrayObj == ctx->Array.DefaultArrayObj) {
+ ctx->Array.VAO == ctx->Array.DefaultVAO) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glVertexAttribIFormat(No array object bound)");
return;
* "The error INVALID_VALUE is generated if index is greater than
* or equal to the value of MAX_VERTEX_ATTRIBS."
*/
- if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glVertexAttribIFormat(attribindex=%u > "
"GL_MAX_VERTEX_ATTRIBS)",
* that this is an oversight.
*/
if (ctx->API == API_OPENGL_CORE &&
- ctx->Array.ArrayObj == ctx->Array.DefaultArrayObj) {
+ ctx->Array.VAO == ctx->Array.DefaultVAO) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glVertexAttribLFormat(No array object bound)");
return;
* "The error INVALID_VALUE is generated if <attribindex> is greater than
* or equal to the value of MAX_VERTEX_ATTRIBS."
*/
- if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glVertexAttribLFormat(attribindex=%u > "
"GL_MAX_VERTEX_ATTRIBS)",
* is bound."
*/
if (ctx->API == API_OPENGL_CORE &&
- ctx->Array.ArrayObj == ctx->Array.DefaultArrayObj) {
+ ctx->Array.VAO == ctx->Array.DefaultVAO) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glVertexAttribBinding(No array object bound)");
return;
* MAX_VERTEX_ATTRIB_BINDINGS, otherwise the error INVALID_VALUE
* is generated."
*/
- if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glVertexAttribBinding(attribindex=%u >= "
"GL_MAX_VERTEX_ATTRIBS)",
}
ASSERT(VERT_ATTRIB_GENERIC(attribIndex) <
- Elements(ctx->Array.ArrayObj->VertexAttrib));
+ Elements(ctx->Array.VAO->VertexAttrib));
vertex_attrib_binding(ctx, VERT_ATTRIB_GENERIC(attribIndex),
VERT_ATTRIB_GENERIC(bindingIndex));
* is bound."
*/
if (ctx->API == API_OPENGL_CORE &&
- ctx->Array.ArrayObj == ctx->Array.DefaultArrayObj) {
+ ctx->Array.VAO == ctx->Array.DefaultVAO) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glVertexBindingDivisor(No array object bound)");
return;
void
_mesa_print_arrays(struct gl_context *ctx)
{
- struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
+ struct gl_vertex_array_object *vao = ctx->Array.VAO;
GLuint i;
- _mesa_update_array_object_max_element(ctx, arrayObj);
+ _mesa_update_vao_max_element(ctx, vao);
- printf("Array Object %u\n", arrayObj->Name);
- if (arrayObj->_VertexAttrib[VERT_ATTRIB_POS].Enabled)
- print_array("Vertex", -1, &arrayObj->_VertexAttrib[VERT_ATTRIB_POS]);
- if (arrayObj->_VertexAttrib[VERT_ATTRIB_NORMAL].Enabled)
- print_array("Normal", -1, &arrayObj->_VertexAttrib[VERT_ATTRIB_NORMAL]);
- if (arrayObj->_VertexAttrib[VERT_ATTRIB_COLOR0].Enabled)
- print_array("Color", -1, &arrayObj->_VertexAttrib[VERT_ATTRIB_COLOR0]);
+ printf("Array Object %u\n", vao->Name);
+ if (vao->_VertexAttrib[VERT_ATTRIB_POS].Enabled)
+ print_array("Vertex", -1, &vao->_VertexAttrib[VERT_ATTRIB_POS]);
+ if (vao->_VertexAttrib[VERT_ATTRIB_NORMAL].Enabled)
+ print_array("Normal", -1, &vao->_VertexAttrib[VERT_ATTRIB_NORMAL]);
+ if (vao->_VertexAttrib[VERT_ATTRIB_COLOR0].Enabled)
+ print_array("Color", -1, &vao->_VertexAttrib[VERT_ATTRIB_COLOR0]);
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
- if (arrayObj->_VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled)
- print_array("TexCoord", i, &arrayObj->_VertexAttrib[VERT_ATTRIB_TEX(i)]);
+ if (vao->_VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled)
+ print_array("TexCoord", i, &vao->_VertexAttrib[VERT_ATTRIB_TEX(i)]);
for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++)
- if (arrayObj->_VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
- print_array("Attrib", i, &arrayObj->_VertexAttrib[VERT_ATTRIB_GENERIC(i)]);
- printf(" _MaxElement = %u\n", arrayObj->_MaxElement);
+ if (vao->_VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
+ print_array("Attrib", i, &vao->_VertexAttrib[VERT_ATTRIB_GENERIC(i)]);
+ printf(" _MaxElement = %u\n", vao->_MaxElement);
}
void
_mesa_init_varray(struct gl_context *ctx)
{
- ctx->Array.DefaultArrayObj = ctx->Driver.NewArrayObject(ctx, 0);
- _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj,
- ctx->Array.DefaultArrayObj);
+ ctx->Array.DefaultVAO = ctx->Driver.NewArrayObject(ctx, 0);
+ _mesa_reference_vao(ctx, &ctx->Array.VAO, ctx->Array.DefaultVAO);
ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
ctx->Array.Objects = _mesa_NewHashTable();
static void
delete_arrayobj_cb(GLuint id, void *data, void *userData)
{
- struct gl_array_object *arrayObj = (struct gl_array_object *) data;
+ struct gl_vertex_array_object *vao = (struct gl_vertex_array_object *) data;
struct gl_context *ctx = (struct gl_context *) userData;
- _mesa_delete_array_object(ctx, arrayObj);
+ _mesa_delete_vao(ctx, vao);
}