summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMathias Fröhlich <[email protected]>2018-11-17 07:13:11 +0100
committerMathias Fröhlich <[email protected]>2018-11-21 06:27:19 +0100
commit1217a8448c1061d230956ac6e69a1bb3809dd6f2 (patch)
treea0977d47c0f0ae6ff580b4d5e0ab3fbc5bd49f58 /src
parent73d2d313e9fafc8e8a6ac54af1da18d476821e7a (diff)
mesa: Use the gl_vertex_array_object::Enabled bitfield.
Instead of using gl_array_attributes::Enabled use the much more compact representation stored in gl_vertex_array_object::Enabled using the corresponding bits. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Signed-off-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/api_arrayelt.c28
-rw-r--r--src/mesa/main/arrayobj.c4
-rw-r--r--src/mesa/main/draw.c20
-rw-r--r--src/mesa/main/enable.c21
-rw-r--r--src/mesa/main/varray.c9
5 files changed, 39 insertions, 43 deletions
diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
index afa30120211..25cbc5326f8 100644
--- a/src/mesa/main/api_arrayelt.c
+++ b/src/mesa/main/api_arrayelt.c
@@ -1572,7 +1572,7 @@ _ae_update_state(struct gl_context *ctx)
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)];
@@ -1580,7 +1580,7 @@ _ae_update_state(struct gl_context *ctx)
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;
@@ -1588,7 +1588,7 @@ _ae_update_state(struct gl_context *ctx)
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)];
@@ -1596,7 +1596,7 @@ _ae_update_state(struct gl_context *ctx)
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)];
@@ -1604,7 +1604,7 @@ _ae_update_state(struct gl_context *ctx)
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)];
@@ -1612,7 +1612,7 @@ _ae_update_state(struct gl_context *ctx)
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)];
@@ -1621,9 +1621,9 @@ _ae_update_state(struct gl_context *ctx)
}
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.
*/
@@ -1641,9 +1641,9 @@ _ae_update_state(struct gl_context *ctx)
/* 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];
@@ -1672,7 +1672,7 @@ _ae_update_state(struct gl_context *ctx)
}
/* 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).
*/
@@ -1683,7 +1683,7 @@ _ae_update_state(struct gl_context *ctx)
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)];
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index c4e61a9954d..5572ae550f8 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -832,8 +832,8 @@ _mesa_update_vao_derived_arrays(struct gl_context *ctx,
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 */
diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index 99ea4d928be..313df6aa8bc 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -67,7 +67,7 @@ check_array_data(struct gl_context *ctx, struct gl_vertex_array_object *vao,
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;
@@ -117,7 +117,7 @@ unmap_array_buffer(struct gl_context *ctx, struct gl_vertex_array_object *vao,
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;
@@ -225,7 +225,7 @@ skip_validated_draw(struct gl_context *ctx)
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;
@@ -252,8 +252,7 @@ skip_validated_draw(struct gl_context *ctx)
/* 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;
@@ -277,20 +276,19 @@ print_draw_arrays(struct gl_context *ctx,
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)) {
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index bd3e493da53..21d6a812e07 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1582,41 +1582,40 @@ _mesa_IsEnabled( GLenum cap )
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:
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index e1675ff5135..e8969eb954a 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1267,7 +1267,7 @@ get_vertex_array_attrib(struct gl_context *ctx,
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:
@@ -2812,11 +2812,10 @@ _mesa_print_arrays(struct gl_context *ctx)
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];