Preformance issue with 3d texure and FBO

Hello everyone !

I am implementing a fluid simulation that is running on the gpu. I am using 3d texture to store all the variables i need. The problem is that rendering to each slice in 3d texture seems to be quite slow.

My code for rendering to each slice of the texture look like this

 
for(int z = 0 ; z < textureSize ; z++)
{
    glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT , GL_TEXTURE_3D, textureID, 0 ,z);
    Render(z);
} 

If i run it like this i get about 15 fps , but if i remove the glFramebufferTexture3DEXT call i get about 90 fps. Without the glFramebufferTexture3DEXT call, the rendering is preformed to the same slice every time so the simulation doesn’t work. But it does the same amount of calculations so the about framerate should be the same. To me it looks like the overhead for attaching a new slice to the framebuffer is very large.

So my question is , is this the only way of doing it ?
or is there another faster way ?

Any comments are appreciated !

/Andreas

If you’re using shaders, you could at least use multiple rendertargets, ie GL_COLOR_ATTACHMENT0…n to skip some passes