diff options
author | Paul Berry <stereotype441@gmail.com> | 2011-07-29 13:18:15 -0700 |
---|---|---|
committer | Paul Berry <stereotype441@gmail.com> | 2011-08-11 13:13:51 -0700 |
commit | 8a3e129ccfe2313a3ae6c4b4855bb8082c78585d (patch) | |
tree | c1a31677d5064df966fe631f63bc4c49280300af /tests | |
parent | 76c27e1327fa6e28afeb7f5bb82750913b25cbbe (diff) |
Add constant array size builtin tests.
This patch adds a new set of generated tests which parallels those
introduced by commt cccc419e (Add comprehensive tests of builtin
functions with uniform input.)
The new tests validate the correctness of built-in functions when used
to compute array sizes. The tests work by creating arrays whose size
is 1 if the result of applying the built-in function is within
tolerance of the correct answer, and -1 if not. Since negative array
sizes are prohibited, any improperly computed values will generate a
compile error.
Though it may seem absurd to compute an array size based on the result
of calling a built-in function, it's worth testing for two reasons:
(1) It is explicitly allowed in GLSL versions since 1.20.
(2) Since array sizes need to be computed at compile time, this is a
convenient way of testing that the GLSL compiler properly implements
constant folding of built-in functions. Indeed, the original
motivation for these tests was to validate bug fixes to Mesa's
constant folding logic.
Here is an example of one of the generated tests (this test is
exp2-vec2.vert):
/* [config]
* expect_result: pass
* glsl_version: 1.20
* [end config]
*
* Check that the following test vectors are constant folded correctly:
* exp2(vec2(-2.0, -0.66666669)) => vec2(0.25, 0.62996054)
* exp2(vec2(0.66666669, 2.0)) => vec2(1.587401, 4.0)
*/
void main()
{
float[distance(exp2(vec2(-2.0, -0.66666669)), vec2(0.25, 0.62996054)) <= 6.7775386e-06 ? 1 : -1] array0;
float[distance(exp2(vec2(0.66666669, 2.0)), vec2(1.587401, 4.0)) <= 4.3034684e-05 ? 1 : -1] array1;
gl_Position = vec4(array0.length() + array1.length());
}
Diffstat (limited to 'tests')
-rw-r--r-- | tests/all.tests | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests index 461d20fb..0de2e30b 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -745,6 +745,9 @@ spec['glsl-1.20'] = Group() import_glsl_parser_tests(spec['glsl-1.20'], os.path.join(os.path.dirname(__file__), 'spec', 'glsl-1.20'), ['preprocessor', 'compiler']) +import_glsl_parser_tests(spec['glsl-1.20'], + os.path.join(generatedTestDir, 'spec', 'glsl-1.20'), + ['compiler']) spec['glsl-1.20']['execution'] = Group() add_shader_test_dir(spec['glsl-1.20']['execution'], os.path.join(os.path.dirname(__file__), 'spec', 'glsl-1.20', 'execution'), |