PDA

View Full Version : switching between FBOs with mipmapped textures



despoke
04-17-2008, 05:11 PM
Hi,

For my home project (a deferred renderer), I render to several offscreen textures before compositing the result in a final pass. To do so, I create 2 FBOS and bind the relevant textures at initialisation time. Then in the render loop, I consecutively bind each FBO and render something into it. I also use GL_EXT_timer_query to profile my application, which proves to be really useful :o) My graphic card is a GeForce 7900GT.

While looking at the time taken by glBindFramebufferEXT(), it costs about 0.002ms to bind the 1st FBO, while it costs 1.5ms-2.0ms to bind the 2nd FBO.

After further tests, it seems this is because the 2nd FBO uses the following configuration:
- color attachment 0: a texture created with mipmaps.
- depth attachment: a depth texture

The 1st FBO configuration is:
- color attachment 0: a texture created without mipmaps.
- depth attachment: a depth texture

If I attach a non-mipmapped texture to the 2nd FBO or if I don't bind a depth texture to the 2nd FBO, then the cost of binding that FBO becomes same as 1st FBO. To resume:
- binding an FBO with mipmapped texture and no depth texture is OK.
- binding an FBO with non-mipmapped texture and a depth texture is OK.
- binding an FBO with mipmapped texture and a depth texture is GPU expensive.

This is problematic because my app accumulates lighting contributions into the 2nd FBO, while it renders shadow maps in between each accumulation (this incurs switching FBOs). It uses the depth texture in the 2nd FBO to perform ealy-z-rejection and the mipmaps for other purposes, so it's kind-of needed. Because of the repeated switches to the 2nd FBO, my app is performing poorly on the GPU side!

Has anybody experienced similar issues when binding an FBO with mipmapped color texture+depth texture and found a workaround for this hardware/driver limitation? Could it be just specific to my graphic card (GeForce 7900GT), or for all Nvidia cards?

Thanks

Relic
04-18-2008, 08:03 AM
Wild guess: Is any texture setup to generate mipmaps automatically?

despoke
04-18-2008, 11:38 AM
No, I don't setup any texture with automatic mipmap generation.

CatAtWork
04-30-2008, 05:40 PM
Have you called glHint( GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST ) or anything similar?

V-man
05-01-2008, 07:47 AM
Are you calling glGenerateMipmapsEXT(GL_TEXTURE_2D) when you first create the texture?
Also, when you render to the texture, you have to call glGenerateMipmapsEXT(GL_TEXTURE_2D)

My guess is that binding is not really the expensive part, but mipmapping is.