summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2016-05-29 10:13:22 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2016-05-29 10:13:22 +0000
commit32d5319a7313a52d6060e52c0d9f70987ab68b28 (patch)
treead39f75372ade74f818b47f73e223e5a75532c9f
parent055b89bfed6f2b29a15e7d9b5a48ea4024a02fff (diff)
Import Mesa 11.2.2
-rw-r--r--lib/mesa/src/mesa/vbo/vbo_minmax_index.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/lib/mesa/src/mesa/vbo/vbo_minmax_index.c b/lib/mesa/src/mesa/vbo/vbo_minmax_index.c
index 1377926bb..0f75a87f3 100644
--- a/lib/mesa/src/mesa/vbo/vbo_minmax_index.c
+++ b/lib/mesa/src/mesa/vbo/vbo_minmax_index.c
@@ -38,7 +38,7 @@
struct minmax_cache_key {
GLintptr offset;
GLuint count;
- unsigned index_size;
+ GLenum type;
};
@@ -60,8 +60,7 @@ 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->index_size == b->index_size);
+ return (a->offset == b->offset) && (a->count == b->count) && (a->type == b->type);
}
@@ -102,7 +101,7 @@ vbo_delete_minmax_cache(struct gl_buffer_object *bufferObj)
static GLboolean
vbo_get_minmax_cached(struct gl_buffer_object *bufferObj,
- unsigned index_size, GLintptr offset, GLuint count,
+ GLenum type, GLintptr offset, GLuint count,
GLuint *min_index, GLuint *max_index)
{
GLboolean found = GL_FALSE;
@@ -138,7 +137,7 @@ vbo_get_minmax_cached(struct gl_buffer_object *bufferObj,
goto out_invalidate;
}
- key.index_size = index_size;
+ key.type = type;
key.offset = offset;
key.count = count;
hash = vbo_minmax_cache_hash(&key);
@@ -174,7 +173,7 @@ out_disable:
static void
vbo_minmax_cache_store(struct gl_context *ctx,
struct gl_buffer_object *bufferObj,
- unsigned index_size, GLintptr offset, GLuint count,
+ GLenum type, GLintptr offset, GLuint count,
GLuint min, GLuint max)
{
struct minmax_cache_entry *entry;
@@ -201,7 +200,7 @@ vbo_minmax_cache_store(struct gl_context *ctx,
entry->key.offset = offset;
entry->key.count = count;
- entry->key.index_size = index_size;
+ entry->key.type = type;
entry->min = min;
entry->max = max;
hash = vbo_minmax_cache_hash(&entry->key);
@@ -241,28 +240,26 @@ 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->index_size);
+ const GLuint restartIndex = _mesa_primitive_restart_index(ctx, ib->type);
+ const int index_size = vbo_sizeof_ib_type(ib->type);
const char *indices;
GLuint i;
- GLintptr offset = 0;
- indices = (char *) ib->ptr + prim->start * ib->index_size;
+ indices = (char *) ib->ptr + prim->start * index_size;
if (_mesa_is_bufferobj(ib->obj)) {
- GLsizeiptr size = MIN2(count * ib->index_size, ib->obj->Size);
+ GLsizeiptr size = MIN2(count * index_size, ib->obj->Size);
- if (vbo_get_minmax_cached(ib->obj, ib->index_size, (GLintptr) indices,
- count, min_index, max_index))
+ if (vbo_get_minmax_cached(ib->obj, ib->type, (GLintptr) indices, count,
+ min_index, max_index))
return;
- offset = (GLintptr) indices;
- indices = ctx->Driver.MapBufferRange(ctx, offset, size,
+ indices = ctx->Driver.MapBufferRange(ctx, (GLintptr) indices, size,
GL_MAP_READ_BIT, ib->obj,
MAP_INTERNAL);
}
- switch (ib->index_size) {
- case 4: {
+ switch (ib->type) {
+ case GL_UNSIGNED_INT: {
const GLuint *ui_indices = (const GLuint *)indices;
GLuint max_ui = 0;
GLuint min_ui = ~0U;
@@ -290,7 +287,7 @@ vbo_get_minmax_index(struct gl_context *ctx,
*max_index = max_ui;
break;
}
- case 2: {
+ case GL_UNSIGNED_SHORT: {
const GLushort *us_indices = (const GLushort *)indices;
GLuint max_us = 0;
GLuint min_us = ~0U;
@@ -312,7 +309,7 @@ vbo_get_minmax_index(struct gl_context *ctx,
*max_index = max_us;
break;
}
- case 1: {
+ case GL_UNSIGNED_BYTE: {
const GLubyte *ub_indices = (const GLubyte *)indices;
GLuint max_ub = 0;
GLuint min_ub = ~0U;
@@ -339,8 +336,8 @@ vbo_get_minmax_index(struct gl_context *ctx,
}
if (_mesa_is_bufferobj(ib->obj)) {
- vbo_minmax_cache_store(ctx, ib->obj, ib->index_size, offset,
- count, *min_index, *max_index);
+ vbo_minmax_cache_store(ctx, ib->obj, ib->type, prim->start, count,
+ *min_index, *max_index);
ctx->Driver.UnmapBuffer(ctx, ib->obj, MAP_INTERNAL);
}
}