mesa: remove no longer needed _mesa_is_bufferobj function
[mesa.git] / src / mesa / vbo / vbo_minmax_index.c
index 58a2af49aca7d5d9ae169890ee2a3357f4f4e483..f66ed3dee392b22fc36701b82418acca3e7b6907 100644 (file)
@@ -115,7 +115,7 @@ vbo_get_minmax_cached(struct gl_buffer_object *bufferObj,
    if (!vbo_use_minmax_cache(bufferObj))
       return GL_FALSE;
 
-   mtx_lock(&bufferObj->Mutex);
+   simple_mtx_lock(&bufferObj->MinMaxCacheMutex);
 
    if (bufferObj->MinMaxCacheDirty) {
       /* Disable the cache permanently for this BO if the number of hits
@@ -166,7 +166,7 @@ out_invalidate:
    }
 
 out_disable:
-   mtx_unlock(&bufferObj->Mutex);
+   simple_mtx_unlock(&bufferObj->MinMaxCacheMutex);
    return found;
 }
 
@@ -184,7 +184,7 @@ vbo_minmax_cache_store(struct gl_context *ctx,
    if (!vbo_use_minmax_cache(bufferObj))
       return;
 
-   mtx_lock(&bufferObj->Mutex);
+   simple_mtx_lock(&bufferObj->MinMaxCacheMutex);
 
    if (!bufferObj->MinMaxCache) {
       bufferObj->MinMaxCache =
@@ -223,7 +223,7 @@ vbo_minmax_cache_store(struct gl_context *ctx,
       free(entry);
 
 out:
-   mtx_unlock(&bufferObj->Mutex);
+   simple_mtx_unlock(&bufferObj->MinMaxCacheMutex);
 }
 
 
@@ -242,27 +242,27 @@ vbo_get_minmax_index(struct gl_context *ctx,
 {
    const GLboolean restart = ctx->Array._PrimitiveRestart;
    const GLuint restartIndex =
-      _mesa_primitive_restart_index(ctx, ib->index_size);
+      _mesa_primitive_restart_index(ctx, 1 << ib->index_size_shift);
    const char *indices;
    GLuint i;
    GLintptr offset = 0;
 
-   indices = (char *) ib->ptr + prim->start * ib->index_size;
-   if (_mesa_is_bufferobj(ib->obj)) {
-      GLsizeiptr size = MIN2(count * ib->index_size, ib->obj->Size);
+   indices = (char *) ib->ptr + (prim->start << ib->index_size_shift);
+   if (ib->obj) {
+      GLsizeiptr size = MIN2(count << ib->index_size_shift, ib->obj->Size);
 
-      if (vbo_get_minmax_cached(ib->obj, ib->index_size, (GLintptr) indices,
+      if (vbo_get_minmax_cached(ib->obj, 1 << ib->index_size_shift, (GLintptr) indices,
                                 count, min_index, max_index))
          return;
 
-      offset = indices;
+      offset = (GLintptr) indices;
       indices = ctx->Driver.MapBufferRange(ctx, offset, size,
                                            GL_MAP_READ_BIT, ib->obj,
                                            MAP_INTERNAL);
    }
 
-   switch (ib->index_size) {
-   case 4: {
+   switch (ib->index_size_shift) {
+   case 2: {
       const GLuint *ui_indices = (const GLuint *)indices;
       GLuint max_ui = 0;
       GLuint min_ui = ~0U;
@@ -290,7 +290,7 @@ vbo_get_minmax_index(struct gl_context *ctx,
       *max_index = max_ui;
       break;
    }
-   case 2: {
+   case 1: {
       const GLushort *us_indices = (const GLushort *)indices;
       GLuint max_us = 0;
       GLuint min_us = ~0U;
@@ -312,7 +312,7 @@ vbo_get_minmax_index(struct gl_context *ctx,
       *max_index = max_us;
       break;
    }
-   case 1: {
+   case 0: {
       const GLubyte *ub_indices = (const GLubyte *)indices;
       GLuint max_ub = 0;
       GLuint min_ub = ~0U;
@@ -338,8 +338,8 @@ vbo_get_minmax_index(struct gl_context *ctx,
       unreachable("not reached");
    }
 
-   if (_mesa_is_bufferobj(ib->obj)) {
-      vbo_minmax_cache_store(ctx, ib->obj, ib->index_size, offset,
+   if (ib->obj) {
+      vbo_minmax_cache_store(ctx, ib->obj, 1 << ib->index_size_shift, offset,
                              count, *min_index, *max_index);
       ctx->Driver.UnmapBuffer(ctx, ib->obj, MAP_INTERNAL);
    }