Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: ati and shadow texture lockups

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    29

    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!

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2007
    Posts
    269

    Re: ati and shadow texture lockups

    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:
    Code :
     sampler1D a;
     sampler2D b;
    this shader source could compile and link. But if the two samplers point to the same texture unit:

    Code :
    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:
    Code :
     sampler2D a;
     sampler2D b;
    this shader will compile and link. If the two samplers point to the same texture unit:

    Code :
    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."

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    29

    Re: ati and shadow texture lockups

    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 ?! :|
    i dont get it

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

  4. #4
    Member Regular Contributor
    Join Date
    Apr 2007
    Posts
    269

    Re: ati and shadow texture lockups

    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".

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    29

    Re: ati and shadow texture lockups

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

  6. #6
    Member Regular Contributor
    Join Date
    Apr 2007
    Posts
    269

    Re: ati and shadow texture lockups

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •