[Piglit] [PATCH 60/63] shader_runner/spirv: check if test really includes spirv
Alejandro PiƱeiro
apinheiro at igalia.com
Sat Feb 23 23:45:48 UTC 2019
SPIRV YES/ONLY assumes that the test includes the SPIR-V shader, and
that you should use it. This commit checks that this really happens,
and prints a proper error message if that is not the case.
Without this commit, a SPIRV YES/ONLY test that by mistake didn't
include the [spirv xx] sections would be just skipped with the
following non-intuitive message:
"Function "glDeleteProgramsARB" not supported on this implementation"
---
tests/shaders/shader_runner.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 7c6810099..33b2fe6df 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1728,6 +1728,7 @@ process_test_script(const char *script_name)
enum states state = none;
const char *line = text;
enum piglit_result result;
+ bool test_really_contains_spirv = false;
if (line == NULL) {
printf("could not read file \"%s\"\n", script_name);
@@ -1770,6 +1771,7 @@ process_test_script(const char *script_name)
shader_string_size = strlen(shader_string);
} else if (parse_str(line, "[vertex shader spirv]", NULL)) {
state = vertex_shader_spirv;
+ test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[vertex shader specializations]", NULL)) {
state = vertex_shader_specializations;
@@ -1778,6 +1780,7 @@ process_test_script(const char *script_name)
shader_string = NULL;
} else if (parse_str(line, "[tessellation control shader spirv]", NULL)) {
state = tess_ctrl_shader_spirv;
+ test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[tessellation control shader specializations]", NULL)) {
state = tess_ctrl_shader_specializations;
@@ -1786,6 +1789,7 @@ process_test_script(const char *script_name)
shader_string = NULL;
} else if (parse_str(line, "[tessellation evaluation shader spirv]", NULL)) {
state = tess_eval_shader_spirv;
+ test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[tessellation evaluation shader specializations]", NULL)) {
state = tess_eval_shader_specializations;
@@ -1796,6 +1800,7 @@ process_test_script(const char *script_name)
state = geometry_shader_specializations;
} else if (parse_str(line, "[geometry shader spirv]", NULL)) {
state = geometry_shader_spirv;
+ test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[geometry shader specializations]", NULL)) {
state = geometry_shader_specializations;
@@ -1812,6 +1817,7 @@ process_test_script(const char *script_name)
state = fragment_shader_specializations;
} else if (parse_str(line, "[fragment shader spirv]", NULL)) {
state = fragment_shader_spirv;
+ test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[fragment shader specializations]", NULL)) {
state = fragment_shader_specializations;
@@ -1820,6 +1826,7 @@ process_test_script(const char *script_name)
shader_string = NULL;
} else if (parse_str(line, "[compute shader spirv]", NULL)) {
state = compute_shader_spirv;
+ test_really_contains_spirv = true;
shader_string = NULL;
} else if (parse_str(line, "[compute shader specializations]", NULL)) {
state = compute_shader_specializations;
@@ -1833,6 +1840,15 @@ process_test_script(const char *script_name)
test_start_line_num = line_num + 1;
if (test_start[0] != '\0')
test_start++;
+
+ if (!test_really_contains_spirv &&
+ spirv_replaces_glsl) {
+ fprintf(stderr, "SPIRV YES/ONLY test, but"
+ " spirv section was not found.\n");
+
+ return PIGLIT_FAIL;
+ }
+
return PIGLIT_PASS;
} else {
fprintf(stderr,
@@ -1912,6 +1928,14 @@ process_test_script(const char *script_name)
line_num++;
}
+ if (!test_really_contains_spirv &&
+ spirv_replaces_glsl) {
+ fprintf(stderr, "SPIRV YES/ONLY test, but"
+ " spirv section was not found.\n");
+
+ return PIGLIT_FAIL;
+ }
+
return leave_state(state, line, script_name);
}
--
2.19.1
More information about the Piglit
mailing list