[Piglit] [PATCH 1/6] shader_runner and glslparsertest: choose GL version more accurately.
Paul Berry
stereotype441 at gmail.com
Thu Feb 14 08:50:48 PST 2013
Previously, both shader_runner and glslparsertest contained switch
statements that attempted to choose a GL version for testing based on
a GLSL version requirement, and those switch statements didn't choose
a GL version very accurately (for example, they converted GLSL version
1.50 to GL version 3.1, which doesn't work).
This patch replaces the switch statements with a single common
function (in piglit-util-gl-common) that does the right thing.
---
tests/glslparsertest/glslparsertest.c | 36 ++++++++++++++---------------------
tests/shaders/shader_runner.c | 18 +++++-------------
tests/util/piglit-util-gl-common.c | 19 ++++++++++++++++++
tests/util/piglit-util-gl-common.h | 8 ++++++++
4 files changed, 46 insertions(+), 35 deletions(-)
diff --git a/tests/glslparsertest/glslparsertest.c b/tests/glslparsertest/glslparsertest.c
index ff32da7..14998c0 100644
--- a/tests/glslparsertest/glslparsertest.c
+++ b/tests/glslparsertest/glslparsertest.c
@@ -41,32 +41,24 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
if (argc > 3) {
const unsigned int int_version = parse_glsl_version(argv[3]);
-
switch (int_version) {
- case 110:
- case 120:
- case 130:
+ case 100:
config.supports_gl_compat_version = 10;
- config.supports_gl_core_version = 0;
- config.supports_gl_es_version = 0;
- break;
- case 140:
- case 150:
- case 330:
- config.supports_gl_compat_version = 31;
- config.supports_gl_core_version = 31;
- config.supports_gl_es_version = 0;
- break;
- case 400:
- case 410:
- case 420:
- config.supports_gl_compat_version = 40;
- config.supports_gl_core_version = 40;
- config.supports_gl_es_version = 0;
+ config.supports_gl_es_version = 20;
break;
- default:
+ case 300:
config.supports_gl_compat_version = 10;
- config.supports_gl_es_version = 20;
+ config.supports_gl_es_version = 30;
+ break;
+ default: {
+ const unsigned int gl_version
+ = required_gl_version_from_glsl_version(int_version);
+ config.supports_gl_compat_version = gl_version;
+ if (gl_version < 31)
+ config.supports_gl_core_version = 0;
+ else
+ config.supports_gl_core_version = gl_version;
+ }
break;
}
} else {
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 0ae9e0c..07cc5c9 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -931,6 +931,7 @@ parse_required_versions(struct requirement_parse_results *results,
}
}
+
static void
choose_required_gl_version(struct requirement_parse_results *parse_results,
struct component_version *gl_version)
@@ -946,19 +947,10 @@ choose_required_gl_version(struct requirement_parse_results *parse_results,
return;
/* Possibly promote the GL version. */
- switch (parse_results->glsl_version.num) {
- case 140:
- case 150:
- case 330:
- if (gl_version->num < 31)
- gl_version->num = 31;
- break;
- case 400:
- case 410:
- case 420:
- if (gl_version->num < 40)
- gl_version->num = 40;
- break;
+ if (gl_version->num < required_gl_version_from_glsl_version(
+ parse_results->glsl_version.num)) {
+ gl_version->num = required_gl_version_from_glsl_version(
+ parse_results->glsl_version.num);
}
}
diff --git a/tests/util/piglit-util-gl-common.c b/tests/util/piglit-util-gl-common.c
index 25098b8..3ee3013 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -567,3 +567,22 @@ piglit_ortho_uniform(GLint location, int w, int h)
piglit_gen_ortho_uniform(location, 0, w, 0, h, -1, 1);
}
#endif
+
+
+unsigned
+required_gl_version_from_glsl_version(unsigned glsl_version)
+{
+ switch (glsl_version) {
+ case 110: return 20;
+ case 120: return 21;
+ case 130: return 30;
+ case 140: return 31;
+ case 150: return 32;
+ case 330: return 33;
+ case 400: return 40;
+ case 410: return 41;
+ case 420: return 42;
+ case 430: return 43;
+ default: return 0;
+ }
+}
diff --git a/tests/util/piglit-util-gl-common.h b/tests/util/piglit-util-gl-common.h
index 336953d..2e87d69 100644
--- a/tests/util/piglit-util-gl-common.h
+++ b/tests/util/piglit-util-gl-common.h
@@ -219,6 +219,14 @@ extern GLint piglit_ARBfp_pass_through;
static const GLint PIGLIT_ATTRIB_POS = 0;
static const GLint PIGLIT_ATTRIB_TEX = 1;
+/**
+ * Given a GLSL version number, return the lowest-numbered GL version
+ * that is guaranteed to support it.
+ */
+unsigned
+required_gl_version_from_glsl_version(unsigned glsl_version);
+
+
#ifdef __cplusplus
} /* end extern "C" */
#endif
--
1.8.1.3
More information about the Piglit
mailing list