diff options
author | Mathias Fröhlich <mathias.froehlich@web.de> | 2018-02-25 18:01:07 +0100 |
---|---|---|
committer | Mathias Fröhlich <mathias.froehlich@web.de> | 2018-03-01 04:06:23 +0100 |
commit | 478a9bc7bb6870993e2a8df97b2dab1d4e45a723 (patch) | |
tree | ed9ff58028f28cd40953f8a5d00246dc82e34e71 /src | |
parent | bfa8d8e5bf5a2f2f5b727acde0b4dad34d0c4210 (diff) |
vbo: Remove vbo_save_vertex_list::buffer_offset.
The buffer_offset is used in aligned_vertex_buffer_offset.
But now that most of these decisions are done in compile_vertex_list
we can work on local variables instead of struct members in the
display list code. Clean that up and remove buffer_offset.
Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/vbo/vbo_save.h | 14 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_save_api.c | 28 |
2 files changed, 13 insertions, 29 deletions
diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h index 51ca3c2614d..a9834d6e6d4 100644 --- a/src/mesa/vbo/vbo_save.h +++ b/src/mesa/vbo/vbo_save.h @@ -70,7 +70,6 @@ struct vbo_save_vertex_list { */ fi_type *current_data; - GLuint buffer_offset; /**< in bytes */ GLuint vertex_count; /**< number of vertices in this list */ GLuint wrap_count; /* number of copied vertices at start */ @@ -82,19 +81,6 @@ struct vbo_save_vertex_list { /** - * Is the vertex list's buffer offset an exact multiple of the - * vertex size (in bytes)? This is used to check for a vertex array / - * drawing optimization. - */ -static inline bool -aligned_vertex_buffer_offset(const struct vbo_save_vertex_list *node) -{ - unsigned vertex_size = node->vertex_size * sizeof(GLfloat); /* in bytes */ - return vertex_size != 0 && node->buffer_offset % vertex_size == 0; -} - - -/** * Return the stride in bytes of the display list node. */ static inline GLsizei diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index e8d027f15cb..e6cd04281e3 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -527,7 +527,6 @@ compile_vertex_list(struct gl_context *ctx) { struct vbo_save_context *save = &vbo_context(ctx)->save; struct vbo_save_vertex_list *node; - GLintptr buffer_offset = 0; /* Allocate space for this structure in the display list currently * being compiled. @@ -543,10 +542,12 @@ compile_vertex_list(struct gl_context *ctx) /* Duplicate our template, increment refcounts to the storage structs: */ + const GLsizei stride = save->vertex_size*sizeof(GLfloat); node->vertex_size = save->vertex_size; - node->buffer_offset = - (save->buffer_map - save->vertex_store->buffer_map) * sizeof(GLfloat); - if (aligned_vertex_buffer_offset(node)) { + GLintptr buffer_offset = + (save->buffer_map - save->vertex_store->buffer_map) * sizeof(GLfloat); + GLuint start_offset = 0; + if (0 < buffer_offset && 0 < stride && buffer_offset % stride == 0) { /* The vertex size is an exact multiple of the buffer offset. * This means that we can use zero-based vertex attribute pointers * and specify the start of the primitive with the _mesa_prim::start @@ -555,9 +556,11 @@ compile_vertex_list(struct gl_context *ctx) * changes in drivers. In particular, the Gallium CSO module will * filter out redundant vertex buffer changes. */ + /* We cannot immediately update the primitives as some methods below + * still need the uncorrected start vertices + */ + start_offset = buffer_offset/stride; buffer_offset = 0; - } else { - buffer_offset = node->buffer_offset; } GLuint offsets[VBO_ATTRIB_MAX]; for (unsigned i = 0, offset = 0; i < VBO_ATTRIB_MAX; ++i) { @@ -596,7 +599,7 @@ compile_vertex_list(struct gl_context *ctx) if (current_size) { node->current_data = malloc(current_size * sizeof(GLfloat)); if (node->current_data) { - const char *buffer = (const char *) save->vertex_store->buffer_map; + const char *buffer = (const char *)save->buffer_map; unsigned attr_offset = save->attrsz[0] * sizeof(GLfloat); unsigned vertex_offset = 0; @@ -604,8 +607,7 @@ compile_vertex_list(struct gl_context *ctx) vertex_offset = (node->vertex_count - 1) * node->vertex_size * sizeof(GLfloat); - memcpy(node->current_data, - buffer + node->buffer_offset + vertex_offset + attr_offset, + memcpy(node->current_data, buffer + vertex_offset + attr_offset, current_size * sizeof(GLfloat)); } else { _mesa_error(ctx, GL_OUT_OF_MEMORY, "Current value allocation"); @@ -636,12 +638,8 @@ compile_vertex_list(struct gl_context *ctx) * On the other hand the _vbo_loopback_vertex_list call below needs the * primitves to be corrected already. */ - if (aligned_vertex_buffer_offset(node)) { - const unsigned start_offset = - node->buffer_offset / (node->vertex_size * sizeof(GLfloat)); - for (unsigned i = 0; i < node->prim_count; i++) { - node->prims[i].start += start_offset; - } + for (unsigned i = 0; i < node->prim_count; i++) { + node->prims[i].start += start_offset; } /* Deal with GL_COMPILE_AND_EXECUTE: |