Struct and interpolants

I returned to some GLSL that I updated some time ago. I had moved from an nVidia card to an ATI card and had left the script in what I thought was a complaint form, however a VP of…

out struct avShader
{
	out vec4 T;
	out vec3 N;
	out vec3 P;
} _CurShader;

in vec4 T;
void main()
{
	_CurShader.T = T;
}

now throws warnings and errors that this convention no longer works.
Any suggestions would be much appreciated!

GL version string is reported as: “4.0.10243 Compatibility Profile Context”
GLS: “4.00”

Thankx

ps I can probably avoid using structs in this way, but since Im sure I had it working, Id like to know why and what /if there has been a change to the specs… its very difficult to get proper info on structs for interpolating!

Any suggestions would be much appreciated!

Change your code.


struct avShader
{
  vec4 T;
  vec3 N;
  vec3 P;
};

out avShader _CurShader;

Though really, you should just use a named interface block.

Thanks yes, I seem to remember trying that struct convention and it not working unless I used the one I posted.

I just happened to notice interface blocks in the specs and that seems to be precisely what Im after so thanks!

So compiles ok, and Im guessing the warning error messages are client specific, but Im now getting following link error:

ERROR: error(#275) Symbol ‘_CurObject’ is defined with 2 different types between two stages
ERROR: error(#277) Symbol ‘_CurObject’ usage doesn’t match between two stages

that object is defined identically in both FP and VP as:

// Uniform settings provided by the current mesh
uniform struct avGeometry
{
	mat4 worldMatrix;
	int ObjectId;
};
uniform avGeometry _CurObject;

Cant see what the “difference” is!

“uniform” is used to declare variables. It isn’t used to declare structs unless you are declaring a variable of that struct’s type.

ah yes, thanks for pointing that out, although thats not the problem since removing the uniform qualifier for the struct declaration doesnt change the link errors.

there is no difference in declaration or use of that struct to any other I use now, so im guessing it has to be something within the specification of the uniforms in Gl…

I dont suppose you know where I can find the ATI link error documentation? I cant find any mention anywhere :stuck_out_tongue: thx

I dont suppose you know where I can find the ATI link error documentation?

I don’t know how that’s going to help you. The error is pretty self-explanatory. GLSL requires that the in/out interfaces are defined the same way, including struct definitions.

The ATI compiler thinks that they are not. Therefore, one of two things is happening. Either they actually are not defined identically, in which case you need to fix your shaders, or it’s a driver bug. ATI link error documentation isn’t going to fix your shaders or fix the driver bug.

Sure, but it should list some conditions under which the error is thrown that may not be obvious. The shader whilst relatively large isnt particularly complex and has run on this card before with the same catalyst drivers. Its just vanilla blinn, but with extensive parametrisation as uniform values are set from my scene graph.

Whilst I initially shared your optimism that its a case of following the error to a logical solution, the struct it mentions is byte for byte identical in both VP and FP.

There is a difference in that im now using GL through OpenTK rather than Tao (both C# Gl wrappers) so that could well have something to do with it.

Tao vs OpenTK shouldn’t make a difference, both are passing the shader text directly to the driver. This could be a driver error; or it could be a user error.

Try reading back the shader source using GL.GetShaderSource() and verify that it is identical to what you expect. (Sometimes text files can be saved with different encodings, which may throw drivers off).

It might also be a good idea to create a small, self-contained test case to see if others can reproduce the issue.

Finally, try updating your video drivers, as they seem to be out of date (Ati has released a 4.1 driver).

Yes, shouldnt make a difference, but its not a small program (over 400 cs files in all) so its not straight forward to fully isolate the problem, but I’ll see if I can reproduce the effect in a smaller test case. Since its an innocuous struct defined between others that arent presenting problems I suspect it may be a memory problem in the driver, or something. I might try reording to see if its just the unlucky one!

Thanks to everyone… found the problem… doesnt work with an int! Its highly stupid! Im pretty sure on nvidia it just casts from a uchar or whatever you pass. Oh well! Cheers

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