Info log error: "Validation failed..."

Hello,

I’m currently writing a raycasting program with GLSL to render volume graphics. To do this I send two textures to the shader, one containing the volume data (3D sampler) and one containing the “end position” of the ray (2D sampler).

Since I’m quite a beginner at GLSL I’ve run into some basic problems already at the compilation stage.

The shader program seems to have a problem with me having two samplers, this is from the info log:

“Validation failed - samplers of different types are bound to the same texture image unit.”

Source code:
(vertex shader)

void main()
{
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

(fragment shader)

uniform sampler3D VolumeData;
uniform sampler2D BackfaceData;

void main()
{
vec3 RayStart = gl_Color.xyz;
vec3 RayEnd = texture2D(BackfaceData, gl_TexCoord[0].xy).xyz;
.
.
.
gl_FragColor = VoxColor;
}

(my program)

void CreateShaders()
{
const char
*VertexText = textFileRead(“vert.vsh”),
*FragmentText = textFileRead(“frag.vsh”);
.
.
.
VertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(VertexShader, 1, &VertexText, 0);
glCompileShader(VertexShader);

FragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(FragmentShader, 1, &FragmentText, 0);
glCompileShader(FragmentShader);

ShaderProgram = glCreateProgram();
glAttachShader(ShaderProgram, VertexShader);
glAttachShader(ShaderProgram, FragmentShader);

glLinkProgram(ShaderProgram);
.
.
.
}

I found a reference to this error in OpenGLwiki but the instructions on how to fix it is somewhat strange since it says the error occurs at linking and you fix it by assigning the samplers after linking. I’ve tried assigning the samplers before linking (glLinkProgram) but the problem remains.

The shaders’ log return no error.

When compiling the shaders with Typhoon Labs no errors are returned, this makes me believe the problem is in my program. Before CreateShaders is calles glew and glut are initialized.

Thank you for your help!

It means you assigned the same value to the uniform “VolumeData” and “BackfaceData”. Or you just forgot to assign any values (in which case the values are 0 or false for boolean values)

ref: OpenGL spec 2.1 page 79, Uniform Variables:
" When a program is successfully linked, all active uniforms belonging to the
program object are initialized to zero (FALSE for booleans). A successful link will
"

but you did not provide the code where you call “glUniform1i”
(remember that glUniform applied on the program in use, so you have to call glUseProgram() first)

GLint loc1=glGetUniformLocation(shaderProgram,“VolumeData”);
GLint loc2=glGetUniformLocation(shaderProgram,“BackfaceData”);

glUseProgram(shaderProgram);
if(loc1!=-1)
{
glUniform(loc1,0); // on texture unit 0
}
else
{
// not an active uniform
}

if(loc2!=-1)
{
glUniform(loc2,1); // on texture unit 1
}
else
{
// not an active uniform
}
then you can try to validate and see what kind of error you have in the log.

It means you assigned the same value to the uniform “VolumeData” and “BackfaceData”.

This is a GLSL linker error. He can’t have assigned any values to them, because until the linker runs, these values don’t exist yet.

“Validation failed” . This is not a linker error. I already get this kind of message and this was the root cause for me.

Kipt88,
what message do you get, if you insert the following code after glLinkProgram(ShaderProgram)?

GLint status;
glGetProgramiv(shaderProgram,GL_LINK_STATUS,&status);
if(status==GL_TRUE)
{
cout << “link succeeded” << endl;
}
else
{
cout << “link failed” << endl;
}

Can tell us how you get this log? From a debugging software?
or is it from glGetProgramInfoLog()?

glGetProgramInfoLog() is the link log after you called
glLinkProgram(shaderProgram), but it can be the validation log
if you called glValidateProgram(shaderProgram);

Note that validation happens automatically before the first rendering command. A rendering command is for example glBegin() or glDrawArrays().

Spec 2.1 page 93:
“It is not always possible to determine at link time if a program object actually will execute. Therefore validation is done when the first rendering command is issued, to determine if the currently active program object can be executed.”

This is the complete code (in my original post I left out the output / error checking):

const char
*VertexText = textFileRead(“vert.vsh”),
*FragmentText = textFileRead(“frag.vsh”);
char
InfoLog[MAX_INFO_LOG_LENGTH];
GLint
param,
InfoLogLen;

VertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(VertexShader, 1, &VertexText, 0);
glCompileShader(VertexShader);
glGetShaderiv(VertexShader, GL_COMPILE, &param);
if (param)
{
loPrint("Error while compiling Vertex Shader!

");
glGetShaderInfoLog(VertexShader, MAX_INFO_LOG_LENGTH, &InfoLogLen, InfoLog);
loPrint(InfoLog);
Quit();
}
else
loPrint("Vertex Shader compiled…
");

FragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(FragmentShader, 1, &FragmentText, 0);
glCompileShader(FragmentShader);
glGetShaderiv(FragmentShader, GL_COMPILE, &param);
if (param)
{
loPrint("Error while compiling Fragment Shader!
");
glGetShaderInfoLog(FragmentShader, MAX_INFO_LOG_LENGTH, &InfoLogLen, InfoLog);
loPrint(InfoLog);
Quit();
}
else
loPrint("Fragment Shader compiled…
");

ShaderProgram = glCreateProgram();
glAttachShader(ShaderProgram, VertexShader);
glAttachShader(ShaderProgram, FragmentShader);

glLinkProgram(ShaderProgram);
glGetProgramiv(ShaderProgram, GL_LINK_STATUS, &param);
if (param)
{
loPrint("Error while linking Shader Program!
");
glGetProgramInfoLog(ShaderProgram, MAX_INFO_LOG_LENGTH, &InfoLogLen, InfoLog);
loPrint(InfoLog);
Quit();
}
else
loPrint("Shader Program linked…
");

Quit() is simply exit() and some clean up actions. loPrint prints a string to log.txt in my project directory, with the shaders described in my original post the containts of log.txt is:

Vertex Shader compiled…
Fragment Shader compiled…
Error while linking Shader Program!
Fragment shader(s) linked, vertex shader(s) linked.
Validation failed - samplers of different types are bound to the same texture image unit.

But the error is discovered before this so there must be a validation before glGetProgramiv(ShaderProgram, GL_LINK_STATUS, &param); Since I can’t change the values of my samplers before glUseProgram and I call glGetProgramiv before this, I am at a loss to where I should call glUniform…

Ok, now I got it. glGetProgramiv causes the program to validate so by calling this after linking and assigning the uniforms I get no errors. However there are still something strange. When I call glGetProgramiv param returns GL_TRUE (1), but both glGetShaderiv returns GL_FALSE (0) but when I read the info log it just say:
“Fragment shader was successfully compiled to run on hardware.”

Can you simplify the fragment shader to the point where you still get the error, but it’s short enough for us to see? NVIDIA’s drivers are very optimization-happy, and may get confused with complex code.

Why do you write "if(param) { error} else { success } "?
param is set to GL_TRUE in case of success not in case of error.
Your if statement is wrong.

So your shaders don’t even compile.

I started out by using if (param) {success} else {error} but when I read my log it said: “Error while compiling Vertex Shader!
Vertex shader was successfully compiled to run on hardware.” whitch is very strange. So therefore I assumed (based on the error message) that if (param) {error} else {success} must be correct, but this can’t be true if param == GL_TRUE on success.

That’s very strange. Maybe you can tell use which graphics card/OS/driver version you have?

ATI Radeon HD 3600 series (supports OpenGL 2.1) on Windows XP.

(creating a new thread since the problem no longer fits the title)

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