[Piglit] [PATCH 1/3] built-in-constants: Change GLSL version handling
Ian Romanick
idr at freedesktop.org
Wed Apr 29 16:01:50 PDT 2015
From: Ian Romanick <ian.d.romanick at intel.com>
Instead of a floating point number, specify the version exactly the same
way the #version string would be specified. The GLSL ES 3.00 handling
was a bit wonkey before, and adding GLSL ES 3.10 would make it even
worse.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
tests/shaders/built-in-constants.c | 68 ++++++++++++++++------
tests/spec/arb_compute_shader/minimum-maximums.txt | 2 +-
.../minimum-maximums.txt | 2 +-
.../arb_tessellation_shader/minimum-maximums.txt | 2 +-
tests/spec/glsl-1.10/minimum-maximums.txt | 2 +-
tests/spec/glsl-1.20/minimum-maximums.txt | 2 +-
tests/spec/glsl-1.30/minimum-maximums.txt | 2 +-
tests/spec/glsl-1.40/minimum-maximums.txt | 2 +-
tests/spec/glsl-1.50/minimum-maximums.txt | 2 +-
tests/spec/glsl-3.30/minimum-maximums.txt | 2 +-
tests/spec/glsl-es-1.00/minimum-maximums.txt | 2 +-
tests/spec/glsl-es-3.00/minimum-maximums.txt | 2 +-
12 files changed, 61 insertions(+), 29 deletions(-)
diff --git a/tests/shaders/built-in-constants.c b/tests/shaders/built-in-constants.c
index 5d4bc69..abf6fa8 100644
--- a/tests/shaders/built-in-constants.c
+++ b/tests/shaders/built-in-constants.c
@@ -37,7 +37,8 @@ struct test_vector tests[500];
unsigned num_tests = 0;
int required_glsl_version = 0;
-char *required_glsl_version_string = NULL;
+char required_glsl_version_string[128];
+bool es_shader = false;
GLenum shader_type = 0;
/**
@@ -185,11 +186,9 @@ parse_file(const char *filename)
unsigned text_size;
char *text = piglit_load_text_file(filename, &text_size);
char *line = text;
- int count;
- int major;
- int minor;
char *end_of_line;
ptrdiff_t len;
+ char *endptr;
if (line == NULL) {
fprintf(stderr, "could not read file \"%s\"\n", filename);
@@ -198,7 +197,7 @@ parse_file(const char *filename)
/* The format of the test file is:
*
- * major.minor
+ * version [es|core]
* GL_VERTEX_SHADER|GL_GEOMETRY_SHADER|GL_FRAGMENT_SHADER|GL_COMPUTE_SHADER
* GL_ARB_some_extension
* gl_MaxFoo 8
@@ -208,13 +207,28 @@ parse_file(const char *filename)
/* Process the version requirement.
*/
- count = sscanf(line, "%d.%d", &major, &minor);
- if (count != 2) {
- fprintf(stderr, "Parse error in version line.\n");
+ end_of_line = strchrnul(line, '\n');
+ len = end_of_line - line;
+
+ if (len + 1 >= ARRAY_SIZE(required_glsl_version_string)) {
+ fprintf(stderr, "Version line too long.\n");
piglit_report_result(PIGLIT_FAIL);
}
- required_glsl_version = major * 100 + minor;
+ memcpy(required_glsl_version_string, line, len);
+ required_glsl_version_string[len] = '\0';
+
+ required_glsl_version = strtol(line, &endptr, 10);
+ line = (char *) eat_whitespace(endptr);
+ es_shader = strncmp("es\n", line, 3) == 0;
+
+ if (required_glsl_version <= 0 ||
+ (line != end_of_line &&
+ strncmp("es\n", line, 3) != 0 &&
+ strncmp("core\n", line, 5) != 0)) {
+ fprintf(stderr, "Parse error in version line.\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
/* Skip to the next line.
*/
@@ -264,8 +278,6 @@ parse_file(const char *filename)
}
while (line[0] != '\0') {
- char *endptr;
-
line = (char *) eat_whitespace(line);
if (string_match("gl_Max", line) != 0
@@ -392,7 +404,29 @@ piglit_init(int argc, char **argv)
piglit_get_glsl_version(&is_es, &major, &minor);
glsl_version = major * 100 + minor;
- if (glsl_version < required_glsl_version)
+
+ if ((es_shader || required_glsl_version == 100) && !is_es) {
+ switch (required_glsl_version) {
+ case 100:
+ if (!piglit_is_extension_supported("GL_ARB_ES2_compatibility"))
+ piglit_report_result(PIGLIT_SKIP);
+ break;
+ case 300:
+ if (!piglit_is_extension_supported("GL_ARB_ES3_compatibility"))
+ piglit_report_result(PIGLIT_SKIP);
+ break;
+ default:
+ printf("Unknown GLSL ES version.\n");
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ } else if ((!es_shader && required_glsl_version != 100) && is_es) {
+ /* It should actually be impossible to get here because
+ * supports_gl_es_version won't get set, and that is required
+ * in the ES builds.
+ */
+ printf("Desktop OpenGL shaders are not valid in OpenGL ES.\n");
+ piglit_report_result(PIGLIT_FAIL);
+ } else if (glsl_version < required_glsl_version)
piglit_report_result(PIGLIT_SKIP);
/* Process the list of required extensions. While doing this,
@@ -434,22 +468,20 @@ piglit_init(int argc, char **argv)
* shaders in the test run.
*/
asprintf(&version_string,
- "#version %d %s\n"
+ "#version %s\n"
"%s"
"#ifdef GL_ES\n"
"precision mediump float;\n"
"#endif\n",
- required_glsl_version,
- required_glsl_version == 300 ? "es" : "",
+ required_glsl_version_string,
extension_enables);
asprintf(&passthrough_version_string,
- "#version %d %s\n"
+ "#version %s\n"
"#ifdef GL_ES\n"
"precision mediump float;\n"
"#endif\n",
- required_glsl_version,
- required_glsl_version == 300 ? "es" : "");
+ required_glsl_version_string);
/* Create the shaders that will be used for the real part of the test.
diff --git a/tests/spec/arb_compute_shader/minimum-maximums.txt b/tests/spec/arb_compute_shader/minimum-maximums.txt
index 85cac37..01d5a46 100644
--- a/tests/spec/arb_compute_shader/minimum-maximums.txt
+++ b/tests/spec/arb_compute_shader/minimum-maximums.txt
@@ -1,4 +1,4 @@
-3.30
+330
GL_COMPUTE_SHADER
GL_ARB_compute_shader
gl_MaxComputeWorkGroupCount.x 65535
diff --git a/tests/spec/arb_shading_language_420pack/minimum-maximums.txt b/tests/spec/arb_shading_language_420pack/minimum-maximums.txt
index 15650c0..082b0a0 100644
--- a/tests/spec/arb_shading_language_420pack/minimum-maximums.txt
+++ b/tests/spec/arb_shading_language_420pack/minimum-maximums.txt
@@ -1,4 +1,4 @@
-1.30
+130
GL_ARB_shading_language_420pack
gl_MinProgramTexelOffset -8
gl_MaxProgramTexelOffset 7
diff --git a/tests/spec/arb_tessellation_shader/minimum-maximums.txt b/tests/spec/arb_tessellation_shader/minimum-maximums.txt
index 6e92a4d..e537ceb 100644
--- a/tests/spec/arb_tessellation_shader/minimum-maximums.txt
+++ b/tests/spec/arb_tessellation_shader/minimum-maximums.txt
@@ -1,4 +1,4 @@
-3.30
+330
GL_TESS_CONTROL_SHADER
GL_ARB_tessellation_shader
gl_MaxTessControlInputComponents 128
diff --git a/tests/spec/glsl-1.10/minimum-maximums.txt b/tests/spec/glsl-1.10/minimum-maximums.txt
index f0db76d..ac9799f 100644
--- a/tests/spec/glsl-1.10/minimum-maximums.txt
+++ b/tests/spec/glsl-1.10/minimum-maximums.txt
@@ -1,4 +1,4 @@
-1.10
+110
gl_MaxClipPlanes 6
gl_MaxCombinedTextureImageUnits 2
gl_MaxDrawBuffers 1
diff --git a/tests/spec/glsl-1.20/minimum-maximums.txt b/tests/spec/glsl-1.20/minimum-maximums.txt
index f65ca64..0badcd9 100644
--- a/tests/spec/glsl-1.20/minimum-maximums.txt
+++ b/tests/spec/glsl-1.20/minimum-maximums.txt
@@ -1,4 +1,4 @@
-1.20
+120
gl_MaxClipPlanes 6
gl_MaxCombinedTextureImageUnits 2
gl_MaxDrawBuffers 1
diff --git a/tests/spec/glsl-1.30/minimum-maximums.txt b/tests/spec/glsl-1.30/minimum-maximums.txt
index 9eb97e7..2ea77ea 100644
--- a/tests/spec/glsl-1.30/minimum-maximums.txt
+++ b/tests/spec/glsl-1.30/minimum-maximums.txt
@@ -1,4 +1,4 @@
-1.30
+130
gl_MaxClipDistances 8
gl_MaxClipPlanes 8
gl_MaxCombinedTextureImageUnits 16
diff --git a/tests/spec/glsl-1.40/minimum-maximums.txt b/tests/spec/glsl-1.40/minimum-maximums.txt
index a2e8370..7e78b26 100644
--- a/tests/spec/glsl-1.40/minimum-maximums.txt
+++ b/tests/spec/glsl-1.40/minimum-maximums.txt
@@ -1,4 +1,4 @@
-1.40
+140
gl_MaxClipDistances 8
gl_MaxCombinedTextureImageUnits 16
gl_MaxDrawBuffers 8
diff --git a/tests/spec/glsl-1.50/minimum-maximums.txt b/tests/spec/glsl-1.50/minimum-maximums.txt
index a8bb936..d6e9661 100644
--- a/tests/spec/glsl-1.50/minimum-maximums.txt
+++ b/tests/spec/glsl-1.50/minimum-maximums.txt
@@ -1,4 +1,4 @@
-1.50
+150
gl_MaxVertexAttribs 16
gl_MaxVertexUniformComponents 1024
gl_MaxVaryingFloats 60
diff --git a/tests/spec/glsl-3.30/minimum-maximums.txt b/tests/spec/glsl-3.30/minimum-maximums.txt
index 4923442..a1ee368 100644
--- a/tests/spec/glsl-3.30/minimum-maximums.txt
+++ b/tests/spec/glsl-3.30/minimum-maximums.txt
@@ -1,4 +1,4 @@
-3.30
+330
gl_MaxVertexAttribs 16
gl_MaxVertexUniformComponents 1024
gl_MaxVaryingFloats 60
diff --git a/tests/spec/glsl-es-1.00/minimum-maximums.txt b/tests/spec/glsl-es-1.00/minimum-maximums.txt
index 939db0d..cff8926 100644
--- a/tests/spec/glsl-es-1.00/minimum-maximums.txt
+++ b/tests/spec/glsl-es-1.00/minimum-maximums.txt
@@ -1,4 +1,4 @@
-1.00
+100
gl_MaxCombinedTextureImageUnits 8
gl_MaxDrawBuffers 1
gl_MaxFragmentUniformVectors 16
diff --git a/tests/spec/glsl-es-3.00/minimum-maximums.txt b/tests/spec/glsl-es-3.00/minimum-maximums.txt
index da97b27..46de39c 100644
--- a/tests/spec/glsl-es-3.00/minimum-maximums.txt
+++ b/tests/spec/glsl-es-3.00/minimum-maximums.txt
@@ -1,4 +1,4 @@
-3.00
+300 es
gl_MaxVertexAttribs 16
gl_MaxVertexUniformVectors 256
gl_MaxVertexOutputVectors 16
--
2.1.0
More information about the Piglit
mailing list