[Mesa-dev] [PATCH 01/11] mesa: Add flush_vertices argument to _mesa_bind_vertex_buffer.

Mathias.Froehlich at gmx.net Mathias.Froehlich at gmx.net
Fri Jun 17 18:03:53 UTC 2016


From: Mathias Fröhlich <mathias.froehlich at web.de>

Similar to _mesa_update_array_format add an argument to
avoid calling FLUSH_VERTICES in certain cases.
This will be used with the following change.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
 src/mesa/drivers/common/meta.c | 16 +++++++++-------
 src/mesa/main/varray.c         | 16 ++++++++++------
 src/mesa/main/varray.h         |  2 +-
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index be671b4..5962aaa 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -328,7 +328,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
                                    GL_FALSE, GL_FALSE,
                                    offsetof(struct vertex, x), true);
          _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(0),
-                                  *buf_obj, 0, sizeof(struct vertex));
+                                  *buf_obj, 0, sizeof(struct vertex), true);
          _mesa_enable_vertex_array_attrib(ctx, array_obj,
                                           VERT_ATTRIB_GENERIC(0));
          if (texcoord_size > 0) {
@@ -337,7 +337,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
                                       GL_FALSE, GL_FALSE, GL_FALSE,
                                       offsetof(struct vertex, tex), false);
             _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
-                                     *buf_obj, 0, sizeof(struct vertex));
+                                     *buf_obj, 0, sizeof(struct vertex), true);
             _mesa_enable_vertex_array_attrib(ctx, array_obj,
                                              VERT_ATTRIB_GENERIC(1));
          }
@@ -347,7 +347,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
                                    GL_FALSE, GL_FALSE,
                                    offsetof(struct vertex, x), true);
          _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
-                                  *buf_obj, 0, sizeof(struct vertex));
+                                  *buf_obj, 0, sizeof(struct vertex), true);
          _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
 
          if (texcoord_size > 0) {
@@ -356,7 +356,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
                                       GL_FALSE, GL_FALSE,
                                       offsetof(struct vertex, tex), false);
             _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(0),
-                                     *buf_obj, 0, sizeof(struct vertex));
+                                     *buf_obj, 0, sizeof(struct vertex), true);
             _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_TEX(0));
          }
 
@@ -366,7 +366,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
                                       GL_FALSE, GL_FALSE,
                                       offsetof(struct vertex, r), false);
             _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_COLOR0,
-                                     *buf_obj, 0, sizeof(struct vertex));
+                                     *buf_obj, 0, sizeof(struct vertex), true);
             _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_COLOR0);
          }
       }
@@ -3325,7 +3325,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
                                 GL_FALSE, GL_FALSE,
                                 offsetof(struct vertex, x), true);
       _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
-                               drawtex->buf_obj, 0, sizeof(struct vertex));
+                               drawtex->buf_obj, 0,
+                               sizeof(struct vertex), true);
       _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
 
 
@@ -3335,7 +3336,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
                                    GL_FALSE, GL_FALSE,
                                    offsetof(struct vertex, st[i]), true);
          _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(i),
-                                  drawtex->buf_obj, 0, sizeof(struct vertex));
+                                  drawtex->buf_obj, 0,
+                                  sizeof(struct vertex), true);
          _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_TEX(i));
       }
    }
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index c2bf295..5cd7324 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -164,7 +164,7 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
                          struct gl_vertex_array_object *vao,
                          GLuint index,
                          struct gl_buffer_object *vbo,
-                         GLintptr offset, GLsizei stride)
+                         GLintptr offset, GLsizei stride, bool flush_vertices)
 {
    struct gl_vertex_buffer_binding *binding = &vao->VertexBinding[index];
 
@@ -172,7 +172,11 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
        binding->Offset != offset ||
        binding->Stride != stride) {
 
-      FLUSH_VERTICES(ctx, _NEW_ARRAY);
+      if (flush_vertices) {
+         FLUSH_VERTICES(ctx, _NEW_ARRAY);
+      } else {
+         ctx->NewState |= _NEW_ARRAY;
+      }
 
       _mesa_reference_buffer_object(ctx, &binding->BufferObj, vbo);
 
@@ -533,7 +537,7 @@ update_array(struct gl_context *ctx,
    effectiveStride = stride != 0 ? stride : array->_ElementSize;
    _mesa_bind_vertex_buffer(ctx, ctx->Array.VAO, attrib,
                             ctx->Array.ArrayBufferObj, (GLintptr) ptr,
-                            effectiveStride);
+                            effectiveStride, true);
 }
 
 
@@ -1770,7 +1774,7 @@ vertex_array_vertex_buffer(struct gl_context *ctx,
    }
 
    _mesa_bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(bindingIndex),
-                            vbo, offset, stride);
+                            vbo, offset, stride, true);
 }
 
 
@@ -1858,7 +1862,7 @@ vertex_array_vertex_buffers(struct gl_context *ctx,
 
       for (i = 0; i < count; i++)
          _mesa_bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(first + i),
-                                  vbo, 0, 16);
+                                  vbo, 0, 16, true);
 
       return;
    }
@@ -1930,7 +1934,7 @@ vertex_array_vertex_buffers(struct gl_context *ctx,
       }
 
       _mesa_bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(first + i),
-                               vbo, offsets[i], strides[i]);
+                               vbo, offsets[i], strides[i], true);
    }
 
    _mesa_end_bufferobj_lookups(ctx);
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index a766afa..18bfe19 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -108,7 +108,7 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
                          struct gl_vertex_array_object *vao,
                          GLuint index,
                          struct gl_buffer_object *vbo,
-                         GLintptr offset, GLsizei stride);
+                         GLintptr offset, GLsizei stride, bool flush_vertices);
 
 extern void GLAPIENTRY
 _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride,
-- 
2.5.5



More information about the mesa-dev mailing list