[Piglit] [PATCH] squash! GS: Test that geometry shader input/output layout qualifiers only compile if valid
Paul Berry
stereotype441 at gmail.com
Tue Oct 22 19:13:45 CEST 2013
This is a suggested fix to
http://lists.freedesktop.org/archives/piglit/2013-October/008024.html
([PATCH 1/4 v3] GS: Test that geometry shader input/output layout
qualifiers only compile if valid).
With this fix applied, the patch is:
Reviewed-by: Paul Berry <stereotype441 at gmail.com>
---
.../geometry/gs-input-layout-qualifiers.c | 48 ++++++++++------------
.../geometry/gs-output-layout-qualifiers.c | 48 ++++++++++------------
2 files changed, 44 insertions(+), 52 deletions(-)
diff --git a/tests/spec/glsl-1.50/execution/geometry/gs-input-layout-qualifiers.c b/tests/spec/glsl-1.50/execution/geometry/gs-input-layout-qualifiers.c
index 0afc4e8..0b7ba41 100644
--- a/tests/spec/glsl-1.50/execution/geometry/gs-input-layout-qualifiers.c
+++ b/tests/spec/glsl-1.50/execution/geometry/gs-input-layout-qualifiers.c
@@ -54,8 +54,6 @@ static const char *gstemplate =
"void main() {\n"
"}\n";
-static GLuint prog;
-
char *valids[] = {"points",
"lines",
"lines_adjacency",
@@ -82,6 +80,7 @@ piglit_init(int argc, char **argv)
char* gstext = NULL;
int i = 0;
bool pass = true;
+ GLint expected_compile_result;
/* Parse params */
if (argc != 2) {
@@ -89,41 +88,38 @@ piglit_init(int argc, char **argv)
}
layout = argv[1];
- if (layout == NULL) {
- printf("%s failed\n", argv[0]);
- piglit_report_result(PIGLIT_FAIL);
+
+ /* figure out if we expect compilation to be successful. */
+ expected_compile_result = GL_FALSE;
+ for (i = 0; i < ARRAY_SIZE(valids); i++) {
+ if (strcmp(layout, valids[i]) == 0) {
+ expected_compile_result = GL_TRUE;
+ break;
+ }
}
- prog = glCreateProgram();
asprintf(&gstext, gstemplate, layout);
gs = glCreateShader(GL_GEOMETRY_SHADER);
glShaderSource(gs, 1, (const GLchar **) &gstext, NULL);
glCompileShader(gs);
- glAttachShader(prog, gs);
free(gstext);
- /* check if the current layout is valid */
- for(i = 0; i < ARRAY_SIZE(valids); i++) {
- if(strcmp(layout, valids[i]) == 0) {
- glGetShaderiv(gs, GL_COMPILE_STATUS,
- &gsCompiled);
- if(gsCompiled != GL_TRUE) {
- printf("Failed to compile.\n");
- pass = false;
- }
-
- pass = piglit_check_gl_error(GL_NO_ERROR)
- && pass;
- piglit_report_result(pass ? PIGLIT_PASS :
- PIGLIT_FAIL);
+ /* check compile result */
+ glGetShaderiv(gs, GL_COMPILE_STATUS, &gsCompiled);
+ if (gsCompiled != expected_compile_result) {
+ if (expected_compile_result) {
+ printf("Failed to compile with input qualifier "
+ "\"%s\".\n", layout);
+ } else {
+ printf("\"%s\" is an invalid input qualifier "
+ "but geometry shader still compiled.\n",
+ layout);
}
+ pass = false;
}
- /* if the layout was not valid... */
- printf("\"%s\" is an invalid input qualifier "
- "but geometry shader still compiled.\n",
- layout);
- piglit_report_result(PIGLIT_FAIL);
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
enum piglit_result
diff --git a/tests/spec/glsl-1.50/execution/geometry/gs-output-layout-qualifiers.c b/tests/spec/glsl-1.50/execution/geometry/gs-output-layout-qualifiers.c
index 232b8f3..deb9bc3 100644
--- a/tests/spec/glsl-1.50/execution/geometry/gs-output-layout-qualifiers.c
+++ b/tests/spec/glsl-1.50/execution/geometry/gs-output-layout-qualifiers.c
@@ -53,8 +53,6 @@ static const char *gstemplate =
"void main() {\n"
"}\n";
-static GLuint prog;
-
char *valids[] = {"points",
"line_strip",
"triangle_strip"};
@@ -79,6 +77,7 @@ piglit_init(int argc, char **argv)
char* gstext = NULL;
int i = 0;
bool pass = true;
+ GLint expected_compile_result;
/* Parse params */
if (argc != 2) {
@@ -86,41 +85,38 @@ piglit_init(int argc, char **argv)
}
layout = argv[1];
- if (layout == NULL) {
- printf("%s failed\n", argv[0]);
- piglit_report_result(PIGLIT_FAIL);
+
+ /* figure out if we expect compilation to be successful. */
+ expected_compile_result = GL_FALSE;
+ for (i = 0; i < ARRAY_SIZE(valids); i++) {
+ if (strcmp(layout, valids[i]) == 0) {
+ expected_compile_result = GL_TRUE;
+ break;
+ }
}
- prog = glCreateProgram();
asprintf(&gstext, gstemplate, layout);
gs = glCreateShader(GL_GEOMETRY_SHADER);
glShaderSource(gs, 1, (const GLchar **) &gstext, NULL);
glCompileShader(gs);
- glAttachShader(prog, gs);
free(gstext);
- /* check if the current layout is valid */
- for(i = 0; i < ARRAY_SIZE(valids); i++) {
- if(strcmp(layout, valids[i]) == 0) {
- glGetShaderiv(gs, GL_COMPILE_STATUS,
- &gsCompiled);
- if(gsCompiled != GL_TRUE) {
- printf("Failed to compile.\n");
- pass = false;
- }
-
- pass = piglit_check_gl_error(GL_NO_ERROR)
- && pass;
- piglit_report_result(pass ? PIGLIT_PASS :
- PIGLIT_FAIL);
+ /* check compile result */
+ glGetShaderiv(gs, GL_COMPILE_STATUS, &gsCompiled);
+ if (gsCompiled != expected_compile_result) {
+ if (expected_compile_result) {
+ printf("Failed to compile with output qualifier "
+ "\"%s\".\n", layout);
+ } else {
+ printf("\"%s\" is an invalid output qualifier "
+ "but geometry shader still compiled.\n",
+ layout);
}
+ pass = false;
}
- /* if the layout was not valid... */
- printf("\"%s\" is an invalid output qualifier "
- "but geometry shader still compiled.\n",
- layout);
- piglit_report_result(PIGLIT_FAIL);
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
enum piglit_result
--
1.8.4.1
More information about the Piglit
mailing list