PDA

View Full Version : Error validating shaders / can't send samplers



abhishek bansal
11-28-2010, 05:11 AM
hi all,

i am working on a volume rendering project for that i need to implement raycasting algorithm, but my shaders are behaving strangely...problem is that i m not able to send my volume_data & transfer_func textures to my fragment shaders properly..here is the code where i m sending these samplers to shader



glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_3D, volume_texture);
glUseProgram(p);
parameterLocation = glGetUniformLocation(p,"volumeData");
glUniform1i(parameterLocation,0);

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_1D, tf_texture);
glUseProgram(p);
parameterLocation = glGetUniformLocation(p,"transferFunction");
glUniform1i(parameterLocation, 1);


i tried to experiment with glActiveTexture i.e i tried to change n in GL_TEXTUREn and shader validator show errors for different textures i.e. in present configuration it shows following error

Program 3 linker: Validation warning! - Sampler value volumeData has not been set in fragment shader
Validation successful.

if i reverse the values it will show same error for transferfunction..

here is my fragment shader..


uniform sampler3D volumeData;
uniform sampler1D transferFunction;
varying vec3 texCoord;
uniform vec3 xCameraPosition;
uniform vec3 bboxMin;
uniform vec3 bboxMax;
uniform float step;
uniform int steps;
uniform vec3 bgColor;

void main(void)
{
vec3 rayOrigin = texCoord;
vec3 rayDir = normalize(rayOrigin - xCameraPosition);
vec3 position = rayOrigin;
vec4 finalColor = vec4(0.0, 0.0, 0.0, 0.0);
vec3 zarroVector = vec3(0, 0, 0);
for (int i = 0; i < steps; ++i)
{
position += step * rayDir;
if (any(greaterThan(position, bboxMax)) || any(lessThan(position, bboxMin)))
{
break;
}
float density = texture3D(volumeData, position).r;
vec4 color = texture1D(transferFunction, density);

finalColor += vec4(color.rgb * (1.0 - color.a) * step, color.a);

if (finalColor.a > .6)
{
break;
}
}

gl_FragColor = vec4(finalColor.rgb * finalColor.a + (1.0 - finalColor.a) * bgColor, 1.0);
}


here is where i am validating my program..


static void validateProgram(GLuint program) {
const unsigned int BUFFER_SIZE = 1024;
char buffer[BUFFER_SIZE];
memset(buffer, 0, BUFFER_SIZE);
GLsizei length = 0;

memset(buffer, 0, BUFFER_SIZE);
glGetProgramInfoLog(program, BUFFER_SIZE, &amp;length, buffer);
if (length > 0)
cout << "Program " << program << " linker: " << buffer << endl;

glValidateProgram(program);
GLint status;
glGetProgramiv(program, GL_VALIDATE_STATUS, &amp;status);
if (status == GL_FALSE)
cout << "Error validating shader : returned false" << program << endl;
}


My graphic card is ATI radeon 5470 HD mobility and it supports shader model 3.0 and opengl 3.2....please help as i m stuck very badly...

thank you

Dark Photon
11-28-2010, 07:56 PM
Hmmm. You're getting a "Validate" warning from "before" you actually call glValidateProgram. Odd.

I don't definitely know the answer to your problem, but here are two related things that might help. First, when porting a GL app to ATI, we noticed that glValidateProgram did something useful. On NVidia, we never had any complaints from glValidateProgram, but ATI/AMD does seem to at least validate the bound program against the textures that are bound to the texture units to verify that they're compatible.

Second, we don't call glGetProgramInfoLog, but instead use:



glCompileShader
glGetShaderiv( shaderObject, GL_COMPILE_STATUS, &amp;compiled );
if ( !compiled )
...
glLinkProgram
glGetProgramiv ( handle, GL_LINK_STATUS, & linked );
if ( !linked )
...
glValidateProgram
glGetProgramiv( programObject, GL_VALIDATE_STATUS, &amp;validated );
if ( !validated )
...

So there is no case where we just query the prog info log without some kind of an error being flagged.

If one is flagged, then we query it for the program or shader via:



glGetObjectParameterivARB( handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, & maxlen );


Might try that. Not sure exactly why you're seeing what you're seeing yet, but this may help you nail down a test prog to mail to ATI (if in-fact it's their bug).

linqunzju
11-29-2010, 01:34 AM
It seems it is a driver issue. Driver should only report "Validation successful.". This warning will not affect the finial results, since the GL_VALIDATE_STATUS is correct.

We will fix the warning issue ASAP.

abhishek bansal
11-29-2010, 04:05 AM
It seems it is a driver issue. Driver should only report "Validation successful.". This warning will not affect the finial results, since the GL_VALIDATE_STATUS is correct.

are u sure it is a driver error ...?? because my shader is not working as expected..it means i am making mistake in my c++ code..!!
i will check my code than..
thank you

Dark Photon
11-29-2010, 06:24 AM
If one is flagged, then we query it for the program or shader via:

glGetObjectParameterivARB( handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, & maxlen );

Should have said:


glGetObjectParameterivARB( handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, & maxlen );
...in combination with...
glGetInfoLogARB


So abhishek bansal, suggest do not query the log unless a shader fails to compile or a program object fails to link or validate. That may work around the driver issue.

abhishek bansal
11-29-2010, 08:27 AM
So abhishek bansal, suggest do not query the log unless a shader fails to compile or a program object fails to link or validate. That may work around the driver issue.


ya i already have done that...now there are no warnings (since infolog is only called after a failure in /linking/validation) but my shader still don't work...by any means is there a possibility that my samplers are not getting values and that warning was right ???

thank u for your genereous help