[Mesa-dev] [PATCH v2 05/23] glsl: Fail to link if inter-stage input/outputs are not assigned to stream 0

Iago Toral itoral at igalia.com
Wed Jul 29 23:49:46 PDT 2015


On Wed, 2015-07-29 at 21:58 +0200, Marek Olšák wrote:
> Hi,
> 
> Where does the spec say we should fail to link? I don't see such a
> statement there.

I have reviewed ARB_gpu_shader5 and I don't see any specific mentions to
what should be done in this particular case. That said, isn't this the
logical thing to do? It is a programming error to link an FS input to a
GS output bound to a non-zero stream and at best the program would have
undefined behavior if the FS input is used. Hiding this from the
developer silently does not seem to be a good idea in any case, whatever
the developer was trying to accomplish he is doing it wrong.

> It looks like varyings with stream > 0 should not be linked with the
> fragment shader.

How is this better?

FWIW, the proprietary nVidia driver also fails to link in this case with
this error:

"output 'var_name' is associated with an input with a non-zero stream,
which is not allowed"

Iago

> Marek
> 
> On Wed, Jun 18, 2014 at 11:51 AM, Iago Toral Quiroga <itoral at igalia.com> wrote:
> > Outputs that are linked to inputs in the next stage must be output to stream 0,
> > otherwise we should fail to link.
> > ---
> >  src/glsl/link_varyings.cpp | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
> > index 9725a43..3b20594 100644
> > --- a/src/glsl/link_varyings.cpp
> > +++ b/src/glsl/link_varyings.cpp
> > @@ -1345,6 +1345,14 @@ assign_varying_locations(struct gl_context *ctx,
> >           if (input_var || (prog->SeparateShader && consumer == NULL)) {
> >              matches.record(output_var, input_var);
> >           }
> > +
> > +         /* Only stream 0 outputs can be consumed in the next stage */
> > +         if (input_var && output_var->data.stream != 0) {
> > +            linker_error(prog, "output %s is assigned to stream=%d but "
> > +                         "is linked to an input, which requires stream=0",
> > +                         output_var->name, output_var->data.stream);
> > +            return false;
> > +         }
> >        }
> >     } else {
> >        /* If there's no producer stage, then this must be a separable program.
> > --
> > 1.9.1
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 




More information about the mesa-dev mailing list