Ati and shadow texture lockups

hi

I have a strange problem with glsl shader.
On nvidia it compiles, links, validates and runs just fine.
On ATI (ATI Radeon HD 4800, GL:2.1.8577) it compiles, links
but validation fails with this message:

Validation failed! - Different sampler types for same sample texture unit in fragment shader

in the shader there are samplers:

uniform sampler2D _IN_NormalsTexture;
uniform sampler2D _IN_SColorsTexture;
uniform sampler2D _IN_LNDepthTexture;
uniform sampler2DShadow _IN_ShadowMapTexture;

_IN_NormalsTexture, _IN_SColorsTexture and _IN_LNDepthTexture are accesed just once by texture2D()
and _IN_ShadowMapTexture is accesed 4 times with shadow2DProj()
so i do not see any problems (for example accesing sampler2D with shadow2DProj or such)
so why the shader do not validates on ATI ??? any ideas ?

Is glsl on ati have some weird limitations on shadow texture lockups ?
(HD series under DirectX10 behaves just like nvidia, so hardware supports filtered shadow map lockups)

The shader is spaghetti style couse it is generated by CG from hlsl source.
the full source is here http://mxadd.org/trash/shader.txt

Thanks for any ansfers!

I think ATI behavior is right.

*  spec 2.1 page 83 Samplers section: "It is not allowed to have variables of different sampler types pointing to the same texture image unit within a program object. This situation can only be detected at the next rendering command issued, and an INVALID OPERATION error will then be generated."
* Interpretation: 

 sampler1D a;
 sampler2D b;

this shader source could compile and link. But if the two samplers point to the same texture unit:


GLint la=GetUniformLocation(prog,"a");
glUniform1i(la,0); // on texture unit 0
GLint la=GetUniformLocation(prog,"b");
glUniform1i(lb,0); // on texture unit 0

glValidateProgram(prog); will fail.

* spec 2.1 page 84 Samplers section:"Each active sampler variable counts against the limit, even if multiple samplers refer to the same texture image unit." 

* Interpretation: 

 sampler2D a;
 sampler2D b;

this shader will compile and link. If the two samplers point to the same texture unit:


GLint la=GetUniformLocation(prog,"a");
glUniform1i(la,0); // on texture unit 0
GLint la=GetUniformLocation(prog,"b");
glUniform1i(lb,0); // on texture unit 0

glValidateProgram(prog); will pass.

* spec 2.1 page 84 Samplers section:"If this cannot be determined at link time, for example if the program object only contains a vertex shader, then it will be determined at the next rendering command issued, and an INVALID OPERATION error will then be generated." 

* Interpretation: this makes more sense when reading spec 2.1 page 87 Validation section: "This [ndlr invalidate] error is generated [...] if · any active sampler in the current program object refers to a texture image unit where fixed-function fragment processing accesses a texture target that does not match the sampler type, or · the sum of the number of active samplers in the program and the number of texture image units enabled for fixed-function fragment processing exceeds the combined limit on the total number of texture image units allowed."

wait a minute – why this is right ?

int tex0 = glGetUniformLocationARB(LinkedProgram, “_IN_NormalsTexture”);
int tex1 = glGetUniformLocationARB(LinkedProgram, “_IN_SColorsTexture”);
int tex2 = glGetUniformLocationARB(LinkedProgram, “_IN_LNDepthTexture”);
int tex3 = glGetUniformLocationARB(LinkedProgram, “_IN_ShadowMapTexture”);

glActiveTextureARB(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, NormalMapTexture);
glEnable(GL_TEXTURE_2D);
glUniform1iARB(tex0, 0);

glActiveTextureARB(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, ColorMapTexture);
glEnable(GL_TEXTURE_2D);
glUniform1iARB(tex1, 1);

glActiveTextureARB(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, LDepthMapTexture);
glEnable(GL_TEXTURE_2D);
glUniform1iARB(tex2, 2);

glActiveTextureARB(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, ShadowMapTexture);
glEnable(GL_TEXTURE_2D);
glUniform1iARB(tex3, 3);

glValidateProgramARB(LinkedProgram);

every sampler has its own unit - so why the hell validation fails ?! :expressionless:
i dont get it :stuck_out_tongue:

  • i validate my linked programs when they are first time used
    just before executing draw call. (all states are set)

Did you make sure you call glUseProgram(LinkedProgram) before you call glUniform1iARB*() ?

glGetUniformLocationARB() takes the program you want in argument but glUniform1iARB*() works differently. glUniform1iARB*() works on the program “in use”.

yes, the program is bound - something weird behavior on ati IMHO

I agree something is wrong on the ATI side, then.

By the way, if you have a fragment shader, the following line has no effect at all:
glEnable(GL_TEXTURE_2D);

It just tells the fixed pipeline to use texture mapping.

Hi all

It seems I have similar problem. In my shader, first texture stage is reserved for base map, second for normal map and finally third one for shadow map. Validation fails with already mentioned output, additionally rendering fall back to software. If I comment shadow2Dproj it works just fine.

After ATI drivers reinstall I noticed that validation output (Different samplers types for …) disappeared, however result the same.

I couldn’t googled anything useful. Anything new in this case ?

regards
Martin

ps. my opengl version is 2.1 (ATI mobility xpress 1100)

Only radeons HD can shadow2Dproj in hardware.
The old radeons (not HD) cannot do shadow map lockups - the hardware is not capable.

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