Varying struct?

i’m modifying some old glsl code (yeah right), and have discovered that i don’t seem to be able to use the ‘varying’ directive on a struct without getting a warning from the nvidia compiler…thus:


warning C7514: OpenGL does not allow varying of type struct LightVarying[1]

LightVarying is just this:-


struct LightVarying
{
   vec3 shadowcoord;
};
varying LightVarying var_lights[1];

is this true or is this an nvidia compiler bug?

Have never done and array of structs for varyings. But have used a single struct alone:


struct LightVarying
{
   vec3 shadowcoord;
};

#if defined( VERTEX_SHADER )
out Stuff { LightVarying var; };
#elif defined( FRAGMENT_SHADER )
in  Stuff { LightVarying var; };
#endif
...
var.shadowcoord = ...

Don’t think that helps you though…

i really despair at nvidias shader compiler. Nested constant controlled loops (not uniforms, friggin hard coded numbers) confuse the hell out of it. I’m sick of unrolling loops because their compiler is shite. It’s 2011 now and they’ve still got bugs doing straight c parsing. I wrote c parsers at A’level when I was 17. It’s a no-brainer.


Fragment inputs can only be signed and unsigned integers and integer vectors, floating
point scalars, floating-point vectors, matrices, or arrays or structures of these.

This rules out arrays of structures, so their compiler isn’t that bad.

Really? In my experience, it’s very good at nuking code that depends on constant expressions and evaluating it at compile time.

Try adding:


#pragma optionNV(unroll all)

Without this, seems it only unrolls loops up to ~4X by default. Solved a shader perf issue that way.

However once I switched to using uniform arrays, found I didn’t need that to get good perf since that performs better on the hardware.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.