From 018e602dc629dfbda52b5c7711b5867d72ce33c8 Mon Sep 17 00:00:00 2001 From: Charmaine Lee Date: Wed, 30 Aug 2017 14:26:41 -0700 Subject: [PATCH] vbo: fix offset in minmax cache key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of saving primitive offset in the minmax cache key, save the actual buffer offset which is used in the cache lookup. Fixes rendering artifact seen with GoogleEarth when run with VMware driver. v2: Per Brian's comment, initialize offset to avoid compiler warning. Cc: mesa-stable@lists.freedesktop.org Reviewed-by: Brian Paul (cherry picked from commit 2d93b462b4d978b0da417b35a7470e336bc4e783) [Andres Gomez: resolve trivial conflicts] Signed-off-by: Andres Gomez Conflicts: src/mesa/vbo/vbo_minmax_index.c Squashed with: vbo: fix build errors on android incompatible pointer to integer conversion assigning to 'GLintptr' (aka 'int') from 'const char *' [-Werror,-Wint-conversion] offset = indices; ^ ~~~~~~~ Fixes: 2d93b462b4d ("vbo: fix offset in minmax cache key") Signed-off-by: Tapani Pälli Reviewed-by: Charmaine Lee Reviewed-by: Emil Velikov (cherry picked from commit 0986f686328216fa201769c630372fd4b6f8877a) --- src/mesa/vbo/vbo_minmax_index.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesa/vbo/vbo_minmax_index.c b/src/mesa/vbo/vbo_minmax_index.c index 0f75a87f3f3..36c573cac0e 100644 --- a/src/mesa/vbo/vbo_minmax_index.c +++ b/src/mesa/vbo/vbo_minmax_index.c @@ -244,6 +244,7 @@ vbo_get_minmax_index(struct gl_context *ctx, const int index_size = vbo_sizeof_ib_type(ib->type); const char *indices; GLuint i; + GLintptr offset = 0; indices = (char *) ib->ptr + prim->start * index_size; if (_mesa_is_bufferobj(ib->obj)) { @@ -253,7 +254,8 @@ vbo_get_minmax_index(struct gl_context *ctx, min_index, max_index)) return; - indices = ctx->Driver.MapBufferRange(ctx, (GLintptr) indices, size, + offset = (GLintptr) indices; + indices = ctx->Driver.MapBufferRange(ctx, offset, size, GL_MAP_READ_BIT, ib->obj, MAP_INTERNAL); } @@ -336,8 +338,8 @@ 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, - *min_index, *max_index); + vbo_minmax_cache_store(ctx, ib->obj, ib->type, offset, + count, *min_index, *max_index); ctx->Driver.UnmapBuffer(ctx, ib->obj, MAP_INTERNAL); } }