actx->nr_vbos = 0;
/* conventional vertex arrays */
- if (vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
+ if (vao->Enabled & VERT_BIT_COLOR_INDEX) {
aa->array = &vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX];
aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex];
aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
aa++;
}
- if (vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
+ if (vao->Enabled & VERT_BIT_EDGEFLAG) {
aa->array = &vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG];
aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex];
aa->offset = _gloffset_EdgeFlagv;
aa++;
}
- if (vao->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
+ if (vao->Enabled & VERT_BIT_NORMAL) {
aa->array = &vao->VertexAttrib[VERT_ATTRIB_NORMAL];
aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex];
aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
aa++;
}
- if (vao->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
+ if (vao->Enabled & VERT_BIT_COLOR0) {
aa->array = &vao->VertexAttrib[VERT_ATTRIB_COLOR0];
aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex];
aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
aa++;
}
- if (vao->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
+ if (vao->Enabled & VERT_BIT_COLOR1) {
aa->array = &vao->VertexAttrib[VERT_ATTRIB_COLOR1];
aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex];
aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
aa++;
}
- if (vao->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
+ if (vao->Enabled & VERT_BIT_FOG) {
aa->array = &vao->VertexAttrib[VERT_ATTRIB_FOG];
aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex];
aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
}
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
- struct gl_array_attributes *attribArray =
- &vao->VertexAttrib[VERT_ATTRIB_TEX(i)];
- if (attribArray->Enabled) {
+ if (vao->Enabled & VERT_BIT_TEX(i)) {
+ struct gl_array_attributes *attribArray =
+ &vao->VertexAttrib[VERT_ATTRIB_TEX(i)];
/* NOTE: we use generic glVertexAttribNV functions here.
* If we ever remove GL_NV_vertex_program this will have to change.
*/
/* generic vertex attribute arrays */
for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) { /* skip zero! */
- struct gl_array_attributes *attribArray =
- &vao->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
- if (attribArray->Enabled) {
+ if (vao->Enabled & VERT_BIT_GENERIC(i)) {
+ struct gl_array_attributes *attribArray =
+ &vao->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
GLint intOrNorm;
at->array = attribArray;
at->binding = &vao->BufferBinding[attribArray->BufferBindingIndex];
}
/* finally, vertex position */
- if (vao->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) {
+ if (vao->Enabled & VERT_BIT_GENERIC0) {
/* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
* issued as the last (provoking) attribute).
*/
check_vbo(actx, aa->binding->BufferObj);
aa++;
}
- else if (vao->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
+ else if (vao->Enabled & VERT_BIT_POS) {
aa->array = &vao->VertexAttrib[VERT_ATTRIB_POS];
aa->binding = &vao->BufferBinding[aa->array->BufferBindingIndex];
aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
for (gl_vert_attrib attr = 0; attr < VERT_ATTRIB_MAX; ++attr) {
/* Query the original api defined attrib/binding information ... */
const unsigned char *const map =_mesa_vao_attribute_map[mode];
- const struct gl_array_attributes *attrib = &vao->VertexAttrib[map[attr]];
- if (attrib->Enabled) {
+ if (vao->Enabled & VERT_BIT(map[attr])) {
+ const struct gl_array_attributes *attrib = &vao->VertexAttrib[map[attr]];
const struct gl_vertex_buffer_binding *binding =
&vao->BufferBinding[attrib->BufferBindingIndex];
/* ... and compare that with the computed attrib/binding */
GLuint attrib, GLuint j)
{
const struct gl_array_attributes *array = &vao->VertexAttrib[attrib];
- if (array->Enabled) {
+ if (vao->Enabled & VERT_BIT(attrib)) {
const struct gl_vertex_buffer_binding *binding =
&vao->BufferBinding[array->BufferBindingIndex];
struct gl_buffer_object *bo = binding->BufferObj;
GLuint attrib)
{
const struct gl_array_attributes *array = &vao->VertexAttrib[attrib];
- if (array->Enabled) {
+ if (vao->Enabled & VERT_BIT(attrib)) {
const struct gl_vertex_buffer_binding *binding =
&vao->BufferBinding[array->BufferBindingIndex];
struct gl_buffer_object *bo = binding->BufferObj;
case API_OPENGLES:
/* For OpenGL ES, only draw if we have vertex positions
*/
- if (!ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POS].Enabled)
+ if (!(ctx->Array.VAO->Enabled & VERT_BIT_POS))
return true;
break;
/* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic
* array [0]).
*/
- return (!ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POS].Enabled &&
- !ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled);
+ return !(ctx->Array.VAO->Enabled & (VERT_BIT_POS|VERT_BIT_GENERIC0));
}
break;
printf("_mesa_DrawArrays(mode 0x%x, start %d, count %d):\n",
mode, start, count);
- unsigned i;
- for (i = 0; i < VERT_ATTRIB_MAX; ++i) {
+ GLbitfield mask = vao->Enabled;
+ while (mask) {
+ const gl_vert_attrib i = u_bit_scan(&mask);
const struct gl_array_attributes *array = &vao->VertexAttrib[i];
- if (!array->Enabled)
- continue;
const struct gl_vertex_buffer_binding *binding =
&vao->BufferBinding[array->BufferBindingIndex];
struct gl_buffer_object *bufObj = binding->BufferObj;
- printf("attr %s: size %d stride %d enabled %d "
+ printf("attr %s: size %d stride %d "
"ptr %p Bufobj %u\n",
gl_vert_attrib_name((gl_vert_attrib) i),
- array->Size, binding->Stride, array->Enabled,
+ array->Size, binding->Stride,
array->Ptr, bufObj->Name);
if (_mesa_is_bufferobj(bufObj)) {
case GL_VERTEX_ARRAY:
if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
goto invalid_enum_error;
- return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POS].Enabled;
+ return !!(ctx->Array.VAO->Enabled & VERT_BIT_POS);
case GL_NORMAL_ARRAY:
if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
goto invalid_enum_error;
- return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled;
+ return !!(ctx->Array.VAO->Enabled & VERT_BIT_NORMAL);
case GL_COLOR_ARRAY:
if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
goto invalid_enum_error;
- return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled;
+ return !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR0);
case GL_INDEX_ARRAY:
if (ctx->API != API_OPENGL_COMPAT)
goto invalid_enum_error;
- return ctx->Array.VAO->
- VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled;
+ return !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR_INDEX);
case GL_TEXTURE_COORD_ARRAY:
if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
goto invalid_enum_error;
- return ctx->Array.VAO->
- VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled;
+ return !!(ctx->Array.VAO->Enabled &
+ VERT_BIT_TEX(ctx->Array.ActiveTexture));
case GL_EDGE_FLAG_ARRAY:
if (ctx->API != API_OPENGL_COMPAT)
goto invalid_enum_error;
- return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled;
+ return !!(ctx->Array.VAO->Enabled & VERT_BIT_EDGEFLAG);
case GL_FOG_COORDINATE_ARRAY_EXT:
if (ctx->API != API_OPENGL_COMPAT)
goto invalid_enum_error;
- return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_FOG].Enabled;
+ return !!(ctx->Array.VAO->Enabled & VERT_BIT_FOG);
case GL_SECONDARY_COLOR_ARRAY_EXT:
if (ctx->API != API_OPENGL_COMPAT)
goto invalid_enum_error;
- return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled;
+ return !!(ctx->Array.VAO->Enabled & VERT_BIT_COLOR1);
case GL_POINT_SIZE_ARRAY_OES:
if (ctx->API != API_OPENGLES)
goto invalid_enum_error;
- return ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled;
+ return !!(ctx->Array.VAO->Enabled & VERT_BIT_POINT_SIZE);
/* GL_ARB_texture_cube_map */
case GL_TEXTURE_CUBE_MAP:
switch (pname) {
case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
- return array->Enabled;
+ return !!(vao->Enabled & VERT_BIT_GENERIC(index));
case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
return (array->Format == GL_BGRA) ? GL_BGRA : array->Size;
case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
fprintf(stderr, "Array Object %u\n", vao->Name);
- gl_vert_attrib i;
- for (i = 0; i < VERT_ATTRIB_MAX; ++i) {
+ GLbitfield mask = vao->Enabled;
+ while (mask) {
+ const gl_vert_attrib i = u_bit_scan(&mask);
const struct gl_array_attributes *array = &vao->VertexAttrib[i];
- if (!array->Enabled)
- continue;
const struct gl_vertex_buffer_binding *binding =
&vao->BufferBinding[array->BufferBindingIndex];