PDA

View Full Version : FBO - texture_2D_array problems



babis
06-30-2008, 07:13 AM
Hello, I've been using an FBO writing to texture array layers successfully for a while, but as soon as I made a minor change, it broke, and I'm wondering about the source of the problem ( which most probably lie elsewhere).

I'm not sure if the process is completely right / in order. It's the following :

- bind fbo, set draw buffer as color attachment0
- begin the appropriate shader, bind any textures / cubemaps needed
- start a loop where :
---> bind the i-th textures / cubemaps for the shader
---> Attach the i-th layer of the texture array
---> set glGenerateMipmaps for texture_array_2d
---> render some stuff
---> unattach
- disable fbo
- restore drawbuffer

The change was in the loop count.
Now I get a framebuffer unsupported in the 2nd iteration of the loop. Do you find anything weird / wrong in the above flow?

Many thanks,
Babis

EDIT : I sometimes get a framebuffer_unsupported error, & sometimes I get a framebuffer_incomplete error

innuendo
06-30-2008, 07:48 AM
I'm not sure if the process is completely right / in order. It's the following :

- bind fbo, set draw buffer as color attachment0
- begin the appropriate shader, bind any textures / cubemaps needed
- start a loop where :
---> bind the i-th textures / cubemaps for the shader
---> Attach the i-th layer of the texture array
---> set glGenerateMipmaps for texture_array_2d
---> render some stuff
---> unattach
- disable fbo
- restore drawbuffer




How do you bind textureArray ?

Is it float error ?

Oh.
I think you have to restore drawBuffer firstly. And only after that disable FBO.

babis
06-30-2008, 08:26 AM
Hi innuendo, thanks for your quick response.

glDrawBuffer didn't change anything.
What do you mean by float error?

About the binding, in order not to write every combination I tried & to summarize :

before I didn't bind the texarray at all before the fbo attachment. I only bound it to 0 unit in rendering, & since probably no other texarray lies at unit 0, it wouldn't change.

Now I bind it at 0 explicitly before attaching the layer, with LINEAR / CLAMP. But glGenerateMipmapsEXT causes my FBO to break.
My render filter for the texarray is LINEAR_MIPMAP_LINEAR/ CLAMP.

I managed to get it working, but without generating mipmaps.
Where should I place the glGenerateMipmapsEXT call to make it work correctly?

Many thanks,
babis

innuendo
06-30-2008, 08:42 AM
I managed to get it working, but without generating mipmaps.
Where should I place the glGenerateMipmapsEXT call to make it work correctly?

Many thanks,
babis



Try to use glGenerateMipmapsEXT in FBO's creation, not in render loop.

'float error' equal 'fuzzy error'
in Russain language:)

Good luck

babis
06-30-2008, 09:00 AM
The problem is that in the FBO creation I only attach a depth buffer, since the layer attachments change continuously every frame..

I also tried replacing glGenerateMipmapsEXT with glTexParameteri(GL_GENERATE_MIPMAP), but no results.

Thanks for your help.

babis
06-30-2008, 01:02 PM
In addition to the above, I get those problems ONLY if my texture array has depth more than .. 9. Lower than / equal to that, I can have mipmaps. More than that, only without mipmaps.

Meanwhile, GL_MAX_ARRAY_TEXTURE_LAYERS_EXT returns 512.

Does anything make sense??

Zengar
06-30-2008, 02:21 PM
Hm, seems you have run into a bug/limitation of nvidia hardware (or driver) :)

Seth Hoffert
06-30-2008, 02:25 PM
I am using a 53-layer 2D texture array in one of my programs, and I use glGenerateMipmaps on it and it generates no error, but then again I haven't done too much with render-to-texture-array. Could be an FBO bug in the driver I suppose. :)

I did come across a mipmapping + render-to-texture-array bug once though (the GS was basically unaware that I was using mipmaps, and wrote into the wrong location in memory, but I notified NVIDIA of this and it is now fixed).

babis
06-30-2008, 02:58 PM
Thanks guys, at least I have an excuse not to blame myself now :)

If anyone though has successfully used texture arrays for render-to-many-slices, with glGenerateMipmaps on, successfully, I would like to hear his setup.

innuendo
07-01-2008, 12:20 AM
The problem is that in the FBO creation I only attach a depth buffer, since the layer attachments change continuously every frame..

Thanks for your help.

So, can you try to use FramebufferTextureLayerEXT with layer= zero in FBO's creation ?

babis
07-01-2008, 06:06 AM
If I do this & use glGenerateMipmapEXT once, at creation time, it seems that only my mipmaps, are garbage.

Mars_999
07-02-2008, 05:44 PM
Have you created a complete mipmap chain for your textures? You have to do this even if you use glGenerateMipmapsEXT. So either manually set them up, or cheat and use the GL_GENERATE_MIPMAPS flag to the glTexParameteri()

babis
07-03-2008, 05:43 AM
Thanks Mars_999,

manually setting them up means creating dummy data & passing them with texsubimage3D for each miplevel? I did that, but no luck again. And, even if it work, seems very paranoid to me, having to do this, and only if the depth of my texture array is greater than a specified size..

But, using GL_GENERATE_MIPMAPS along with glGenerateMipmapEXT(), eliminated a bug I was having where only the first set (in 1st frame) of the computed mipmaps were garbage, so thanks! :)

Michael Gold
05-09-2009, 01:50 AM
manually setting them up means creating dummy data & passing them with texsubimage3D for each miplevel?

You don't need to create dummy data... a NULL data pointer is sufficient for creating a level.