[Mesa-dev] [PATCH 4/6] glsl/linker: don't fail non static used inputs without matching outputs

Timothy Arceri tarceri at itsqueeze.com
Fri Feb 1 23:28:21 UTC 2019



On 2/2/19 5:05 am, Andres Gomez wrote:
> If there is no Static Use of an input variable, the linker shouldn't
> fail whenever there is no defined matching output variable in the
> previous stage.
> 
>  From page 47 (page 51 of the PDF) of the GLSL 4.60 v.5 spec:
> 
>    " Only the input variables that are statically read need to be
>      written by the previous stage; it is allowed to have superfluous
>      declarations of input variables."
> 
> Now, we complete this exception whenever the input variable has an
> explicit location. Previously, 18004c338f6 ("glsl: fail when a
> shader's input var has not an equivalent out var in previous") took
> care of the cases in which the input variable didn't have an explicit
> location.
> 
> Additionally, likewise 1aa5738e666 ("glsl: relax input->output
> validation for SSO programs"), avoid failing also for programs that
> utilize GL_ARB_separate_shader_objects.
> 
> Cc: Timothy Arceri <tarceri at itsqueeze.com>
> Cc: Iago Toral Quiroga <itoral at igalia.com>
> Cc: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
> Cc: Tapani Pälli <tapani.palli at intel.com>
> Cc: Ian Romanick <ian.d.romanick at intel.com>
> Signed-off-by: Andres Gomez <agomez at igalia.com>
> ---
>   src/compiler/glsl/link_varyings.cpp | 16 ++++++++++++++--
>   1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
> index e5f7d3e322a..6cebc5b3c5a 100644
> --- a/src/compiler/glsl/link_varyings.cpp
> +++ b/src/compiler/glsl/link_varyings.cpp
> @@ -808,8 +808,20 @@ cross_validate_outputs_to_inputs(struct gl_context *ctx,
>   
>                  output = output_explicit_locations[idx][input->data.location_frac].var;
>   
> -               if (output == NULL ||
> -                   input->data.location != output->data.location) {
> +               if (output == NULL) {
> +                  /* A linker failure should only happen when, for programs
> +                   * not using sso, there is no output declaration and there
> +                   * is Static Use of the declared input.
> +                   */
> +                  if (input->data.used && !prog->SeparateShader) {

This is not really what used was designed for so it's always a bit 
unsettling to see this type of thing.

However its better that what we do now and is consistent with 
18004c338f6 so this patch is:

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>


> +                     linker_error(prog,
> +                                  "%s shader input `%s' with explicit location "
> +                                  "has no matching output\n",
> +                                  _mesa_shader_stage_to_string(consumer->Stage),
> +                                  input->name);
> +                     break;
> +                  }
> +               } else if (input->data.location != output->data.location) {
>                     linker_error(prog,
>                                  "%s shader input `%s' with explicit location "
>                                  "has no matching output\n",
> 


More information about the mesa-dev mailing list