[Mesa-dev] [PATCH] mesa/vbo: fix invalid min/max indexes
Rob Clark
robdclark at gmail.com
Mon May 8 21:27:18 UTC 2017
On Mon, May 8, 2017 at 4:57 PM, Marek Olšák <maraeo at gmail.com> wrote:
> I personally find the assertions unnecessary because the bug has been
> discovered and fixed by this patch, and this code is unlikely to
> change. Anyway:
>
> Reviewed-by: Marek Olšák <marek.olsak at amd.com>
I don't suppose there is something like debug_assert() (ie. only
defined for --enable-debug builds) for mesa code? That was really
what I wanted there. Maybe I'll just put #ifdef DEBUG / #endif around
it..
(I am a fan of asserts, even just so that next time I read the code I
remember that some case shouldn't happen ;-))
BR,
-R
> Marek
>
> On Mon, May 8, 2017 at 10:37 PM, Rob Clark <robdclark at gmail.com> wrote:
>> Fixes: c3f37e9b ("st/mesa: use min_index and max_index directly from vbo")
>> Signed-off-by: Rob Clark <robdclark at gmail.com>
>> ---
>> I haven't had a chance to piglit this yet, but it does fix the
>> regression w/ 'glmark2 -b ideas'.
>>
>> src/mesa/vbo/vbo_exec_array.c | 22 ++++++++++++++++------
>> 1 file changed, 16 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
>> index 0fcaefe..437d260 100644
>> --- a/src/mesa/vbo/vbo_exec_array.c
>> +++ b/src/mesa/vbo/vbo_exec_array.c
>> @@ -855,6 +855,11 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
>> struct _mesa_index_buffer ib;
>> struct _mesa_prim prim;
>>
>> + if (!index_bounds_valid) {
>> + assert(start == 0u);
>> + assert(end == ~0u);
>> + }
>> +
>> if (skip_draw_elements(ctx, count, indices))
>> return;
>>
>> @@ -999,6 +1004,11 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
>> (void) check_draw_elements_data;
>> #endif
>>
>> + if (!index_bounds_valid) {
>> + start = 0;
>> + end = ~0;
>> + }
>> +
>> vbo_validated_drawrangeelements(ctx, mode, index_bounds_valid, start, end,
>> count, type, indices, basevertex, 1, 0);
>> }
>> @@ -1048,7 +1058,7 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type,
>> return;
>> }
>>
>> - vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>> + vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, 0, ~0,
>> count, type, indices, 0, 1, 0);
>> }
>>
>> @@ -1077,7 +1087,7 @@ vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
>> return;
>> }
>>
>> - vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>> + vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, 0, ~0,
>> count, type, indices, basevertex, 1, 0);
>> }
>>
>> @@ -1107,7 +1117,7 @@ vbo_exec_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
>> return;
>> }
>>
>> - vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>> + vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, 0, ~0,
>> count, type, indices, 0, numInstances, 0);
>> }
>>
>> @@ -1142,7 +1152,7 @@ vbo_exec_DrawElementsInstancedBaseVertex(GLenum mode, GLsizei count,
>> return;
>> }
>>
>> - vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>> + vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, 0, ~0,
>> count, type, indices,
>> basevertex, numInstances, 0);
>> }
>> @@ -1179,7 +1189,7 @@ vbo_exec_DrawElementsInstancedBaseInstance(GLenum mode, GLsizei count,
>> return;
>> }
>>
>> - vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>> + vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, 0, ~0,
>> count, type, indices, 0, numInstances,
>> baseInstance);
>> }
>> @@ -1218,7 +1228,7 @@ vbo_exec_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode,
>> return;
>> }
>>
>> - vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>> + vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, 0, ~0,
>> count, type, indices, basevertex,
>> numInstances, baseInstance);
>> }
>> --
>> 2.9.3
>>
More information about the mesa-dev
mailing list