[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
Thu Jul 30 01:09:30 PDT 2015

On Thu, 2015-07-30 at 09:43 +0200, Marek Olšák wrote:
> On Thu, Jul 30, 2015 at 8:49 AM, Iago Toral <itoral at igalia.com> wrote:
> > 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?
> The spec simply says that varyings with stream > 0 are not passed to
> the rasterizer, which means the matching fragment shader inputs should
> be uninitialized, but it should still be possible to capture the
> varyings with transform feedback. That's how I understand the spec.

FWIW, I have tested this in the proprietary nVidia driver and the result
is the same, it fails to link even if that GS output is captured by TF.

My interpretation of the spec is that since GS outputs to stream 0 are
not passed down the pipeline they simply do not exist in the eyes of the
FS, that is, I see this situation as the same in which we declare an
input in the FS that is not declared as output in the GS. But it is true
that the spec does not address this situation explicitly, so I think
both interpretations could be valid.

I still think that failing to link is better though. If we report a link
failure the developer knows what is going on and the fix is trivial,
otherwise they will run into incorrect rendering, they will have to
figure out what is going and eventually fix the code anyway...

Since at least nVidia proprietary is failing to link as well in these
scenarios I guess our chances of running into shaders that we fail to
link for this reason and were expected to link properly are pretty small


More information about the mesa-dev mailing list