PDA

View Full Version : GLSL linking error with Radeon 2400



santyhamer
07-27-2007, 02:49 PM
Hello,

i'm getting tons of "" errors with the Radeon 2400 and Catalyst 7.7 ( the latests ) on the glLinkProgramARB call.

My code is pretty simple:


//Create the GLSL program
shader.program = glCreateProgramObjectARB();
if ( 0==shader.program )
{
throw Exception(L"The glCreateProgramObjectARB returned NULL. Can't create GLSL program.");
}

//More local variables
GLcharARB info[8192];
GLsizei infoLen;
GLint vsResult, psResult, linkResult;

//-------------------------------------------------
//Vertex shader
//-------------------------------------------------
shader.vs = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
if ( 0==shader.vs )
{
throw Exception(L"The glCreateShaderObjectARB returned NULL."
L"Can't create GLSL fragment shader. Please sure your graphics card supports"
L"vertex shaders 2.0 or above.");
}

const char* vv = _vsCode.c_str();
glShaderSourceARB(shader.vs, 1, &vv, 0);
glCompileShaderARB(shader.vs);

glGetObjectParameterivARB(shader.vs, GL_OBJECT_COMPILE_STATUS_ARB, &vsResult);
glGetInfoLogARB(shader.vs,sizeof(info), &infoLen, info);
l_strInfo += info;

if ( vsResult!=0 )
{
glAttachObjectARB(shader.program, shader.vs);
}
else
{
throw Exception(L"Error compiling vertex shader: "+Utils::UTF8ToUNICODE(info)+
L"With defines : "+Utils::UTF8ToUNICODE(defines));
}

//-------------------------------------------------
//Pixel shader
//-------------------------------------------------
shader.ps = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
if ( 0==shader.ps )
{
throw Exception(L"The glCreateShaderObjectARB returned NULL."
L"Can't create GLSL fragment shader. Please sure your graphics card supports"
L"pixel/fragment shaders 2.0 or above.");
}

const char* pp = _psCode.c_str();
glShaderSourceARB(shader.ps, 1, &pp, 0);
glCompileShaderARB(shader.ps);

glGetObjectParameterivARB(shader.ps, GL_OBJECT_COMPILE_STATUS_ARB, &psResult);
glGetInfoLogARB(shader.ps,sizeof(info), &infoLen, info);
l_strInfo += info;

if ( psResult!=0 )
{
glAttachObjectARB(shader.program, shader.ps);
}
else
{
throw Exception(L"Error compiling fragment shader: "+Utils::UTF8ToUNICODE(info)+
L"With defines : "+Utils::UTF8ToUNICODE(defines));
}

//-------------------------------------------------
//Link shader. See http://oss.sgi.com/projects/ogl-sample/registry/ARB/fragment_shader.txt
//-------------------------------------------------
glDeleteObjectARB(shader.vs);//yes, delete them after both are attached
glDeleteObjectARB(shader.ps);

glLinkProgramARB(shader.program);
glGetObjectParameterivARB(shader.program, GL_OBJECT_LINK_STATUS_ARB, &linkResult);
glGetInfoLogARB(shader.program,sizeof(info), &infoLen, info);
l_strInfo += info;

if ( 0==linkResult )
{
throw Exception(L"Error linking GLSL program shader: "+Utils::UTF8ToUNICODE(info)+
L"With defines : "+Utils::UTF8ToUNICODE(defines));
}In the shader i'm using 10 "uniform sampler2D" and 2 "uniform samplerCube" ... which exceed 8 samplers, but the # texture units of the Rad2400 is 16.

Any idea why please? Btw, works ok with an NVIDIA, perhaps is an ATI bug with the new cards only?

santyhamer
07-27-2007, 02:58 PM
The link error i'm getting is

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

and i'm getting it just after the glLink call

Korval
07-27-2007, 04:21 PM
It sounds like there are multiple uniform samplers with the same name, probably from different files. We would need to see your shader code to verify this.

sqrt[-1]
07-27-2007, 10:57 PM
I don't know about it being a link error, but it is a shader validation error (error preventing shader being used to render) to have samplers of different types pointing to the same image unit.

Eg. You cannot have a sampler2D and a samplerCube equaling zero.

You sure it fails on the link and not on a validation pass after the link?

Also I have had trouble with ATI drivers in the past with deleting attached shader objects before linking - yes this is a bug. So try and delete these lines and see what happens:

glDeleteObjectARB(shader.vs);
glDeleteObjectARB(shader.ps);

santyhamer
07-28-2007, 09:47 PM
[/QUOTE]Originally posted by sqrt[-1]:
You sure it fails on the link and not on a validation pass after the link?
[/QUOTE]

Yep, the warning appears just after the glLink call(filing the output string with the validation warning message). I don't call glValidate at all.



Also I have had trouble with ATI drivers in the past with deleting attached shader objects before linking - yes this is a bug. So try and delete these lines and see what happens:

