From db5529573f40c5ad68d589ab6a5e4e47d6743b4c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 26 Oct 2006 20:54:28 +0000 Subject: [PATCH] If DEBUG, check that all array indices really do fall in [start,end] in the DrawRangeElements() call. Warn the user if that's not true. --- src/mesa/tnl/t_array_api.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index 36ea54296ce..6826cf7e24c 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.2 * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * @@ -115,6 +115,12 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) { GET_CURRENT_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); + /* It's tempting to get rid of this threshold value because we take + * very different paths if 'count' is less than or greater than 'thresh'. + * I've found/fixed at least one bug which only occured for particular + * array sizes. Also, several conformance tests use very short arrays + * which means the long-array path doesn't get tested. -Brian + */ GLuint thresh = (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) ? 30 : 10; if (MESA_VERBOSE & VERBOSE_API) @@ -289,6 +295,18 @@ _tnl_DrawRangeElements(GLenum mode, ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT, count, type, indices ); +#ifdef DEBUG + /* check that array indices really fall inside [start, end] range */ + { + GLuint i; + for (i = 0; i < count; i++) { + if (ui_indices[i] < start || ui_indices[i] > end) { + _mesa_warning(ctx, "Invalid array index in " + "glDrawRangeElements(index=%u)", ui_indices[i]); + } + } + } +#endif assert(!ctx->CompileFlag); -- 2.30.2