Hi,
I've been investigating an issue in Flightgear, an OSS flight sim using
OSG. We have lots of stutter, usually in multiplayer, caused by loading
new models (this happens whenever somebody join). Loading textures from
disk happens on another thread (via DatabasePager), but I traced the
issue to glTexImage2D() calls. So it's texture uploading to graphics
driver / card that's causing it. It's not uncommon to see delays of
300ms for 500KiB - 1MiB textures.
The situation is quite bad. I'm using an ATI Radeon HD5850, and I
generally get 30fps with maxed out shader/details settings in
Flightgear and 8x-ish antialiasing added. But seconds-long stutter,
under practically all combinations of settings, is unacceptable for a
flight simulator.
I'm not an OpenGL expert at all (quite the contrary), but it seems using
PBOs might alleviate this issue by doing DMA instead of hogging the CPU
for texture transfer. There's the other solution of compressing
textures, but it's not a really viable option given what we have so far,
and I'm unsure that's the right fix even if performance does seem to
improve. We're using AC3D models, and the ac3d plugin loads both
geometry and textures.
However, I'm having difficulties setting up PBOs reliably. I attempted
hacking the ac3d plugin and its TextureData class to hardcode PBO usage
in the setTexture() method. Here are my attempts:
1) mImage-setPixelBufferObject(new osg::PixelBufferObject(mImage));
The PBO is set up, applyTexImage2D_load() finds it, but OSG crashes
because GLBufferObject::getOffset() returns 0.
2) Creating another image object, setting up a PBO on it, cloning
relevant properties from mImage, then doing copySubImage() from the
previous mImage. I also tried doing Image::allocateImage() on it before
copying. But either copySubImage() segfaults in GLU calls, or I hit the
first problem again.
3) By some combination of luck and a typo I made in 2 above (reversing
some coordinates) I got some textures showing up with wrong colors. It
seems to be faster at first glance, but it still crashes at some point.
What am I doing wrong?
Indeed, hacking the plugin doesn't seem the best option, I was just
doing that to test. I suppose, though I'm unsure if it's possible, I
should iterate over the whole scene graph using the visitor pattern and
set up PBOs for every texture.
I'm a bit puzzled there's no simple way to just switch this on. What
would you recommend? Any advice is appreciated.
Thanks,
Eduard
--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32112#32112
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org