On Saturday 26 May 2007, Tim Moore wrote: > OK, but maybe this call shouldn't be buried in the initialization of the > model loader. osgViewer::Viewer changes this mode for threading models > that need it, and maybe your new viewer should do the same. That is probably too late. Some of our shared osg::Referenced are assigned on static initialization. That is may be even before that osgDB::Registry is loaded.
I do even thing about some ugly hacks to ensure that ew have really every object safe. The other way to do so is to use what we currently have in simgear to do atomic reference counts by compiler intrinsics. That is really fast. I have a mostly patched version of osg on local disk. But did not manage to finish that and send it to Robert ... This way we could be sure that we do not loose any references at least on any relevant architecture. The others (AIX, HP-UX ...) would need to set the OSG_THREAD_SAFE_REFERENCE counting environment variable if they want to make use of any multithreaded features ... > > I have a multithreaded viewer in the works and for that it is still > > useful to have thread safe reference counting in place. > > Also Having the database pager set up once we have the osgviewer code > > settled we will do model loading in a thread that runs in parallel to the > > rest of the application. And remember that we share some data across > > models. That model cloning will need thread safe reference counting. > > It does not cost much OTOH. > > Here's a somewhat unscientific test : > src/Main/fgfs --fg-root=/home/moore/graphics/FlightGear/data/ > --aircraft=bo105 --disable-ai-models --geometry=1024x768 > > time of day: noon. > > Without thread safe reference counting (time in milliseconds): > event 5.75 > update 3.3 > cull 1.75 > draw 3.6 > Total: 14.4 > > event 5.75 > update 3.83 > cull 1.83 > draw 3.75 > Total: 15.16 > > So, .76ms, or a 5% difference... I think this is fairly significant. > > The real cost will come when we start doing database paging: that's when > a lot of Referenced objects will have their reference counts changed. In > normal operation database paging doesn't need threadsafe reference > counting. > > You have a good point about copying models. The thread safe mode can be > set per Referenced object, which may be a better way of dealing with > shared objects. Vote against. Even that stuff that is currently not managed by osgDB will be handled by osgDB in the future. I intent to make model and tile loading as well a osgDB reader. At least an internal reader that registers itself at osgDB. This way we will not have any frame drop any more in the feature. Everything io bound operation is done in an offline thread and osgDB make sure that display lists are already compiled when the model/tile whatever is plugged into the scenegraph. ... no hangs anymore when an AIModel comes in sight ... Greetings Mathias ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel