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 5 of 5

Thread: Problems with TBO on ATI

  1. #1
    Junior Member Newbie
    Join Date
    May 2009
    Location
    Budapest, Hungary
    Posts
    28

    Problems with TBO on ATI

    Hi!

    I have problems with Texture Buffer Objects on ATI. After a lot of searcing for the cause I finally made a simple shader like this:

    vertex shader:
    Code :
    #version 330
     
    precision highp float;
     
    layout(location = 0) in vec4 vPosition;
     
    void main()
    {
    	gl_Position = vPosition;
    }


    fragment shader:
    Code :
    #version 330
     
    precision highp float;
     
    layout(location = 0) out vec4 fragColor;
     
    uniform samplerBuffer texBuf;
    uniform int screenWidth;
     
    void main()
    {
    	int offset = int(gl_FragCoord.y) * screenWidth + int(gl_FragCoord.x);
    	vec4 color = texelFetch(texBuf, offset);
    	fragColor = color;
    }


    It works as excepted, the test RGBA8 buffer texture set up for a fullscreen quad with an image is rendered correctly with these shaders. Works on NV and ATI too.

    The problems arise when I want to use some other uniform. The following shader should set the green channel output to 1 when I load an identity matrix into modelViewProjMat.

    vertex shader:
    Code :
    #version 330
     
    precision highp float;
     
    layout(location = 0) in vec4 vPosition;
    uniform mat4 modelViewProjMat;
     
    out mat4 test;
     
    void main()
    {
    	test = modelViewProjMat;
    	gl_Position = vPosition;
     
    	//gl_Position = modelViewProjMat * vPosition;
    }

    fragment shader:
    Code :
    #version 330
     
    precision highp float;
     
    layout(location = 0) out vec4 fragColor;
     
    in mat4 test;
     
    uniform samplerBuffer texBuf;
    uniform int screenWidth;
     
    void main()
    {
    	int offset = int(gl_FragCoord.y) * screenWidth + int(gl_FragCoord.x);
    	vec4 color = texelFetch(texBuf, offset);
    	fragColor = color;
    	fragColor.g = test[0].x;
    }

    On NV it works as expected, fragColor.g is 1. Unfortunately on ATI, fragColor.g is 0. As I checked, I found that all components of modelViewProjMat is 0 whatever I set them. Without the texel fetch the modelViewProjMat is correctly loaded into the shader program.
    There's no OpenGL errors raised, the location for the modelViewProjMat uniform is non-negative, so I can only think that it's a driver bug. It happen with a Radeon 4850 with Catalyst 11.12 on Vista 64 bit.

    If anyone have found a similiar problem any help is appreciated. Thanks

  2. #2
    Intern Newbie
    Join Date
    Sep 2011
    Posts
    32

    Re: Problems with TBO on ATI

    Will you like to show what your geometry like? I could not produce your problem with my code snippet. Matrix interpolation is working as expected.
    Senior Engineer, OpenGL driver, AMD

  3. #3
    Junior Member Newbie
    Join Date
    May 2009
    Location
    Budapest, Hungary
    Posts
    28

    Re: Problems with TBO on ATI

    Ok, I'm sorry, it was my fault. I intercepted the uniforms using the glGetProgram and glGetActiveUniform functions. What I missed is that the location of the uniform and the index used for GetActiveUniform is not the same. For some reasons, the 3 uniforms of the upper program have locations 16, 17 and 18.
    But I think glUniform should generate some error if I try to use it with locations 0, 1 and 2.

  4. #4
    Intern Newbie
    Join Date
    Sep 2011
    Posts
    32

    Re: Problems with TBO on ATI

    Quote Originally Posted by thekend
    But I think glUniform should generate some error if I try to use it with locations 0, 1 and 2.
    It won't generate any errors at fact. The location of uniforms are generated in compiling. Usually, locations are filled in order, which means your 0, 1, 2 are filled by other hidden uniforms. That is because in many cases, driver will patch the user shader code for some specific purposes. Some uniforms are inserted into user shader. It is very important to make sure your uniform location is correct.
    Senior Engineer, OpenGL driver, AMD

  5. #5
    Junior Member Newbie
    Join Date
    May 2009
    Location
    Budapest, Hungary
    Posts
    28

    Re: Problems with TBO on ATI

    Quote Originally Posted by Hongwei Li
    It won't generate any errors at fact. The location of uniforms are generated in compiling. Usually, locations are filled in order, which means your 0, 1, 2 are filled by other hidden uniforms. That is because in many cases, driver will patch the user shader code for some specific purposes. Some uniforms are inserted into user shader. It is very important to make sure your uniform location is correct.
    Yes, I keep in mind that. Thanks for the answer.

Posting Permissions

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