PDA

View Full Version : varying struct?



knackered
04-19-2011, 09:37 AM
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?

Dark Photon
04-19-2011, 02:15 PM
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...

knackered
04-24-2011, 08:58 AM
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.

kyle_
04-24-2011, 09:48 AM
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.

Dark Photon
04-24-2011, 01:08 PM
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.
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.