<div dir="ltr">On 16 October 2013 16:56, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 10/16/2013 10:29 AM, Paul Berry wrote:<br>
> ---<br>
><br>
> I'm not 100% sure this is the right way to go, and here's why:<br>
><br>
> Taken together, all the GLSL specs except GLSL 4.30 and GLSL 4.40 tell<br>
> a consistent story: desktop shader versions 1.10 and 1.20 may be<br>
> linked together, and desktop shader versions 1.40 and above may be<br>
> linked together.  No other cross-version linking is allowed.<br>
><br>
> However, cross-version linking restrictions were explicitly removed in<br>
> GLSL 4.30 (the change is listed under "Summary of Changes from Version<br>
> 4.20 as "Remove cross-version linking restrictions.").  GLSL 4.30 and<br>
> 4.40 state that *any* version of desktop GLSL may be linked with any<br>
> other version of desktop GLSL.  (Note that cross-version linking is<br>
> still prohibited for ES shaders).<br>
<br>
</div>This came from a Khronos bug that I submitted.  The problem is that no<br>
other driver enforces the spec mandated restriction.  On top of that,<br>
you can't fully enforce the restriction (without draw-time errors) with<br>
separate shader objects.  I *thought* the change in 4.3 was to allow<br>
mixed versions between stages, but mixing versions within a stage is<br>
still forbidden.<br></blockquote><div><br></div><div>Looking at the specs, it appears that they removed the restriction for both intra- and inter-stage linking.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im"><br>
> This leads to a conundrum.  Normally when the GLSL spec changes from<br>
> one version to the next, we implement different rules depending on the<br>
> user-supplied "#version" directive.  But we can't do that for<br>
> cross-version linking rules since it's not clear which version of GLSL<br>
> should apply.  Should we:<br>
><br>
> (a) always follow pre-GLSL 4.30 linking rules, since we don't support<br>
> GLSL 4.30 yet?  (that's what this patch implements).<br>
><br>
> (b) always follow post-GLSL 4.30 linking rules, since they're probably<br>
> the clearest reflection of the Khronos board's intent?<br>
><br>
> (c) make some kind of dynamic determination of which set of rules to<br>
> follow?<br>
><br>
> FWIW, the NVIDIA proprietary driver for Linux (version 313.18) appears<br>
> to implement (b).<br>
<br>
</div>There are different cases: intrastage and interstage.  I assume they<br>
allow mixing interstage.  What about intrastage?<br></blockquote><div><br></div><div>That's a good point--when I tested this the other day, I only tested interstage.</div><div><br></div><div>I've just checked intrastage linking and I see the same behaviour: any version can be linked with any other version.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
>  src/glsl/linker.cpp | 28 ++++++++++++++++++++--------<br>
>  1 file changed, 20 insertions(+), 8 deletions(-)<br>
><br>
> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp<br>
> index 9095a40..1dac85c 100644<br>
> --- a/src/glsl/linker.cpp<br>
> +++ b/src/glsl/linker.cpp<br>
> @@ -2057,17 +2057,29 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)<br>
>        }<br>
>     }<br>
><br>
> -   /* Previous to GLSL version 1.30, different compilation units could mix and<br>
> -    * match shading language versions.  With GLSL 1.30 and later, the versions<br>
> -    * of all shaders must match.<br>
> +   /* For desktop GLSL, versions 1.10 and 1.20 may be linked together, and<br>
> +    * versions 1.40 and later may be linked together.  But version 1.30 may<br>
> +    * not be linked with any other version, and versions prior to 1.30 may not<br>
> +    * be linked to versions after 1.30.<br>
>      *<br>
>      * GLSL ES has never allowed mixing of shading language versions.<br>
>      */<br>
> -   if ((is_es_prog || max_version >= 130)<br>
> -       && min_version != max_version) {<br>
> -      linker_error(prog, "all shaders must use same shading "<br>
> -                "language version\n");<br>
> -      goto done;<br>
> +   if (is_es_prog) {<br>
> +      if (min_version != max_version) {<br>
> +         linker_error(prog, "all shaders must use same shading "<br>
> +                      "language version\n");<br>
> +         goto done;<br>
> +      }<br>
> +   } else {<br>
> +      if (min_version < 130 && max_version >= 130) {<br>
> +         linker_error(prog, "GLSL versions prior to 1.30 may not be linked "<br>
> +                      "with GLSL versions 1.30 and above\n");<br>
> +         goto done;<br>
> +      } else if (min_version == 130 && max_version > 130) {<br>
> +         linker_error(prog, "GLSL version 1.30 may not be linked with GLSL "<br>
> +                      "versions above 1.30\n");<br>
> +         goto done;<br>
> +      }<br>
>     }<br>
><br>
>     prog->Version = max_version;<br>
><br>
<br>
</div></div></blockquote></div><br></div></div>