From 40d469f9ac45dfb825364af7a0436346c13502d6 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 9 Apr 2013 19:51:41 -0700 Subject: [PATCH] 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 Reviewed-by: Kenneth Graunke --- src/glsl/link_varyings.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 -- 2.30.2