aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2013-03-18 17:29:58 -0600
committerBrian Paul <brianp@vmware.com>2013-03-19 08:08:08 -0600
commitec3222adb587dd3f1be1d02e91063a30ceec7f88 (patch)
treed9b8021de19974302896501e85f606641050d325
parent63472a94ef657354e0d16dd3302b98ab345d949a (diff)
texunits: increase size of arrays to fix crash
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 <jfonseca@vmware.com>
-rw-r--r--tests/general/texunits.c13
1 files 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);