From: Mathias Fröhlich <mathias.froehl...@web.de>

Hi all,

An other splitout VAO handling improvement patch that
I wanted to feed seperately.
The change may be subject to discussion and following
patches depend on the call signatures of some of the
mesa internal vao methods that in turn depend on the
outcome of this change.
Theory tells me that the patch shall be safe. Practice,
in terms of a piglit quick run on i965, classic swrast and
radeonsi without introducing regressions tell me that
theory seems correct ...

... please review!

thanks and best

Mathias


Pending draw calls on immediate mode or display list calls do
not depend on changes of the VAO state. So, remove calls to
FLUSH_VERTICES and flag _NEW_ARRAY as appropriate.

Signed-off-by: Mathias Fröhlich <mathias.froehl...@web.de>
---
 src/mesa/main/varray.c | 47 +++++------------------------------------------
 1 file changed, 5 insertions(+), 42 deletions(-)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index d55f74e968..d50f6aeaf8 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -171,14 +171,13 @@ vertex_attrib_binding(struct gl_context *ctx,
       else
          vao->VertexAttribBufferMask &= ~array_bit;
 
-      FLUSH_VERTICES(ctx, _NEW_ARRAY);
-
       vao->BufferBinding[array->BufferBindingIndex]._BoundArrays &= ~array_bit;
       vao->BufferBinding[bindingIndex]._BoundArrays |= array_bit;
 
       array->BufferBindingIndex = bindingIndex;
 
       vao->NewArrays |= vao->_Enabled & array_bit;
+      ctx->NewState |= _NEW_ARRAY;
    }
 }
 
@@ -201,8 +200,6 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
        binding->Offset != offset ||
        binding->Stride != stride) {
 
-      FLUSH_VERTICES(ctx, _NEW_ARRAY);
-
       _mesa_reference_buffer_object(ctx, &binding->BufferObj, vbo);
 
       binding->Offset = offset;
@@ -214,6 +211,7 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
          vao->VertexAttribBufferMask |= binding->_BoundArrays;
 
       vao->NewArrays |= vao->_Enabled & binding->_BoundArrays;
+      ctx->NewState |= _NEW_ARRAY;
    }
 }
 
@@ -232,9 +230,9 @@ vertex_binding_divisor(struct gl_context *ctx,
       &vao->BufferBinding[bindingIndex];
 
    if (binding->InstanceDivisor != divisor) {
-      FLUSH_VERTICES(ctx, _NEW_ARRAY);
       binding->InstanceDivisor = divisor;
       vao->NewArrays |= vao->_Enabled & binding->_BoundArrays;
+      ctx->NewState |= _NEW_ARRAY;
    }
 }
 
@@ -316,8 +314,6 @@ get_array_format(const struct gl_context *ctx, GLint 
sizeMax, GLint *size)
  * \param doubles        Double values not reduced to floats
  * \param relativeOffset Offset of the first element relative to the binding
  *                       offset.
- * \param flush_verties  Should \c FLUSH_VERTICES be invoked before updating
- *                       state?
  */
 void
 _mesa_update_array_format(struct gl_context *ctx,
@@ -611,7 +607,6 @@ _mesa_VertexPointer_no_error(GLint size, GLenum type, 
GLsizei stride,
                              const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 
    update_array(ctx, VERT_ATTRIB_POS, GL_RGBA, 4, size, type, stride,
                 GL_FALSE, GL_FALSE, GL_FALSE, ptr);
@@ -623,8 +618,6 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei 
stride, const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
 
-   FLUSH_VERTICES(ctx, 0);
-
    GLenum format = GL_RGBA;
    GLbitfield legalTypes = (ctx->API == API_OPENGLES)
       ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT)
@@ -648,7 +641,6 @@ void GLAPIENTRY
 _mesa_NormalPointer_no_error(GLenum type, GLsizei stride, const GLvoid *ptr )
 {
    GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 
    update_array(ctx, VERT_ATTRIB_NORMAL, GL_RGBA, 3, 3, type, stride, GL_TRUE,
                 GL_FALSE, GL_FALSE, ptr);
@@ -660,8 +652,6 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const 
GLvoid *ptr )
 {
    GET_CURRENT_CONTEXT(ctx);
 
-   FLUSH_VERTICES(ctx, 0);
-
    GLenum format = GL_RGBA;
    const GLbitfield legalTypes = (ctx->API == API_OPENGLES)
       ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT)
@@ -686,7 +676,6 @@ _mesa_ColorPointer_no_error(GLint size, GLenum type, 
GLsizei stride,
                             const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 
    GLenum format = get_array_format(ctx, BGRA_OR_4, &size);
    update_array(ctx, VERT_ATTRIB_COLOR0, format, BGRA_OR_4, size,
@@ -700,8 +689,6 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, 
const GLvoid *ptr)
    GET_CURRENT_CONTEXT(ctx);
    const GLint sizeMin = (ctx->API == API_OPENGLES) ? 4 : 3;
 
-   FLUSH_VERTICES(ctx, 0);
-
    GLenum format = get_array_format(ctx, BGRA_OR_4, &size);
    const GLbitfield legalTypes = (ctx->API == API_OPENGLES)
       ? (UNSIGNED_BYTE_BIT | HALF_BIT | FLOAT_BIT | FIXED_ES_BIT)
@@ -728,7 +715,6 @@ void GLAPIENTRY
 _mesa_FogCoordPointer_no_error(GLenum type, GLsizei stride, const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 
    update_array(ctx, VERT_ATTRIB_FOG, GL_RGBA, 1, 1, type, stride, GL_FALSE,
                 GL_FALSE, GL_FALSE, ptr);
@@ -740,8 +726,6 @@ _mesa_FogCoordPointer(GLenum type, GLsizei stride, const 
GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
 
-   FLUSH_VERTICES(ctx, 0);
-
    GLenum format = GL_RGBA;
    const GLbitfield legalTypes = (HALF_BIT | FLOAT_BIT | DOUBLE_BIT);
 
@@ -760,7 +744,6 @@ void GLAPIENTRY
 _mesa_IndexPointer_no_error(GLenum type, GLsizei stride, const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 
    update_array(ctx, VERT_ATTRIB_COLOR_INDEX, GL_RGBA, 1, 1, type, stride,
                 GL_FALSE, GL_FALSE, GL_FALSE, ptr);
@@ -772,8 +755,6 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const 
GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
 
-   FLUSH_VERTICES(ctx, 0);
-
    GLenum format = GL_RGBA;
    const GLbitfield legalTypes = (UNSIGNED_BYTE_BIT | SHORT_BIT | INT_BIT |
                                      FLOAT_BIT | DOUBLE_BIT);
@@ -795,7 +776,6 @@ _mesa_SecondaryColorPointer_no_error(GLint size, GLenum 
type,
                                      GLsizei stride, const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 
    GLenum format = get_array_format(ctx, BGRA_OR_4, &size);
    update_array(ctx, VERT_ATTRIB_COLOR1, format, BGRA_OR_4, size, type,
@@ -809,8 +789,6 @@ _mesa_SecondaryColorPointer(GLint size, GLenum type,
 {
    GET_CURRENT_CONTEXT(ctx);
 
-   FLUSH_VERTICES(ctx, 0);
-
    GLenum format = get_array_format(ctx, BGRA_OR_4, &size);
    const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT |
                                   SHORT_BIT | UNSIGNED_SHORT_BIT |
@@ -837,7 +815,6 @@ _mesa_TexCoordPointer_no_error(GLint size, GLenum type, 
GLsizei stride,
 {
    GET_CURRENT_CONTEXT(ctx);
    const GLuint unit = ctx->Array.ActiveTexture;
-   FLUSH_VERTICES(ctx, 0);
 
    update_array(ctx, VERT_ATTRIB_TEX(unit), GL_RGBA, 4, size, type,
                 stride, GL_FALSE, GL_FALSE, GL_FALSE, ptr);
@@ -852,8 +829,6 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei 
stride,
    const GLint sizeMin = (ctx->API == API_OPENGLES) ? 2 : 1;
    const GLuint unit = ctx->Array.ActiveTexture;
 
-   FLUSH_VERTICES(ctx, 0);
-
    GLenum format = GL_RGBA;
    const GLbitfield legalTypes = (ctx->API == API_OPENGLES)
       ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT)
@@ -880,7 +855,6 @@ _mesa_EdgeFlagPointer_no_error(GLsizei stride, const GLvoid 
*ptr)
    /* this is the same type that glEdgeFlag uses */
    const GLboolean integer = GL_FALSE;
    GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 
    update_array(ctx, VERT_ATTRIB_EDGEFLAG, GL_RGBA, 1, 1, GL_UNSIGNED_BYTE,
                 stride, GL_FALSE, integer, GL_FALSE, ptr);
@@ -894,8 +868,6 @@ _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr)
    const GLboolean integer = GL_FALSE;
    GET_CURRENT_CONTEXT(ctx);
 
-   FLUSH_VERTICES(ctx, 0);
-
    GLenum format = GL_RGBA;
    const GLbitfield legalTypes = UNSIGNED_BYTE_BIT;
 
@@ -916,7 +888,6 @@ _mesa_PointSizePointerOES_no_error(GLenum type, GLsizei 
stride,
                                    const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 
    update_array(ctx, VERT_ATTRIB_POINT_SIZE, GL_RGBA, 1, 1, type, stride,
                 GL_FALSE, GL_FALSE, GL_FALSE, ptr);
@@ -928,8 +899,6 @@ _mesa_PointSizePointerOES(GLenum type, GLsizei stride, 
const GLvoid *ptr)
 {
    GET_CURRENT_CONTEXT(ctx);
 
-   FLUSH_VERTICES(ctx, 0);
-
    GLenum format = GL_RGBA;
    if (ctx->API != API_OPENGLES) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -1097,11 +1066,11 @@ _mesa_enable_vertex_array_attrib(struct gl_context *ctx,
 
    if (!vao->VertexAttrib[attrib].Enabled) {
       /* was disabled, now being enabled */
-      FLUSH_VERTICES(ctx, _NEW_ARRAY);
       vao->VertexAttrib[attrib].Enabled = GL_TRUE;
       const GLbitfield array_bit = VERT_BIT(attrib);
       vao->_Enabled |= array_bit;
       vao->NewArrays |= array_bit;
+      ctx->NewState |= _NEW_ARRAY;
 
       /* Update the map mode if needed */
       if (array_bit & (VERT_BIT_POS|VERT_BIT_GENERIC0))
@@ -1181,11 +1150,11 @@ _mesa_disable_vertex_array_attrib(struct gl_context 
*ctx,
 
    if (vao->VertexAttrib[attrib].Enabled) {
       /* was enabled, now being disabled */
-      FLUSH_VERTICES(ctx, _NEW_ARRAY);
       vao->VertexAttrib[attrib].Enabled = GL_FALSE;
       const GLbitfield array_bit = VERT_BIT(attrib);
       vao->_Enabled &= ~array_bit;
       vao->NewArrays |= array_bit;
+      ctx->NewState |= _NEW_ARRAY;
 
       /* Update the map mode if needed */
       if (array_bit & (VERT_BIT_POS|VERT_BIT_GENERIC0))
@@ -1706,8 +1675,6 @@ _mesa_InterleavedArrays(GLenum format, GLsizei stride, 
const GLvoid *pointer)
    GLint defstride;                /* default stride */
    GLint c, f;
 
-   FLUSH_VERTICES(ctx, 0);
-
    f = sizeof(GLfloat);
    c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f);
 
@@ -2499,8 +2466,6 @@ vertex_attrib_format(GLuint attribIndex, GLint size, 
GLenum type,
       }
    }
 
-   FLUSH_VERTICES(ctx, 0);
-
    _mesa_update_array_format(ctx, ctx->Array.VAO,
                              VERT_ATTRIB_GENERIC(attribIndex), size, type,
                              format, normalized, integer, doubles,
@@ -2589,8 +2554,6 @@ vertex_array_attrib_format(GLuint vaobj, GLuint 
attribIndex, GLint size,
       }
    }
 
-   FLUSH_VERTICES(ctx, 0);
-
    _mesa_update_array_format(ctx, vao, VERT_ATTRIB_GENERIC(attribIndex), size,
                              type, format, normalized, integer, doubles,
                              relativeOffset);
-- 
2.14.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to