varying array set inside function using "out" fails

A varying array inside a function cannot be set if its passed in using “out”. This (I believe) is a bug, since the “out” key word specifies that the variable passed in should be set. I have a simple program that shows this behavior. A simple fix is to change the “out” to an “inout”. The “out” keyword works fine on other cards, but fails on NVidia cards on Linux (driver version 331.38).

I came across this when implementing SMAA (http://www.iryoku.com/smaa/), where they pass arrays to a few functions to be set.

If I find out how to attach the example program in this forum, I will.

vertex shader:

varying vec4 offset[3];
void setOffsets(out vec4 offsetv[3]){ // FAILS
//void setOffsets(inout vec4 offsetv[3]){ // WORKS (out -> inout)
offsetv[0] = vec4(1., 0.,0.,1.);
}
void setOffset(out vec4 offsetv){
offsetv = vec4(0., 1.,0.,1.);
}
void main()
{
setOffsets(offset); // FAILS (should render RED) unless out -> inout above
// setOffset(offset[0]); // WORKS (renders GREEN)
// offset[0] = vec4(0.,0.,1.,1.); // WORKS (renders BLUE)
gl_Position = ftransform();
}

fragment shader:

varying vec4 offset[3];

void main()
{
gl_FragColor = offset[0];
}

FYI I submitted a pull request to SMAA that implements this workaround https://github.com/iryoku/smaa/pull/6