[Mesa-dev] [PATCH 15/34] glsl/linker: Properly error check VS-GS linkage.

Ian Romanick idr at freedesktop.org
Wed Jul 31 17:22:56 PDT 2013


On 07/28/2013 11:03 PM, Paul Berry wrote:
>  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.
> ---
>   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 2c7e451..07b5699 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_ARB) {

Use the undecorated name.

> +            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
>



More information about the mesa-dev mailing list