glDeleteObjectARB(shader.vs);
glDeleteObjectARB(shader.ps); [/QB][/QUOTE]
Nothing changed 8( Error persist with those lines and without them.

Well... my shader is very simple, like:


uniform sampler2D tex1, tex2, tex3, tex4, tex5, tex6, tex7, tex8, tex9, tex10;

uniform samplerCube cube1, cube2;

varying vec2 uv;
varying vec3 uvCube;

void main ()
{
vec4 res = texture2D(tex1,uv);
res += texture2D(tex2,uv);
res += texture2D(tex3,uv);
res += texture2D(tex4,uv);
res += texture2D(tex5,uv);
res += texture2D(tex6,uv);
res += texture2D(tex7,uv);
res += texture2D(tex8,uv);
res += texture2D(tex9,uv);
res += texture2D(tex10,uv);
res *= textureCube(cube1,uvCube);
res *= textureCube(cube2,uvCube);

gl_FragColor = clamp(res/12.0,0.0,1.0);
}Works with my GeForce 8500, Radeon X1950... but shows the validation warning with the Rad 2400Pro...so perhaps is a bug just for the newest cards...

I suspect is related to max.8 texture units... but the caps shows 16 textures units max... Or pehaps it is not resetting well the uniforms when you create a new shader...

Tryed also with catalyst 7.6 instead of the 7.7... but got the same problem.

Humus
07-30-2007, 10:12 PM
Originally posted by santyhamer:
The link error i'm getting is

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

and i'm getting it just after the glLink call You have to call glUniform1i() to assign each sampler to an image unit. The default uniform value is 0, so by default all samplers point to unit 0, and you can't have multiple samplers of different types pointing to the same unit.

santyhamer
07-31-2007, 10:43 AM
Originally posted by Humus:
You have to call glUniform1i() to assign each sampler to an image unit. The default uniform value is 0, so by default all samplers point to unit 0, and you can't have multiple samplers of different types pointing to the same unit. So I need to call glUniform BEFORE glLink? I usually do that after the glLink ... so it allows me to load and compile shaders, then get the uniform handles and assign the texture units...

santyhamer
07-31-2007, 10:59 AM
I usually do:

1) LoadShader ( with includes glCreateProgramObjectARB, glCreateShaderObjectARB, glLinkProgramARB as indicated on the mentioned code )

2) m_billboardShader.baseTex = glGetUniformLocationARB(m_billboardShader.program, "baseTex"); //get uniform handles

3) glUniform1iARB ( m_billboardShader.baseTex, 3 ); //assign texture unit

4) ....

5) glUseProgramObjectARB and paint object ( in the rendering loop )

That sequence worked well on NVIDIA and Radeon 9500. Fails only on Radeon2XXX with that validation message returned in the glLink. It is curious but if I only use 8 texture samplers max works ok... when I pass 8 all goes bad(but I don't understand why, max tex units returned is 16 )

Brolingstanz
07-31-2007, 05:37 PM
4) ....This is probably where everything goes horribly wrong.

sqrt[-1]
07-31-2007, 06:02 PM
Originally posted by Humus:

Originally posted by santyhamer:
The link error i'm getting is

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

and i'm getting it just after the glLink call You have to call glUniform1i() to assign each sampler to an image unit. The default uniform value is 0, so by default all samplers point to unit 0, and you can't have multiple samplers of different types pointing to the same unit. That is what I said above, it makes sense for validation, but not for linking...

santyhamer
07-31-2007, 06:13 PM
Originally posted by modus
4) ....
This is probably where everything goes horribly wrong.
Nah, the error is produced in the glLink function. The program does not even each the 4) stage [Razz]


Originally posted by sqrt[-1]:
That is what I said above, it makes sense for validation, but not for linking...Yep, I agree. Surely is something related with the Rad2400 drivers + texture units limits because with other cards works well ( and I use glExpert feature on the NVIDIA instrumented drivers and shows no warnings )

Anybody with Catalyst 7.7 + any Radeon 2XXX can confirm using more than 8 texture samplers in a shader works ok, pls? ( unless i am completely wrong and it cannot support max. 16 texture units as i'm getting with the glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB) )

santyhamer
07-31-2007, 06:27 PM
Oh btw, i'm using Windows XP SP2 x86.. not Vista neither other broken OS :p Just to discard things.

santyhamer
08-02-2007, 08:59 PM
I just hope won't be this:

http://www.digitimes.com/mobos/a20070801PD209.html

btw, anybody know what affects that Radeon 2400/2600 BIOS bug?

santyhamer
08-18-2007, 03:09 PM
Catalyst 7.8 gives me the same result 8(
Keeps giving me the "Validation failed - samplers of different types are bound to the same texture image unit" on glLinkProgramARB when using more than 8 texture samplers...

Humus
08-18-2007, 05:34 PM
Doesn't the shader link for you btw? AFAICT this is just a spurious message in the infolog rather than a linking problem.

santyhamer
08-18-2007, 07:59 PM
Originally posted by Humus:
Doesn't the shader link for you btw? AFAICT this is just a spurious message in the infolog rather than a linking problem. Links ok, is just a warning error... but when I apply the shader using more than 8 texture samplers all is messed. See:

Image with Catalyst 7.8, Radeon 2400 Pro ( with validation warning ):

http://img181.imageshack.us/img181/6945/rad2400badqu0.jpg

Image with Catalyst 7.8, Radeon 9500 ( no validation warning ) or ForceWare 162.18 GeForce8500 ( no validation warning neither )
http://img181.imageshack.us/img181/889/rad9500gf8500okzl9.jpg

Like glExpert reports no error and works with Rad9500 and NVIDIA I bet is a driver bug for newest ATI cards. I can give you the program to test if ya need... do not download from the official page, i'm making some modifications...

Jan
08-19-2007, 03:24 AM
So you are the guy behind xNormal. Nice tool!

Jan.

Humus
08-19-2007, 10:16 AM
Originally posted by santyhamer:
I can give you the program to test if ya need... do not download from the official page, i'm making some modifications... Ok, please send it to me at emil.persson 'at' amd.com and I'll take a look at it.

santyhamer
08-19-2007, 10:44 AM
thx Humus, gonna send it asap