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:
#version 330
precision highp float;
layout(location = 0) in vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
fragment shader:
#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:
#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:
#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