diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2011-11-10 10:25:32 -0800 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2011-12-21 11:19:11 -0800 |
commit | 0f4ea93299747296d0ace8edb26736e589da12dd (patch) | |
tree | b4eb2b0d7ef909843f240cf5c0d7170326b1ac40 /tests/spec/glsl-1.30/compiler | |
parent | 82aa5a6c34ade476e812064d2ca96dd7e5d8ff0d (diff) |
glsl-1.30: Verify that gl_Frag{Color,Data} and a function out can be written
These tests try to trick the GLSL compiler by writing a built-in
fragment shader output and a function "out" variable. The compiler is
supposed to generate an error if a built-in output and a user-defined
shader "out" variable are written. Writing to a built-in and a
funciton "out" should be allowed.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Diffstat (limited to 'tests/spec/glsl-1.30/compiler')
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-function-output.frag b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-function-output.frag new file mode 100644 index 000000000..ad5559ad3 --- /dev/null +++ b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-function-output.frag @@ -0,0 +1,29 @@ +/* [config] + * expect_result: pass + * glsl_version: 1.30 + * [end config] + * + * From page 68 of the GLSL 1.30 spec: + * + * "Similarly, if user declared output variables are in use (statically + * assigned to), then the built-in variables gl_FragColor and gl_FragData + * may not be assigned to. These incorrect usages all generate compile + * time errors." + * + * This test tries to trick the compiler by writing to gl_FragColor and an + * 'out' parameter of a function. This is valid. + */ +#version 130 + +void function(out vec4 f) +{ + f = vec4(1.0); +} + +void main() +{ + vec4 v; + + function(v); + gl_FragColor = v; +} diff --git a/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-function-output.frag b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-function-output.frag new file mode 100644 index 000000000..03cb8780e --- /dev/null +++ b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-function-output.frag @@ -0,0 +1,29 @@ +/* [config] + * expect_result: pass + * glsl_version: 1.30 + * [end config] + * + * From page 68 of the GLSL 1.30 spec: + * + * "Similarly, if user declared output variables are in use (statically + * assigned to), then the built-in variables gl_FragColor and gl_FragData + * may not be assigned to. These incorrect usages all generate compile + * time errors." + * + * This test tries to trick the compiler by writing to gl_FragColor and an + * 'out' parameter of a function. This is valid. + */ +#version 130 + +void function(out vec4 f) +{ + f = vec4(1.0); +} + +void main() +{ + vec4 v; + + function(v); + gl_FragData[0] = v; +} |