Are vertex attributes in a fragment shader valid?

I want to create a unified shader file similar to the D3D FX format where vertex and fragment shaders are in one file. I have some technique annotations that I parse manually and I create a main function on the fly. I just send the complete shader code to the GLSL compiler, either as vertex or fragment shader. For a fragment shader, the vertex shader functions are just stripped out by the compiler since they are not called from my entry function. But I also have vertex attributes in this file of course.

Can I safely assume that the fragment shader parser will just ignore them without outputting errors? A quick look at the spec did not give me any info about that. It seems to work on NVidia drivers but I want to make sure that I don’t do anything “illegal” that could not work on other platforms/drivers.

Thanks in advance…

Can I safely assume that the fragment shader parser will just ignore them without outputting errors?

No, it will not. It is not legal to define a vertex attribute in a non-vertex shader. It certainly won’t in 1.3, with it’s “in/out” stuff.

Btw, NV’s 1.3 compiler is really good about dumping deprecation warnings to the logs. Got a slew of them right off the bat :wink: