Mesa (main): mesa: change gl_vertex_array_object::NewArrays to bool

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 3 23:50:05 UTC 2021


Module: Mesa
Branch: main
Commit: ae625da7efa844b2854b685dac43180616615ecb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ae625da7efa844b2854b685dac43180616615ecb

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Sun Oct 24 17:46:09 2021 -0400

mesa: change gl_vertex_array_object::NewArrays to bool

the individual bits are never used

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13512>

---

 src/mesa/main/arrayobj.c                 |  4 ++--
 src/mesa/main/arrayobj.h                 | 10 +++++-----
 src/mesa/main/draw.c                     |  2 +-
 src/mesa/main/mtypes.h                   |  4 ++--
 src/mesa/main/varray.c                   | 19 ++++++++++++-------
 src/mesa/state_tracker/st_cb_rasterpos.c |  2 +-
 src/mesa/vbo/vbo_private.h               |  3 ++-
 7 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 01a7c9b99fc..42a059b9d68 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -518,7 +518,7 @@ _mesa_update_vao_derived_arrays(struct gl_context *ctx,
                                 struct gl_vertex_array_object *vao)
 {
    /* Make sure we do not run into problems with shared objects */
-   assert(!vao->SharedAndImmutable || vao->NewArrays == 0);
+   assert(!vao->SharedAndImmutable || !vao->NewArrays);
 
    /* Limit used for common binding scanning below. */
    const GLsizeiptr MaxRelativeOffset =
@@ -810,7 +810,7 @@ _mesa_set_vao_immutable(struct gl_context *ctx,
                         struct gl_vertex_array_object *vao)
 {
    _mesa_update_vao_derived_arrays(ctx, vao);
-   vao->NewArrays = 0;
+   vao->NewArrays = false;
    vao->SharedAndImmutable = true;
 }
 
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index 0c116b02d24..721b5abc658 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -188,7 +188,7 @@ static inline GLbitfield
 _mesa_draw_vbo_array_bits(const struct gl_context *ctx)
 {
    const struct gl_vertex_array_object *const vao = ctx->Array._DrawVAO;
-   assert(vao->NewArrays == 0);
+   assert(!vao->NewArrays);
    return vao->_EffEnabledVBO & ctx->Array._DrawVAOEnabledAttribs;
 }
 
@@ -202,7 +202,7 @@ static inline GLbitfield
 _mesa_draw_user_array_bits(const struct gl_context *ctx)
 {
    const struct gl_vertex_array_object *const vao = ctx->Array._DrawVAO;
-   assert(vao->NewArrays == 0);
+   assert(!vao->NewArrays);
    return ~vao->_EffEnabledVBO & ctx->Array._DrawVAOEnabledAttribs;
 }
 
@@ -216,7 +216,7 @@ static inline GLbitfield
 _mesa_draw_nonzero_divisor_bits(const struct gl_context *ctx)
 {
    const struct gl_vertex_array_object *const vao = ctx->Array._DrawVAO;
-   assert(vao->NewArrays == 0);
+   assert(!vao->NewArrays);
    return vao->_EffEnabledNonZeroDivisor & ctx->Array._DrawVAOEnabledAttribs;
 }
 
@@ -240,7 +240,7 @@ static inline const struct gl_vertex_buffer_binding*
 _mesa_draw_buffer_binding_from_attrib(const struct gl_vertex_array_object *vao,
                                       const struct gl_array_attributes *attrib)
 {
-   assert(vao->NewArrays == 0);
+   assert(!vao->NewArrays);
    return &vao->BufferBinding[attrib->_EffBufferBindingIndex];
 }
 
@@ -252,7 +252,7 @@ static inline const struct gl_array_attributes*
 _mesa_draw_array_attrib(const struct gl_vertex_array_object *vao,
                         gl_vert_attrib attr)
 {
-   assert(vao->NewArrays == 0);
+   assert(!vao->NewArrays);
    const gl_attribute_map_mode map_mode = vao->_AttributeMapMode;
    return &vao->VertexAttrib[_mesa_vao_attribute_map[map_mode][attr]];
 }
diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c
index 90b10c00d51..1ab837e7361 100644
--- a/src/mesa/main/draw.c
+++ b/src/mesa/main/draw.c
@@ -113,7 +113,7 @@ _mesa_set_draw_vao(struct gl_context *ctx, struct gl_vertex_array_object *vao,
 
    if (vao->NewArrays) {
       _mesa_update_vao_derived_arrays(ctx, vao);
-      vao->NewArrays = 0;
+      vao->NewArrays = false;
 
       new_array = true;
    }
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 9b2eb8afb12..64c70d95051 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1639,8 +1639,8 @@ struct gl_vertex_array_object
    /** "Enabled" with the position/generic0 attribute aliasing resolved */
    GLbitfield _EnabledWithMapMode;
 
-   /** Mask of VERT_BIT_* values indicating changed/dirty arrays */
-   GLbitfield NewArrays;
+   /** Whether the VAO has been changed. */
+   bool NewArrays;
 
    /** The index buffer (also known as the element array buffer in OpenGL). */
    struct gl_buffer_object *IndexBufferObj;
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 70f77e1625d..0ccb50d2df1 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -184,7 +184,8 @@ _mesa_vertex_attrib_binding(struct gl_context *ctx,
 
       array->BufferBindingIndex = bindingIndex;
 
-      vao->NewArrays |= vao->Enabled & array_bit;
+      if (vao->Enabled & array_bit)
+         vao->NewArrays = true;
       vao->NonDefaultStateMask |= array_bit | BITFIELD_BIT(bindingIndex);
    }
 }
@@ -241,7 +242,8 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
          vbo->UsageHistory |= USAGE_ARRAY_BUFFER;
       }
 
