diff options
author | Marek Olšák <[email protected]> | 2017-04-02 19:07:49 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-04-22 22:51:15 +0200 |
commit | 070072ad43bb41624d271f10697ea21a776b1ec1 (patch) | |
tree | 2f88efd83530f8a71e4dec1634378020a8826565 /src/mesa/vbo | |
parent | e137b9eed9501858e2037719a94aafee35179249 (diff) |
mesa: replace _mesa_index_buffer::type with index_size
This avoids repeated translations of the enum.
Reviewed-by: Ilia Mirkin <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/vbo')
-rw-r--r-- | src/mesa/vbo/vbo.h | 2 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec_array.c | 12 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_minmax_index.c | 35 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_primitive_restart.c | 4 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_rebase.c | 10 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_split_copy.c | 10 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_split_inplace.c | 4 |
7 files changed, 39 insertions, 38 deletions
diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index d62ab4e674b..79f75386f72 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -69,7 +69,7 @@ struct _mesa_prim { */ struct _mesa_index_buffer { GLuint count; - GLenum type; + unsigned index_size; struct gl_buffer_object *obj; const void *ptr; }; diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 1bf4b11da2e..aecfad02b7b 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -861,7 +861,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode, vbo_bind_arrays(ctx); ib.count = count; - ib.type = type; + ib.index_size = vbo_sizeof_ib_type(type); ib.obj = ctx->Array.VAO->IndexBufferObj; ib.ptr = indices; @@ -1297,7 +1297,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode, if (!fallback) { ib.count = (max_index_ptr - min_index_ptr) / index_type_size; - ib.type = type; + ib.index_size = vbo_sizeof_ib_type(type); ib.obj = ctx->Array.VAO->IndexBufferObj; ib.ptr = (void *) min_index_ptr; @@ -1330,7 +1330,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode, if (count[i] == 0) continue; ib.count = count[i]; - ib.type = type; + ib.index_size = vbo_sizeof_ib_type(type); ib.obj = ctx->Array.VAO->IndexBufferObj; ib.ptr = indices[i]; @@ -1574,7 +1574,7 @@ vbo_validated_drawelementsindirect(struct gl_context *ctx, vbo_bind_arrays(ctx); ib.count = 0; /* unknown */ - ib.type = type; + ib.index_size = vbo_sizeof_ib_type(type); ib.obj = ctx->Array.VAO->IndexBufferObj; ib.ptr = NULL; @@ -1606,7 +1606,7 @@ vbo_validated_multidrawelementsindirect(struct gl_context *ctx, /* NOTE: IndexBufferObj is guaranteed to be a VBO. */ ib.count = 0; /* unknown */ - ib.type = type; + ib.index_size = vbo_sizeof_ib_type(type); ib.obj = ctx->Array.VAO->IndexBufferObj; ib.ptr = NULL; @@ -1776,7 +1776,7 @@ vbo_validated_multidrawelementsindirectcount(struct gl_context *ctx, /* NOTE: IndexBufferObj is guaranteed to be a VBO. */ ib.count = 0; /* unknown */ - ib.type = type; + ib.index_size = vbo_sizeof_ib_type(type); ib.obj = ctx->Array.VAO->IndexBufferObj; ib.ptr = NULL; diff --git a/src/mesa/vbo/vbo_minmax_index.c b/src/mesa/vbo/vbo_minmax_index.c index 0f75a87f3f3..4c17a086628 100644 --- a/src/mesa/vbo/vbo_minmax_index.c +++ b/src/mesa/vbo/vbo_minmax_index.c @@ -38,7 +38,7 @@ struct minmax_cache_key { GLintptr offset; GLuint count; - GLenum type; + unsigned index_size; }; @@ -60,7 +60,8 @@ static bool vbo_minmax_cache_key_equal(const struct minmax_cache_key *a, const struct minmax_cache_key *b) { - return (a->offset == b->offset) && (a->count == b->count) && (a->type == b->type); + return (a->offset == b->offset) && (a->count == b->count) && + (a->index_size == b->index_size); } @@ -101,7 +102,7 @@ vbo_delete_minmax_cache(struct gl_buffer_object *bufferObj) static GLboolean vbo_get_minmax_cached(struct gl_buffer_object *bufferObj, - GLenum type, GLintptr offset, GLuint count, + unsigned index_size, GLintptr offset, GLuint count, GLuint *min_index, GLuint *max_index) { GLboolean found = GL_FALSE; @@ -137,7 +138,7 @@ vbo_get_minmax_cached(struct gl_buffer_object *bufferObj, goto out_invalidate; } - key.type = type; + key.index_size = index_size; key.offset = offset; key.count = count; hash = vbo_minmax_cache_hash(&key); @@ -173,7 +174,7 @@ out_disable: static void vbo_minmax_cache_store(struct gl_context *ctx, struct gl_buffer_object *bufferObj, - GLenum type, GLintptr offset, GLuint count, + unsigned index_size, GLintptr offset, GLuint count, GLuint min, GLuint max) { struct minmax_cache_entry *entry; @@ -200,7 +201,7 @@ vbo_minmax_cache_store(struct gl_context *ctx, entry->key.offset = offset; entry->key.count = count; - entry->key.type = type; + entry->key.index_size = index_size; entry->min = min; entry->max = max; hash = vbo_minmax_cache_hash(&entry->key); @@ -240,17 +241,17 @@ vbo_get_minmax_index(struct gl_context *ctx, const GLuint count) { const GLboolean restart = ctx->Array._PrimitiveRestart; - const GLuint restartIndex = _mesa_primitive_restart_index(ctx, ib->type); - const int index_size = vbo_sizeof_ib_type(ib->type); + const GLuint restartIndex = + _mesa_primitive_restart_index(ctx, ib->index_size); const char *indices; GLuint i; - indices = (char *) ib->ptr + prim->start * index_size; + indices = (char *) ib->ptr + prim->start * ib->index_size; if (_mesa_is_bufferobj(ib->obj)) { - GLsizeiptr size = MIN2(count * index_size, ib->obj->Size); + GLsizeiptr size = MIN2(count * ib->index_size, ib->obj->Size); - if (vbo_get_minmax_cached(ib->obj, ib->type, (GLintptr) indices, count, - min_index, max_index)) + if (vbo_get_minmax_cached(ib->obj, ib->index_size, (GLintptr) indices, + count, min_index, max_index)) return; indices = ctx->Driver.MapBufferRange(ctx, (GLintptr) indices, size, @@ -258,8 +259,8 @@ vbo_get_minmax_index(struct gl_context *ctx, MAP_INTERNAL); } - switch (ib->type) { - case GL_UNSIGNED_INT: { + switch (ib->index_size) { + case 4: { const GLuint *ui_indices = (const GLuint *)indices; GLuint max_ui = 0; GLuint min_ui = ~0U; @@ -287,7 +288,7 @@ vbo_get_minmax_index(struct gl_context *ctx, *max_index = max_ui; break; } - case GL_UNSIGNED_SHORT: { + case 2: { const GLushort *us_indices = (const GLushort *)indices; GLuint max_us = 0; GLuint min_us = ~0U; @@ -309,7 +310,7 @@ vbo_get_minmax_index(struct gl_context *ctx, *max_index = max_us; break; } - case GL_UNSIGNED_BYTE: { + case 1: { const GLubyte *ub_indices = (const GLubyte *)indices; GLuint max_ub = 0; GLuint min_ub = ~0U; @@ -336,7 +337,7 @@ vbo_get_minmax_index(struct gl_context *ctx, } if (_mesa_is_bufferobj(ib->obj)) { - vbo_minmax_cache_store(ctx, ib->obj, ib->type, prim->start, count, + vbo_minmax_cache_store(ctx, ib->obj, ib->index_size, prim->start, count, *min_index, *max_index); ctx->Driver.UnmapBuffer(ctx, ib->obj, MAP_INTERNAL); } diff --git a/src/mesa/vbo/vbo_primitive_restart.c b/src/mesa/vbo/vbo_primitive_restart.c index 0662c5cd4ef..8f04def377c 100644 --- a/src/mesa/vbo/vbo_primitive_restart.c +++ b/src/mesa/vbo/vbo_primitive_restart.c @@ -175,7 +175,7 @@ vbo_sw_primitive_restart(struct gl_context *ctx, GLuint sub_prim_num; GLuint end_index; GLuint sub_end_index; - GLuint restart_index = _mesa_primitive_restart_index(ctx, ib->type); + GLuint restart_index = _mesa_primitive_restart_index(ctx, ib->index_size); struct _mesa_prim temp_prim; struct vbo_context *vbo = vbo_context(ctx); vbo_draw_func draw_prims_func = vbo->draw_prims; @@ -226,7 +226,7 @@ vbo_sw_primitive_restart(struct gl_context *ctx, ptr = ADD_POINTERS(ib->obj->Mappings[MAP_INTERNAL].Pointer, ib->ptr); - sub_prims = find_sub_primitives(ptr, vbo_sizeof_ib_type(ib->type), + sub_prims = find_sub_primitives(ptr, ib->index_size, 0, ib->count, restart_index, &num_sub_prims); diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c index f40c59fdf35..9f5dc4678f8 100644 --- a/src/mesa/vbo/vbo_rebase.c +++ b/src/mesa/vbo/vbo_rebase.c @@ -182,14 +182,14 @@ void vbo_rebase_prims( struct gl_context *ctx, /* Some users might prefer it if we translated elements to * GLuints here. Others wouldn't... */ - switch (ib->type) { - case GL_UNSIGNED_INT: + switch (ib->index_size) { + case 4: tmp_indices = rebase_GLuint( ptr, ib->count, min_index ); break; - case GL_UNSIGNED_SHORT: + case 2: tmp_indices = rebase_GLushort( ptr, ib->count, min_index ); break; - case GL_UNSIGNED_BYTE: + case 1: tmp_indices = rebase_GLubyte( ptr, ib->count, min_index ); break; } @@ -204,7 +204,7 @@ void vbo_rebase_prims( struct gl_context *ctx, tmp_ib.obj = ctx->Shared->NullBufferObj; tmp_ib.ptr = tmp_indices; tmp_ib.count = ib->count; - tmp_ib.type = ib->type; + tmp_ib.index_size = ib->index_size; ib = &tmp_ib; } diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index ce8831dbb0c..8e35e44a2fb 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -479,8 +479,8 @@ replay_init( struct copy_context *copy ) ADD_POINTERS(copy->ib->obj->Mappings[MAP_INTERNAL].Pointer, copy->ib->ptr); - switch (copy->ib->type) { - case GL_UNSIGNED_BYTE: + switch (copy->ib->index_size) { + case 1: copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count); copy->srcelt = copy->translated_elt_buf; @@ -488,7 +488,7 @@ replay_init( struct copy_context *copy ) copy->translated_elt_buf[i] = ((const GLubyte *)srcptr)[i]; break; - case GL_UNSIGNED_SHORT: + case 2: copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count); copy->srcelt = copy->translated_elt_buf; @@ -496,7 +496,7 @@ replay_init( struct copy_context *copy ) copy->translated_elt_buf[i] = ((const GLushort *)srcptr)[i]; break; - case GL_UNSIGNED_INT: + case 4: copy->translated_elt_buf = NULL; copy->srcelt = (const GLuint *)srcptr; break; @@ -551,7 +551,7 @@ replay_init( struct copy_context *copy ) * list: */ copy->dstib.count = 0; /* duplicates dstelt_nr */ - copy->dstib.type = GL_UNSIGNED_INT; + copy->dstib.index_size = 4; copy->dstib.obj = ctx->Shared->NullBufferObj; copy->dstib.ptr = copy->dstelt; } diff --git a/src/mesa/vbo/vbo_split_inplace.c b/src/mesa/vbo/vbo_split_inplace.c index 1430ac98960..9c5c288700f 100644 --- a/src/mesa/vbo/vbo_split_inplace.c +++ b/src/mesa/vbo/vbo_split_inplace.c @@ -75,7 +75,7 @@ static void flush_vertex( struct split_context *split ) ib.count = split->max_index - split->min_index + 1; ib.ptr = (const void *)((const char *)ib.ptr + - split->min_index * _mesa_sizeof_type(ib.type)); + split->min_index * ib.index_size); /* Rebase the primitives to save index buffer entries. */ for (i = 0; i < split->dstprim_nr; i++) @@ -223,7 +223,7 @@ static void split_prims( struct split_context *split) elts[j] = prim->start + j; ib.count = count; - ib.type = GL_UNSIGNED_INT; + ib.index_size = 4; ib.obj = split->ctx->Shared->NullBufferObj; ib.ptr = elts; |