Hi,
I was playing around with threading models today and found something odd.
For the sake of experiment, I used a osgViewer with a master camera, a slave
camera using the same graphics context as the master camera, and the
CullThreadPerCameraDrawThreadPerContext threading model.
I found that the osgViewer does not commence the next frame until the last
camera's draw dispatch has started. That is strange. My scene has 0 dynamic
objects in it, so logically speaking the next frame could commence as soon as
all the cull threads are done and the first camera's draw dispatch starts.
I attached some pictures to illustrate what I mean. The first picture is what I
am seeing, the second picture is what I would have expected to see.
I fired up the debugger and found OSG was blocking in the _endDynamicDrawBlock.
The block gets released in Renderer::draw, but each camera needs to get there
first, i.e. start drawing.
The idea for a fix would be simple: if there are no dynamic objects in the
scene, we release the block in GraphicsContext::runOperations, for each camera,
before the cameras start drawing.
i.e., we move this piece of code from Renderer::draw to
GraphicsContext::runOperations:
state->setDynamicObjectCount(sceneView->getDynamicObjectCount());
if (sceneView->getDynamicObjectCount()==0 &&
state->getDynamicObjectRenderingCompletedCallback())
{
// OSG_NOTICE<<"Completed in cull"<<std::endl;
state->getDynamicObjectRenderingCompletedCallback()->completed(state);
}
In practice it may not be simple, for starters the GraphicsContext would need
access to the SceneView, which is a no go as the core osg can't depend on
osgViewer. Some refactoring would be needed to work around this issue, so
before I dive in head first, I want to ask if anyone has an alternative
suggestion, or done this kind of optimization before.
Thanks,
Jannik
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63964#63964
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org