FBO causes my VBO to crash

I’m just trying to get FBO to work. Everything seems to work fine, I can attach textures, renderbuffers, etc… I check the FBO status and it says framebuffer is complete. I don’t render anything, just bind back the default framebuffer (just testing). After this, my next DrawArrays call, which sources its data from a VBO, crashes. Now, if I don’t bind my texture to the framebuffer, then everyhting is fine. I checked for GL errors, but there are none… Any ideas?

Thanks!

On my card, radeon 9800 pro, I have found that it will crash when using DrawElements (regardless of VBO or not) if the DrawElements call comes before binding the framebuffer, even if no rendering is done to it. I was able to stop the crashing by moving all DrawElement calls for the main framebuffer to after FBO drawing code. DrawElements works fine inside FBOs, and I figure it is probably just something that will be fixed in the next driver…

Some more info: it doesn’t matter what I bind to the FBO, the crash happens, whenever I manage to create a valid FBO. If the FBO is not created for some reason (eg. incomplete), then there’s no crash. Also, now I tried to dereference a PBO, to load texture from, after the FBO test, and it works fine… But I have multiple VBOs (which should be the same as the PBO), but rendering from any of them crashes!!

Hah, watch this: if I just glMap() and glUnmap() the VBOs before rendering, then it works again!! This is on GF6600 with 77.72 drivers.

Map/unmap is a pretty big operation. Andras, can you describe in a little more detail what operations you’re performing on your failing VBOs and what FBO operations are required to trigger the failure?

Yeah Map()/Unmap() are pretty heavy. And even though it doesn’t crash, there are some weird stuff going on (sometimes geometry disappears for a moment, stuff like that). Ok, here’s some more detail on what I’m doing (sorry, I have everything wrapped up in objects, but you should get the idea (tu0 is texture unit 0)) :

// setup framebuffer
gl->framebuffermgr.Bind(fbo);
tu0->Bind(l.image);
tu0->SetMagFilter(ITextureUnit::nearest);
tu0->SetMinFilter(ITextureUnit::nearest);
fbo->AttachTexture(IFrameBuffer::AttachmentPoint::color, l.image);
gl->framebuffermgr.Check();
gl->framebuffermgr.Bind(0);

This triggers the failure (doing nothing). If I don’t attach the texture, then the Check() will fail, as the FBO is incomplete, but then the crash goes away.

Here’s my VBO prep (the Unmap() method internally binds and unbinds):

buffer->Unmap();
buffer->Bind(IBufferObject::ValueType::vertex);
VertexAttribPointer(location, size, type_convert[type], normalized, stride, (void*)offset);
EnableVertexAttribArray(location);
buffer->UnBind();
::glDrawArrays(Convert(primtype), 0, vxcount);

If you need some more info, please let me know!
Thanks,

Andras

Ok, I just realized that all the sideffects of the extra Map/Unmap that I’ve seen are normal, since I internally doublebuffer my VBOs, so every Map() switches pages automagically, and that’s why I’ve seen the weird stuff. So this means that Map/Unmap solves the crash without any problems. Of course it’s super expensive, but for now I can live with it…

Ok, so here is my other suspect, even though it is not the direct cause of the crash, it doesn’t work as expected, and might indirectly cause problems:

I want to load a texture from a PBO. Loading the texture works fine, but filling the data does not. If I fill the PBO like this, then it works (ie. the data gets uploaded):

BindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, name);
BufferData(GL_PIXEL_UNPACK_BUFFER_ARB, size, image, GL_DYNAMIC_DRAW);
BindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);

But, if I use Map(), and then copy the data, then the result is an empty buffer (black texture, after upload):

BindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, name);
void* data = MapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, GL_READ_WRITE);
BindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
::memcpy(data, image, size);
BindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, name);
UnmapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB);
BindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);

The reason I want to use Map instead of BufferData, is that I want to fill the data in from a separate thread, and would like to avoid having a temporary buffer to copy from. Anyway, this might, or might not have anything to do with the crash. I’ll keep investigating.

Well, I ruled out the PBOs, it doesn’t have anything to do with the crash, and for now I can live with the workaround, although it still frustrates me why mapping doesn’t work.

So, back to the FBO: I’ve done some measurements:
no FBO, no map/unmap hack: 70fps
no FBO, map/unmap hack: 30fps
FBO, map/unmap hack: 10fps!!!

And the most interesting thing is that the framerate remains low even after I stop executing the FBO path! Now I’ll try to render something into my texture, see if it works at all…

Hah, I’ve found the solution to the FBO crash!!
My driver was set to multi-monitor acceleration. If I turn off acceleration for the second monitor, the crash goes away!! Should I report this somewhere, or do nVidia guys read this forum?

Report it, it is safer :slight_smile: