diff options
author | Francisco Jerez <currojerez@riseup.net> | 2014-10-03 15:39:36 +0300 |
---|---|---|
committer | Francisco Jerez <currojerez@riseup.net> | 2015-01-31 17:03:37 +0200 |
commit | 0a6cbabcf241747fa1e7288670bde947bc501692 (patch) | |
tree | 2637c026189c72a349023b79d668942105074c7a | |
parent | ebf387e16dfaa89c8ca645adb5669261d627e164 (diff) |
util/shader: Define "nothrow" variant of piglit_compile_shader_text().
Define a variant of piglit_compile_shader_text() that doesn't call
piglit_report_result() on failure killing the program, which is quite
annoying for tests that expect a compilation to fail and for tests
that are structured in a number of subtests, because a single sub-test
failing to compile a shader will prevent the remaining tests from
running.
I guess this would ideally be the default behavior of
piglit_compile_shader_text(), but with >300 callers in tree it seems
rather difficult to change at this stage.
-rw-r--r-- | tests/util/piglit-shader.c | 20 | ||||
-rw-r--r-- | tests/util/piglit-shader.h | 1 |
2 files changed, 19 insertions, 2 deletions
diff --git a/tests/util/piglit-shader.c b/tests/util/piglit-shader.c index e8fe9c4f7..37cc7cc9f 100644 --- a/tests/util/piglit-shader.c +++ b/tests/util/piglit-shader.c @@ -122,7 +122,7 @@ shader_name(GLenum target) * Convenience function to compile a GLSL shader. */ GLuint -piglit_compile_shader_text(GLenum target, const char *text) +piglit_compile_shader_text_nothrow(GLenum target, const char *text) { GLuint prog; GLint ok; @@ -149,7 +149,8 @@ piglit_compile_shader_text(GLenum target, const char *text) info); fprintf(stderr, "source:\n%s", text); - piglit_report_result(PIGLIT_FAIL); + glDeleteShader(prog); + prog = 0; } else if (0) { /* Enable this to get extra compilation info. @@ -164,6 +165,21 @@ piglit_compile_shader_text(GLenum target, const char *text) return prog; } +/** + * Convenience function to compile a GLSL shader. Throws PIGLIT_FAIL + * on error terminating the program. + */ +GLuint +piglit_compile_shader_text(GLenum target, const char *text) +{ + GLuint shader = piglit_compile_shader_text_nothrow(target, text); + + if (!shader) + piglit_report_result(PIGLIT_FAIL); + + return shader; +} + static GLboolean link_check_status(GLint prog, FILE *output) { diff --git a/tests/util/piglit-shader.h b/tests/util/piglit-shader.h index e2eef0393..9208451a8 100644 --- a/tests/util/piglit-shader.h +++ b/tests/util/piglit-shader.h @@ -31,6 +31,7 @@ void piglit_get_glsl_version(bool *es, int* major, int* minor); GLuint piglit_compile_shader(GLenum target, const char *filename); +GLuint piglit_compile_shader_text_nothrow(GLenum target, const char *text); GLuint piglit_compile_shader_text(GLenum target, const char *text); GLboolean piglit_link_check_status(GLint prog); GLboolean piglit_link_check_status_quiet(GLint prog); |