Hi all,
I am facing a display issue on a w7100 card with catalyst 14.502 driver. I reduce the problem to a very simple one.
Generate a RGBA32F fbo.
Clear the fbo content to 0.
Draw a first textured-quad in this fbo
Draw a second textured-quad in this fbo
The quads are drawn using the following fragment shader:
uniform sampler2DRect src;
uniform sampler2DRect dst;
void main(void) {
vec4 dst = texture2DRect(dst, gl_FragCoord.xy);
vec4 src = texture2DRect(src, gl_TexCoord[0].xy);
src.rgb = src.rgb * 0.5f;
src.a = 0.5f;
gl_FragColor = src + dst;
}
Doing so, I accumulate the content of the 2 quads in the destination fbo.
Then, I draw the texture attached to the framebuffer on the display using the following fragment shader:
uniform sampler2DRect src;
void main(void) {
vec4 tex = texture2DRect(src, gl_TexCoord[0].xy);
if (tex.a != 0.0f) {
tex /= tex.a;
}
gl_FragColor = tex;
}
To ensure synchronisation between the read and write operations on the framebuffer, I both try glFlush/glFinish and using glFence. None of them give me a correct result.
I tested this very simple code on HD7700, W8000 and some other gpus, with no issues. I suppose something is wrong in my way of rendering, but there is change in the rendering behavior of Tonga family.
Could you please help me in fixing this simple thing ?
Regards,
Thomas
Solved! Go to Solution.
You can also look into Image Load Store - OpenGL.org
Are you reading and writing to the same texture at the same time? If so then it is undefined behaviour and if it somehow working then it is just a luck. If you just want add one texture to another you can just use additive blending. Look at glBlendEquation()
Hi,
Thanks for the fast answer. I am indeed read and writing to the same texture. I missed it is an undefined behavior (strange it was running fine for a such long time...).
Unfortunately, I am not doing simple texture addition, but it would be ok to introduced an intermediate texture.
Thanks,
Thomas
You can also look into Image Load Store - OpenGL.org
Thanks.
Thomas