diff options
author | Brian Paul <brianp@vmware.com> | 2015-10-16 11:19:40 -0600 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2015-10-20 12:52:41 -0600 |
commit | 03d2f085394011f704f5702a92128b5677733c38 (patch) | |
tree | 4d57949c327d924c189bf5b607c75c3295d84e67 /src/mesa/vbo | |
parent | 002c5c1da3a2db60607fb184b9c6343415987fb5 (diff) | |
download | external_mesa3d-03d2f085394011f704f5702a92128b5677733c38.zip external_mesa3d-03d2f085394011f704f5702a92128b5677733c38.tar.gz external_mesa3d-03d2f085394011f704f5702a92128b5677733c38.tar.bz2 |
vbo: add new vbo_compute_max_verts() helper function
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Diffstat (limited to 'src/mesa/vbo')
-rw-r--r-- | src/mesa/vbo/vbo_context.h | 14 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec_api.c | 3 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec_draw.c | 3 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h index a376efe..1e85335 100644 --- a/src/mesa/vbo/vbo_context.h +++ b/src/mesa/vbo/vbo_context.h @@ -196,6 +196,20 @@ vbo_get_default_vals_as_union(GLenum format) } } + +/** + * Compute the max number of vertices which can be stored in + * a vertex buffer, given the current vertex size, and the amount + * of space already used. + */ +static inline unsigned +vbo_compute_max_verts(const struct vbo_exec_context *exec) +{ + return (VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / + (exec->vtx.vertex_size * sizeof(GLfloat)); +} + + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 3f87ac4..f26bf40 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -291,8 +291,7 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, */ exec->vtx.attrsz[attr] = newSize; exec->vtx.vertex_size += newSize - oldSize; - exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / - (exec->vtx.vertex_size * sizeof(GLfloat))); + exec->vtx.max_vert = vbo_compute_max_verts(exec); exec->vtx.vert_count = 0; exec->vtx.buffer_ptr = exec->vtx.buffer_map; diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 9b1103d..f6a1e4b 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -435,8 +435,7 @@ vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean keepUnmapped) if (keepUnmapped || exec->vtx.vertex_size == 0) exec->vtx.max_vert = 0; else - exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / - (exec->vtx.vertex_size * sizeof(GLfloat))); + exec->vtx.max_vert = vbo_compute_max_verts(exec); exec->vtx.buffer_ptr = exec->vtx.buffer_map; exec->vtx.prim_count = 0; |