diff options
author | Marek Olšák <[email protected]> | 2020-02-18 19:05:17 -0500 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2020-03-04 19:54:42 -0500 |
commit | f97341a9d6d4377950e313e76f75230d80f6240d (patch) | |
tree | 003af94de83769a17c3c246a11131cb61af41c92 /src/mesa/vbo/vbo_exec.c | |
parent | 1be1ea0b8e2d5eed5202f669d11f5644fb4b5de2 (diff) |
vbo: clean up vbo_copy_vertices
Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Mathias Fröhlich <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4052>
Diffstat (limited to 'src/mesa/vbo/vbo_exec.c')
-rw-r--r-- | src/mesa/vbo/vbo_exec.c | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c index 627b4a262d8..afda3635fc9 100644 --- a/src/mesa/vbo/vbo_exec.c +++ b/src/mesa/vbo/vbo_exec.c @@ -250,27 +250,17 @@ vbo_copy_vertices(struct gl_context *ctx, case GL_POINTS: return 0; case GL_LINES: + copy = count % 2; + break; case GL_TRIANGLES: + copy = count % 3; + break; case GL_QUADS: - if (mode == GL_LINES) - copy = count % 2; - else if (mode == GL_TRIANGLES) - copy = count % 3; - else if (mode == GL_QUADS) - copy = count % 4; - - for (unsigned i = 0; i < copy; i++) { - memcpy(dst + i * vertex_size, src + (count - copy + i) * vertex_size, - vertex_size * sizeof(GLfloat)); - } - return copy; + copy = count % 4; + break; case GL_LINE_STRIP: - if (count == 0) - return 0; - - memcpy(dst, src + (count - 1) * vertex_size, - vertex_size * sizeof(GLfloat)); - return 1; + copy = MIN2(1, count); + break; case GL_LINE_LOOP: if (!in_dlist && last_prim->begin == 0) { /* We're dealing with the second or later section of a split/wrapped @@ -298,32 +288,23 @@ vbo_copy_vertices(struct gl_context *ctx, return 2; } case GL_TRIANGLE_STRIP: - /* no parity issue, but need to make sure the tri is not drawn twice */ - if (count & 1) { - last_prim->count--; - } + /* Draw an even number of triangles to keep front/back facing the same. */ + last_prim->count -= count % 2; /* fallthrough */ case GL_QUAD_STRIP: - switch (count) { - case 0: - copy = 0; - break; - case 1: - copy = 1; - break; - default: - copy = 2 + (count & 1); - break; - } - for (unsigned i = 0; i < copy; i++) { - memcpy(dst + i * vertex_size, src + (count - copy + i) * vertex_size, - vertex_size * sizeof(GLfloat)); - } - return copy; + if (count <= 1) + copy = count; + else + copy = 2 + (count % 2); + break; case PRIM_OUTSIDE_BEGIN_END: return 0; default: unreachable("Unexpected primitive type"); return 0; } + + memcpy(dst, src + (count - copy) * vertex_size, + copy * vertex_size * sizeof(GLfloat)); + return copy; } |