I'm trying to figure out why the following GLSL code doesn't work:
#ifndef VertexPositionType
#define VertexPositionType vec3
#endif
in StandardVertexShaderInputs {
VertexPositionType ds_VertexPosition;
};
vec4 ProjectVertexPosition(in vec4 v);
vec4 ProjectVertexPosition(in vec3 v);
void main() {
gl_Position = ProjectVertexPosition(ds_VertexPosition);
}
The shader refuse to compile. The info log state:
error C1008: undefined variable "ProjectVertexPosition"
Even if it doesn't warn about the preprocessor, I got that the preprocessor symbol VertexPositionType is not replaced. If I remove the preprocessor definitions, everything is fine.
Now, the specification says:
#define and #undef functionality are defined as is standard for C++ preprocessors for macro definitions both with and without macro parameters.
Perhaps the following line is not a valid preprocessor line?
#define VertexPositionType vec3
Your shader is illegal. NVIDIA's compiler may not be spitting out the right errors, but your shader is doing the wrong thing (well, besides the fact that you didn't provide a #version
declaration. I assumed #version 330
, but it's always good to be explicit about GLSL versions).
I can only assume this is a vertex shader, since you're writing to gl_Position
. Input interface blocks are illegal in vertex shaders, just as output interface blocks are illegal in fragment shaders. AMD's compiler is rather more explicit about this:
ERROR: 0:5: error(#328) interface block should not apply in 'Vertex Shader in'.
ERROR: 0:14: error(#143) Undeclared identifier ds_VertexPosition
ERROR: 0:14: error(#202) No matching overloaded function found ProjectVertexPosition
ERROR: 0:14: error(#160) Cannot convert from 'const float' to 'Position 4-component vector of float'
ERROR: error(#273) 4 compilation errors. No code generated
When I removed the interface block definition, leaving it as just in VertexPositionType ds_VertexPosition;
, it compiled fine.
If I remove the preprocessor definitions, everything is fine.
Then congratulations: you have found an NVIDIA driver bug. You should report it to them, because input interface blocks are not allowed in vertex shaders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With