From 9c7be67968aaba224d518dee86dff736a4b599c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mathias=20Fr=C3=B6hlich?= Date: Sun, 13 May 2018 09:18:57 +0200 Subject: [PATCH] mesa: Remove FLUSH_VERTICES from VAO state changes. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. Reviewed-by: Brian Paul Signed-off-by: Mathias Fröhlich --- src/mesa/main/varray.c | 65 ++++-------------------------------------- 1 file changed, 6 insertions(+), 59 deletions(-) diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index d16807b406c..2ced74a76c3 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -172,16 +172,13 @@ _mesa_vertex_attrib_binding(struct gl_context *ctx, else vao->VertexAttribBufferMask &= ~array_bit; - if (flush_vertices) { - 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; } } @@ -204,9 +201,6 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx, if (binding->BufferObj != vbo || binding->Offset != offset || binding->Stride != stride) { - if (flush_vertices) { - FLUSH_VERTICES(ctx, _NEW_ARRAY); - } _mesa_reference_buffer_object(ctx, &binding->BufferObj, vbo); @@ -219,6 +213,7 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx, vao->VertexAttribBufferMask |= binding->_BoundArrays; vao->NewArrays |= vao->_Enabled & binding->_BoundArrays; + ctx->NewState |= _NEW_ARRAY; } } @@ -238,9 +233,9 @@ vertex_binding_divisor(struct gl_context *ctx, assert(!vao->SharedAndImmutable); if (binding->InstanceDivisor != divisor) { - FLUSH_VERTICES(ctx, _NEW_ARRAY); binding->InstanceDivisor = divisor; vao->NewArrays |= vao->_Enabled & binding->_BoundArrays; + ctx->NewState |= _NEW_ARRAY; } } @@ -322,8 +317,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, @@ -623,7 +616,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); @@ -635,8 +627,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) @@ -660,7 +650,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); @@ -672,8 +661,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) @@ -698,7 +685,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, @@ -712,8 +698,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) @@ -740,7 +724,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); @@ -752,8 +735,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); @@ -772,7 +753,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); @@ -784,8 +764,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); @@ -807,7 +785,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, @@ -821,8 +798,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 | @@ -849,7 +824,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); @@ -864,8 +838,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) @@ -892,7 +864,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); @@ -906,8 +877,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; @@ -928,7 +897,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); @@ -940,8 +908,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, @@ -1110,14 +1076,11 @@ _mesa_enable_vertex_array_attrib(struct gl_context *ctx, if (!vao->VertexAttrib[attrib].Enabled) { /* was disabled, now being enabled */ - if (flush_vertices) { - 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)) @@ -1200,14 +1163,11 @@ _mesa_disable_vertex_array_attrib(struct gl_context *ctx, if (vao->VertexAttrib[attrib].Enabled) { /* was enabled, now being disabled */ - if (flush_vertices) { - 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)) @@ -1728,8 +1688,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); @@ -1899,8 +1857,6 @@ _mesa_LockArraysEXT(GLint first, GLsizei count) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glLockArrays %d %d\n", first, count); @@ -1929,8 +1885,6 @@ _mesa_UnlockArraysEXT( void ) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, 0); - if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glUnlockArrays\n"); @@ -1991,10 +1945,7 @@ _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, static void primitive_restart_index(struct gl_context *ctx, GLuint index) { - if (ctx->Array.RestartIndex != index) { - FLUSH_VERTICES(ctx, 0); - ctx->Array.RestartIndex = index; - } + ctx->Array.RestartIndex = index; } @@ -2521,8 +2472,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, @@ -2611,8 +2560,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.30.2