• Advertisement
Sign in to follow this  

FBO cubemap = slow

This topic is 3629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to implement shadowmapping using a cubemap FBO (render depth to RGB via frag shader), it works great on my GF8800 GTS (350 fps with single light, although I get around 600 with a single regular square map, but in terms of milliseconds that's not a huge difference). The problem is it seems to kill the performance on my laptop with a GF7600 Go. With a regular shadowmap I get around 60fps (and it only went down a couple of fps when I put a few more more in), but it goes down to 13 when I use a cubemap. It happens with both int and float texture formats, and regardless of if I have any form of texture filtering on or if there's anything drawn into it. Here's the way I initialise the FBO if it's of any help:
glGenFramebuffersEXT (1, &id);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, id);

glGenRenderbuffersEXT(1, &zbuf);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, zbuf);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
	GL_DEPTH_COMPONENT, width, height);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
	GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, zbuf);

glGenTextures(1, &img);
glBindTexture(GL_TEXTURE_CUBE_MAP, img);

glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8,
	width, height, 0,
	GL_RGBA, GL_UNSIGNED_BYTE, NULL);
.
.
.
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8,
	width, height, 0,
	GL_RGBA, GL_UNSIGNED_BYTE, NULL);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
	GL_TEXTURE_CUBE_MAP_POSITIVE_X, img, 0);
width and height are always equal and power-of-two. I've flung some timers around and it seems the time is begin spent mainly in (re-)binding the FBO and switching from face to face, which I do like so:
for(int face=0;face<6;face++) {
glBindFrameBufferEXT(GL_FRAMEBUFFER_EXT, id);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_BIT, GL_COLOR_ATTACHMENT0_EXT,
    GL_TEXTURE_CUBE_MAP_POSITIVE_X+face, img, 0);
/* RENDER SCENE HERE */
glBindFrameBufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
Commenting out the glFrameBufferTexture2DEXT puts the framerate up from 13 to 19, a 24ms improvement (though not terribly useful as then the shadow is only rendered on one face). This is the way it's all supposed to be done, right? GPU is 256MB Geforce 7600 Go, driver 169.12, running 32-bit Gentoo Linux, Xorg 7.3. Haven't tried on Windows as a couple of the libs I'm using don't like MinGW and I don't want to get Visual Studio just for this.

Share this post


Link to post
Share on other sites
Advertisement
What is the complexity of your scene? I ask because these cards are pretty different in range, especially if the 8800GTS has 128 (i think more) parallel pipes.

Try testing them with just a sphere or some simple object and checking the frames, because all I can think of is that the complexity of the scene to be drawn 6+1 times might be too much on the 7600 compared to the supreme domination of the 8800.

Share this post


Link to post
Share on other sites
Dont render all 6 sides every frame. Render 1 side per frame. At decent fps you wont notice it.

what is the resolution of the frame buffer? 512x512 should be ok.

Share this post


Link to post
Share on other sites
The scene is trivial, I've done it with a completely empty scene as well and the framerate is the same.
Cubemap resolution doesn't seem to affect the framerate, 512x512 and 2048x2048 both run at 13fps.

I'll try one face per frame, I hope that doesn't introduce seams.

Thanks for the replies guys.

EDIT: tried the update one face per frame, and it introduced a lot of artifacts with a moving light. Not as bad with two or three faces per frame, but still very noticeable.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement