summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-04-09 19:51:41 -0700
committerPaul Berry <[email protected]>2013-08-01 20:22:55 -0700
commit40d469f9ac45dfb825364af7a0436346c13502d6 (patch)
treea55aba12ed903c54aad74181c9eda192f225de23 /src
parent05234e707bb811e3807d260c1c6cac59a4f1820f (diff)
glsl/linker: Properly error check VS-GS linkage.
From section 4.3.4 (Inputs) of the GLSL 1.50 spec: Geometry shader input variables get the per-vertex values written out by vertex shader output variables of the same names. Since a geometry shader operates on a set of vertices, each input varying variable (or input block, see interface blocks below) needs to be declared as an array. Therefore, the element type of each geometry shader input array should match the type of the corresponding vertex shader output. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/link_varyings.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index e3c8142546d..a5a47f416ee 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -68,6 +68,10 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
/* Find all shader inputs in the "consumer" stage. Any variables that have
* matching outputs already in the symbol table must have the same type and
* qualifiers.
+ *
+ * Exception: if the consumer is the geometry shader, then the inputs
+ * should be arrays and the type of the array element should match the type
+ * of the corresponding producer output.
*/
foreach_list(node, consumer->ir) {
ir_variable *const input = ((ir_instruction *) node)->as_variable();
@@ -79,7 +83,12 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
if (output != NULL) {
/* Check that the types match between stages.
*/
- if (input->type != output->type) {
+ const glsl_type *type_to_match = input->type;
+ if (consumer->Type == GL_GEOMETRY_SHADER) {
+ assert(type_to_match->is_array()); /* Enforced by ast_to_hir */
+ type_to_match = type_to_match->element_type();
+ }
+ if (type_to_match != output->type) {
/* There is a bit of a special case for gl_TexCoord. This
* built-in is unsized by default. Applications that variable
* access it must redeclare it with a size. There is some