From ec3222adb587dd3f1be1d02e91063a30ceec7f88 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 18 Mar 2013 17:29:58 -0600 Subject: texunits: increase size of arrays to fix crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NVIDIA's later GPUs/drivers report 192 combined texture units. This causes us to read outside the too-small arrays and segfault. Increase the array sizes and add a check for the future. Reviewed-by: José Fonseca --- tests/general/texunits.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/general/texunits.c b/tests/general/texunits.c index 3140f80c..e419bded 100644 --- a/tests/general/texunits.c +++ b/tests/general/texunits.c @@ -40,8 +40,10 @@ PIGLIT_GL_TEST_CONFIG_BEGIN PIGLIT_GL_TEST_CONFIG_END +#define MAX_UNITS 256 + /** random number for checking state */ -static GLfloat Random[128][4]; +static GLfloat Random[MAX_UNITS][4]; static GLint MaxTextureCoordUnits; static GLint MaxTextureVertexUnits; @@ -53,7 +55,7 @@ static void generate_random_numbers(void) { int i, j; - for (i = 0; i < 128; i++) { + for (i = 0; i < ARRAY_SIZE(Random); i++) { for (j = 0; j < 4; j++) { /* values in [0, 1] */ Random[i][j] = (rand() % 1000) * .001; @@ -233,7 +235,7 @@ test_texture_matrix(void) static GLboolean test_texture_params(void) { - GLuint tex[100]; + GLuint tex[MAX_UNITS]; GLenum err; int i; int maxUnit; @@ -376,6 +378,11 @@ init(void) report_info(); + if (MaxTextureCombinedUnits > MAX_UNITS) { + /* Need to increase the MAX_UNITS limit */ + piglit_report_result(PIGLIT_WARN); + } + generate_random_numbers(); glMatrixMode(GL_PROJECTION); -- cgit v1.2.3