-      vao->NewArrays |= vao->Enabled & binding->_BoundArrays;
+      if (vao->Enabled & binding->_BoundArrays)
+         vao->NewArrays = true;
       vao->NonDefaultStateMask |= BITFIELD_BIT(index);
    }
 }
@@ -269,7 +271,8 @@ vertex_binding_divisor(struct gl_context *ctx,
       else
          vao->NonZeroDivisorMask &= ~binding->_BoundArrays;
 
-      vao->NewArrays |= vao->Enabled & binding->_BoundArrays;
+      if (vao->Enabled & binding->_BoundArrays)
+         vao->NewArrays = true;
       vao->NonDefaultStateMask |= BITFIELD_BIT(bindingIndex);
    }
 }
@@ -652,7 +655,8 @@ _mesa_update_array_format(struct gl_context *ctx,
    array->RelativeOffset = relativeOffset;
    array->Format = new_format;
 
-   vao->NewArrays |= vao->Enabled & VERT_BIT(attrib);
+   if (vao->Enabled & VERT_BIT(attrib))
+      vao->NewArrays = true;
    vao->NonDefaultStateMask |= BITFIELD_BIT(attrib);
 }
 
@@ -912,7 +916,8 @@ update_array(struct gl_context *ctx,
    if ((array->Stride != stride) || (array->Ptr != ptr)) {
       array->Stride = stride;
       array->Ptr = ptr;
-      vao->NewArrays |= vao->Enabled & VERT_BIT(attrib);
+      if (vao->Enabled & VERT_BIT(attrib))
+         vao->NewArrays = true;
       vao->NonDefaultStateMask |= BITFIELD_BIT(attrib);
    }
 
@@ -1884,7 +1889,7 @@ _mesa_enable_vertex_array_attribs(struct gl_context *ctx,
    if (attrib_bits) {
       /* was disabled, now being enabled */
       vao->Enabled |= attrib_bits;
-      vao->NewArrays |= attrib_bits;
+      vao->NewArrays = true;
       vao->NonDefaultStateMask |= attrib_bits;
 
       /* Update the map mode if needed */
@@ -1985,7 +1990,7 @@ _mesa_disable_vertex_array_attribs(struct gl_context *ctx,
    if (attrib_bits) {
       /* was enabled, now being disabled */
       vao->Enabled &= ~attrib_bits;
-      vao->NewArrays |= attrib_bits;
+      vao->NewArrays = true;
 
       /* Update the map mode if needed */
       if (attrib_bits & (VERT_BIT_POS|VERT_BIT_GENERIC0))
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c
index 38bbd5a6827..bb6a5f23774 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -259,7 +259,7 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
     * Just plug in position pointer now.
     */
    rs->VAO->VertexAttrib[VERT_ATTRIB_POS].Ptr = (GLubyte *) v;
-   rs->VAO->NewArrays |= VERT_BIT_POS;
+   rs->VAO->NewArrays = true;
    _mesa_set_draw_vao(ctx, rs->VAO, VERT_BIT_POS);
 
    /* Draw the point. */
diff --git a/src/mesa/vbo/vbo_private.h b/src/mesa/vbo/vbo_private.h
index 7bcb114c245..7e0e174b40f 100644
--- a/src/mesa/vbo/vbo_private.h
+++ b/src/mesa/vbo/vbo_private.h
@@ -255,7 +255,8 @@ _vbo_set_attrib_format(struct gl_context *ctx,
       size /= 2;
    _mesa_update_array_format(ctx, vao, attr, size, type, GL_RGBA,
                              GL_FALSE, integer, doubles, offset);
-   vao->NewArrays |= vao->Enabled & VERT_BIT(attr);
+   if (vao->Enabled & VERT_BIT(attr))
+      vao->NewArrays = true;
    vao->VertexAttrib[attr].Ptr = ADD_POINTERS(buffer_offset, offset);
 }
 



More information about the mesa-commit mailing list