diff options
author | Eric Anholt <eric@anholt.net> | 2012-11-13 15:09:49 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2012-11-15 10:56:57 -0800 |
commit | aa3dfaea314d19dc222635e603435c411a42dd3c (patch) | |
tree | a1652663ba1812c45bbb2d75dbd9c76e179609f1 | |
parent | ff6c4186831a8c0d60536788a56b1f91507d9492 (diff) |
glsl-max-varyings: Add a variant that also tests >MAX_VARYING_COMPONENTS.
Given that piglit hasn't been testing this, I don't want to modify the
existing glsl-max-varyings which has been very useful. I don't want a
non-rendering test, though, because gl 2.0 allows an implementation to
allow shaders with >MAX_VARYING_COMPONENTS, so we should actually test
the rendering if that does happen.
v2: Make the error/warning message clearer.
Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r-- | tests/all.tests | 1 | ||||
-rw-r--r-- | tests/shaders/glsl-max-varyings.c | 47 |
2 files changed, 38 insertions, 10 deletions
diff --git a/tests/all.tests b/tests/all.tests index e62fc961..dccee43e 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -278,6 +278,7 @@ shaders['glsl-fs-texture2drect-proj4'] = PlainExecTest(['glsl-fs-texture2drect', add_plain_test(shaders, 'glsl-fs-user-varying-ff') add_plain_test(shaders, 'glsl-mat-attribute') shaders['glsl-max-varyings'] = concurrent_test('glsl-max-varyings') +shaders['glsl-max-varyings >MAX_VARYING_COMPONENTS'] = concurrent_test('glsl-max-varyings --exceed-limits') add_plain_test(shaders, 'glsl-orangebook-ch06-bump') add_plain_test(shaders, 'glsl-routing') add_plain_test(shaders, 'glsl-vs-arrays') diff --git a/tests/shaders/glsl-max-varyings.c b/tests/shaders/glsl-max-varyings.c index bdb4bed5..323f4c05 100644 --- a/tests/shaders/glsl-max-varyings.c +++ b/tests/shaders/glsl-max-varyings.c @@ -47,6 +47,9 @@ PIGLIT_GL_TEST_CONFIG_BEGIN PIGLIT_GL_TEST_CONFIG_END +static bool exceed_limits = false; +static int max_varyings; + /* Generate a VS that writes to num_varyings vec4s, and put * interesting data in data_varying with 0.0 everywhere else. */ @@ -147,7 +150,7 @@ coord_from_index(int index) return 2 + 12 * index; } -static void +static bool draw(int num_varyings) { int data_varying; @@ -182,8 +185,16 @@ draw(int num_varyings) glBindAttribLocation(prog, 2, "red"); glLinkProgram(prog); - if (!piglit_link_check_status(prog)) - piglit_report_result(PIGLIT_FAIL); + if (!piglit_link_check_status_quiet(prog)) { + if (num_varyings > max_varyings) { + printf("Failed to link with %d out of %d " + "varyings used\n", + num_varyings, max_varyings); + return false; + } else { + piglit_report_result(PIGLIT_FAIL); + } + } glUseProgram(prog); @@ -204,14 +215,17 @@ draw(int num_varyings) glDeleteShader(fs); glDeleteProgram(prog); } + + return true; } enum piglit_result piglit_display(void) { GLint max_components; - int max_varyings, row, col; + int test_varyings, row, col; GLboolean pass = GL_TRUE, warned = GL_FALSE; + bool drew[MAX_VARYING]; piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); @@ -220,22 +234,28 @@ piglit_display(void) printf("GL_MAX_VARYING_FLOATS = %i\n", max_components); - if (max_varyings > MAX_VARYING) { + test_varyings = max_varyings; + if (exceed_limits) + test_varyings++; + if (test_varyings > MAX_VARYING) { printf("test not designed to handle >%d varying vec4s.\n" "(implementation reports %d components)\n", - max_components, MAX_VARYING); - max_varyings = MAX_VARYING; + MAX_VARYING, max_varyings); + test_varyings = MAX_VARYING; warned = GL_TRUE; } glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); - for (row = 0; row < max_varyings; row++) { - draw(row + 1); + for (row = 0; row < test_varyings; row++) { + drew[row] = draw(row + 1); } - for (row = 0; row < max_varyings; row++) { + for (row = 0; row < test_varyings; row++) { + if (!drew[row]) + continue; + for (col = 0; col <= row; col++) { GLboolean ok; float green[3] = {0.0, 1.0, 0.0}; @@ -266,8 +286,15 @@ piglit_display(void) void piglit_init(int argc, char **argv) { + int i; + piglit_require_gl_version(20); + for (i = 0; i < argc; i++) { + if (strcmp(argv[i], "--exceed-limits") == 0) + exceed_limits = true; + } + printf("Vertical axis: Increasing numbers of varyings.\n"); printf("Horizontal axis: Which of the varyings contains the color.\n"); } |