vbo: rewrite some code in playback_copy_to_current()
authorBrian Paul <brianp@vmware.com>
Fri, 12 Jan 2018 20:17:10 +0000 (13:17 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 17 Jan 2018 18:17:56 +0000 (11:17 -0700)
I think this is a little easier to understand.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/vbo/vbo_save_draw.c

index ee7f509b6cb6aeb0965ba3832a87ec4d6578a197..1694a04a3e10092dfdf8b839e31fb99801a953cb 100644 (file)
@@ -51,7 +51,6 @@ playback_copy_to_current(struct gl_context *ctx,
    fi_type vertex[VBO_ATTRIB_MAX * 4];
    fi_type *data;
    GLbitfield64 mask;
-   GLuint offset;
 
    if (node->current_size == 0)
       return;
@@ -60,14 +59,13 @@ playback_copy_to_current(struct gl_context *ctx,
       data = node->current_data;
    }
    else {
-      data = vertex;
+      /* Position of last vertex */
+      const GLuint pos = node->vertex_count > 0 ? node->vertex_count - 1 : 0;
+      /* Offset to last vertex in the vertex buffer */
+      const GLuint offset = node->buffer_offset
+         + pos * node->vertex_size * sizeof(GLfloat);
 
-      if (node->vertex_count)
-         offset = (node->buffer_offset +
-                   (node->vertex_count - 1)
-                   * node->vertex_size * sizeof(GLfloat));
-      else
-         offset = node->buffer_offset;
+      data = vertex;
 
       ctx->Driver.GetBufferSubData(ctx, offset,
                                    node->vertex_size * sizeof(GLfloat),