PDA

View Full Version : FBO Problem on ATI - driver bug?



__v__
11-05-2008, 08:18 AM
I have a simple piece of code that renders a shadow texture using FBO.
On NVIDIA, it works fine, but on ATI, the shadows are distorted.

When I check the shadow texture after rendering it to FBO, it appears to be exactly flipped upside-down compared to NVIDIA result. I can see no other problems with it.

In the code I can't really find anything that would explain this.

Problematic driver version: 8.523.1.1-080905a-069201C-ATI, ATI OpenGL driver 6.14.10.7287, Windows XP, ATI Mobility FireGL V5200. (Newest driver available for that laptop - I also tried newest Catalyst from ati.com and modded it with Mobility Modder.NET, but it had the same opengl dll and moreover, opengl didn't work at all, it fell back to software renderer).

Right now I can't test with any other ATI new enough to support FBO.

It looks to me very much like a driver problem, but it would be curious if nobody else would have run into it. Has anyone seen anything like this?



The code is roughly:



glGenFramebuffersEXT(1, &g_fbo.fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, g_fbo.fbo);

// Create the render buffer for depth
glGenRenderbuffersEXT(1, &g_fbo.frameBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, g_fbo.frameBuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, texwidth, texheight);

int format = GL_DEPTH_COMPONENT32_ARB;

glGenTextures(1, &texid);
glBindTexture(GL_TEXTURE_2D, texid);

int texwidth = 4096;
int texheight = 4096;
glTexImage2D(GL_TEXTURE_2D, 0, format,
texwidth, texheight, 0,
GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texid, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, g_fbo.frameBuffer);

GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);


glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, g_fbo.fbo);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
double width = lightDist * tan(lightAngle);
double height = double(width) * double(texwidth) / double(texheight);
glOrtho(-width / 2.0, width / 2.0, -height / 2.0, height / 2.0, nearDist, farDist);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
gluLookAt(lightPos.x, lightPos.y, lightPos.z,
lightFrustumCenter.x, lightFrustumCenter.y, lightFrustumCenter.z,
0.0f, 1.0f, 0.0f);
glViewport(0, 0, texwidth, texheight);

DrawObjects();

glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

skynet
11-05-2008, 01:10 PM
According to this thread
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=248188
this bug is fixed in Catalyst 8.10.
When this fix appears in the FireGL drivers is unclear.

__v__
11-06-2008, 06:52 AM
skynet, are you sure this is the same bug? The thread you refer to talks about vertex shaders, and my problem is about using FBO? They can be related of course, but I can't see the connection...

skynet
11-06-2008, 08:54 AM
Leadwerks says in this thread
So now my code works on AMD hardware. Never use gl_FragCoord unless you only target NVidia! The y component will be flipped on SOME AMD cards, with some drivers, sometimes only when rendering to an FBO. So even if it works on your test setup, you will have users complaining about upside-down images and other bad stuff.

So my guess was that his problem is related to yours.

I myself also have experiened the FBO-flipped-Y bug, but didn't check yet, if it is still present in 8.10.

__v__
11-07-2008, 12:38 AM
Ok, thank you.

I'll try to test newer Catalyst. The problem is, the laptop I'm seeing this on has the newest drivers from the vendors (HP) website and the ATI ones don't seem to work on it even when tweaked with Mobility Modder.NET.

I'll have to find a newer ATI desktop card to test this.