Permalink
Browse files

merging with trunk using

  • Loading branch information...
1 parent 6962a71 commit 591d71658f75ec12200d73197a0be0d62e5f33fd Stephan Maximilian HUBER committed Mar 9, 2009
View
@@ -28,8 +28,8 @@ PROJECT(OpenSceneGraph)
SET(OPENSCENEGRAPH_MAJOR_VERSION 2)
SET(OPENSCENEGRAPH_MINOR_VERSION 9)
-SET(OPENSCENEGRAPH_PATCH_VERSION 0)
-SET(OPENSCENEGRAPH_SOVERSION 55)
+SET(OPENSCENEGRAPH_PATCH_VERSION 1)
+SET(OPENSCENEGRAPH_SOVERSION 56)
# set to 0 when not a release candidate, non zero means that any generated
# svn tags will be treated as release candidates of given number
@@ -1,43 +1,131 @@
# Locate ffmpeg
# This module defines
# FFMPEG_LIBRARIES
-# FFMPEG_FOUND, if false, do not try to link to ffmpeg
+# FFMPEG_FOUND, if false, do not try to link to ffmpeg
# FFMPEG_INCLUDE_DIR, where to find the headers
#
# $FFMPEG_DIR is an environment variable that would
# correspond to the ./configure --prefix=$FFMPEG_DIR
#
-# Created by Robert Osfield.
+# Created by Robert Osfield.
-#use pkg-config to find various modes
-INCLUDE(FindPkgConfig OPTIONAL)
+# Macro to find header and lib directories
+# example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
-IF(PKG_CONFIG_FOUND)
+MACRO(FFMPEG_FIND varname shortname headername)
+ # First try to find header directly in include directory
+ FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername}
+ ${FFMPEG_ROOT}/include
+ $ENV{FFMPEG_DIR}/include
+ $ENV{OSGDIR}/include
+ $ENV{OSG_ROOT}/include
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/include
+ /usr/include/
+ /sw/include # Fink
+ /opt/local/include # DarwinPorts
+ /opt/csw/include # Blastwave
+ /opt/include
+ /usr/freeware/include
+ )
- INCLUDE(FindPkgConfig)
+ # If not found, try to find it in a subdirectory. Tanguy's build has
+ # avformat.h in include/libavformat, so this catches that case. If that's
+ # standard, perhaps we can keep just this case.
+ IF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
+ FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
+ ${FFMPEG_ROOT}/include
+ $ENV{FFMPEG_DIR}/include
+ $ENV{OSGDIR}/include
+ $ENV{OSG_ROOT}/include
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/include
+ /usr/include/
+ /sw/include # Fink
+ /opt/local/include # DarwinPorts
+ /opt/csw/include # Blastwave
+ /opt/include
+ /usr/freeware/include
+ )
+ ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
- pkg_check_modules(FFMPEG_LIBAVFORMAT libavformat)
- pkg_check_modules(FFMPEG_LIBAVDEVICE libavdevice)
- pkg_check_modules(FFMPEG_LIBAVCODEC libavcodec)
- pkg_check_modules(FFMPEG_LIBAVUTIL libavutil)
-ENDIF(PKG_CONFIG_FOUND)
+ # If not found, try to find it in a subdirectory. Tanguy's build has
+ # avformat.h in include/libavformat, so this catches that case. If that's
+ # standard, perhaps we can keep just this case.
+ IF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
+ FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ffmpeg/${headername}
+ ${FFMPEG_ROOT}/include
+ $ENV{FFMPEG_DIR}/include
+ $ENV{OSGDIR}/include
+ $ENV{OSG_ROOT}/include
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/include
+ /usr/include/
+ /sw/include # Fink
+ /opt/local/include # DarwinPorts
+ /opt/csw/include # Blastwave
+ /opt/include
+ /usr/freeware/include
+ )
+ ENDIF(NOT FFMPEG_${varname}_INCLUDE_DIRS)
+
+ FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
+ NAMES ${shortname}
+ PATHS
+ ${FFMPEG_ROOT}/lib
+ $ENV{FFMPEG_DIR}/lib
+ $ENV{OSGDIR}/lib
+ $ENV{OSG_ROOT}/lib
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/lib
+ /usr/local/lib64
+ /usr/lib
+ /usr/lib64
+ /sw/lib
+ /opt/local/lib
+ /opt/csw/lib
+ /opt/lib
+ /usr/freeware/lib64
+ )
+
+ IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
+ SET(FFMPEG_${varname}_FOUND 1)
+ ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
+
+ENDMACRO(FFMPEG_FIND)
+
+SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
+
+FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
+FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
+FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h)
+FFMPEG_FIND(LIBAVUTIL avutil avutil.h)
+FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # not sure about the header to look for here.
SET(FFMPEG_FOUND "NO")
+# Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional.
IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
-
+
SET(FFMPEG_FOUND "YES")
SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
+ # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later.
SET(FFMPEG_LIBRARIES
${FFMPEG_LIBAVFORMAT_LIBRARIES}
${FFMPEG_LIBAVDEVICE_LIBRARIES}
${FFMPEG_LIBAVCODEC_LIBRARIES}
${FFMPEG_LIBAVUTIL_LIBRARIES})
-
-ENDIF(FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
+ELSE (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
+# MESSAGE(STATUS "Could not find FFMPEG")
+
+ENDIF(FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND)
@@ -57,45 +57,64 @@
typedef std::vector< osg::ref_ptr<osg::GraphicsThread> > GraphicsThreads;
+struct ReleaseBlockOnCompileCompleted : public osgUtil::IncrementalCompileOperation::CompileCompletedCallback
+{
+
+ ReleaseBlockOnCompileCompleted(osg::RefBlockCount* block):
+ _block(block) {}
+
+ virtual bool compileCompleted(osgUtil::IncrementalCompileOperation::CompileSet* compileSet)
+ {
+ if (_block.valid()) _block->completed();
+
+ // tell IncrementalCompileOperation that it's now safe to remove the compileSet
+
+ osg::notify(osg::NOTICE)<<"compileCompleted("<<compileSet<<")"<<std::endl;
+
+ return true;
+ }
+
+ osg::ref_ptr<osg::RefBlockCount> _block;
+};
class LoadAndCompileOperation : public osg::Operation
{
public:
- LoadAndCompileOperation(const std::string& filename, GraphicsThreads& graphicsThreads, osg::RefBlockCount* block):
+ LoadAndCompileOperation(const std::string& filename, osgUtil::IncrementalCompileOperation* ico , osg::RefBlockCount* block):
Operation("Load and compile Operation", false),
_filename(filename),
- _graphicsThreads(graphicsThreads),
+ _incrementalCompileOperation(ico),
_block(block) {}
virtual void operator () (osg::Object* object)
{
// osg::notify(osg::NOTICE)<<"LoadAndCompileOperation "<<_filename<<std::endl;
_loadedModel = osgDB::readNodeFile(_filename);
- if (_loadedModel.valid() && !_graphicsThreads.empty())
+
+ if (_loadedModel.valid() && _incrementalCompileOperation.valid())
{
- osg::ref_ptr<osgUtil::GLObjectsOperation> compileOperation = new osgUtil::GLObjectsOperation(_loadedModel.get());
-
- for(GraphicsThreads::iterator gitr = _graphicsThreads.begin();
- gitr != _graphicsThreads.end();
- ++gitr)
- {
- (*gitr)->add( compileOperation.get() );
- // requiresBarrier = true;
- }
- }
+ osg::ref_ptr<osgUtil::IncrementalCompileOperation::CompileSet> compileSet =
+ new osgUtil::IncrementalCompileOperation::CompileSet(_loadedModel);
+
+ compileSet->_compileCompletedCallback = new ReleaseBlockOnCompileCompleted(_block.get());
- if (_block.valid()) _block->completed();
+ _incrementalCompileOperation->add(compileSet.get());
+ }
+ else
+ {
+ if (_block.valid()) _block->completed();
+ }
// osg::notify(osg::NOTICE)<<"done LoadAndCompileOperation "<<_filename<<std::endl;
}
- std::string _filename;
- GraphicsThreads _graphicsThreads;
- osg::ref_ptr<osg::Node> _loadedModel;
- osg::ref_ptr<osg::RefBlockCount> _block;
+ std::string _filename;
+ osg::ref_ptr<osg::Node> _loadedModel;
+ osg::ref_ptr<osgUtil::IncrementalCompileOperation> _incrementalCompileOperation;
+ osg::ref_ptr<osg::RefBlockCount> _block;
};
@@ -108,9 +127,10 @@ class MasterOperation : public osg::Operation
typedef std::vector< osg::ref_ptr<osg::Node> > Nodes;
- MasterOperation(const std::string& filename):
+ MasterOperation(const std::string& filename, osgUtil::IncrementalCompileOperation* ico):
Operation("Master reading operation",true),
- _filename(filename)
+ _filename(filename),
+ _incrementalCompileOperation(ico)
{
}
@@ -256,9 +276,6 @@ class MasterOperation : public osg::Operation
if (gt) threads.push_back(gt);
}
- bool requiresBarrier = false;
-
-
if (_operationQueue.valid())
{
// osg::notify(osg::NOTICE)<<"Using OperationQueue"<<std::endl;
@@ -276,7 +293,7 @@ class MasterOperation : public osg::Operation
{
// osg::notify(osg::NOTICE)<<"Adding LoadAndCompileOperation "<<*nitr<<std::endl;
- osg::ref_ptr<LoadAndCompileOperation> loadAndCompile = new LoadAndCompileOperation( *nitr, threads, _endOfLoadBlock.get() );
+ osg::ref_ptr<LoadAndCompileOperation> loadAndCompile = new LoadAndCompileOperation( *nitr, _incrementalCompileOperation.get(), _endOfLoadBlock.get() );
loadAndCompileList.push_back(loadAndCompile);
_operationQueue->add( loadAndCompile.get() );
}
@@ -300,14 +317,18 @@ class MasterOperation : public osg::Operation
if ((*litr)->_loadedModel.valid())
{
nodesToAdd[(*litr)->_filename] = (*litr)->_loadedModel;
- requiresBarrier = true;
}
}
}
else
{
+
+ _endOfLoadBlock = new osg::RefBlockCount(newFiles.size());
+
+ _endOfLoadBlock->reset();
+
for(Files::iterator nitr = newFiles.begin();
nitr != newFiles.end();
++nitr)
@@ -318,38 +339,30 @@ class MasterOperation : public osg::Operation
{
nodesToAdd[*nitr] = loadedModel;
- osg::ref_ptr<osgUtil::GLObjectsOperation> compileOperation = new osgUtil::GLObjectsOperation(loadedModel.get());
+ if (_incrementalCompileOperation.valid())
+ {
+ osg::ref_ptr<osgUtil::IncrementalCompileOperation::CompileSet> compileSet =
+ new osgUtil::IncrementalCompileOperation::CompileSet(loadedModel.get());
+
+ compileSet->_compileCompletedCallback = new ReleaseBlockOnCompileCompleted(_endOfLoadBlock.get());
- for(GraphicsThreads::iterator gitr = threads.begin();
- gitr != threads.end();
- ++gitr)
+ _incrementalCompileOperation->add(compileSet.get());
+ }
+ else
{
- (*gitr)->add( compileOperation.get() );
- requiresBarrier = true;
+ _endOfLoadBlock->completed();
}
}
+ else
+ {
+ _endOfLoadBlock->completed();
+ }
}
- }
-
- if (requiresBarrier)
- {
- _endOfCompilebarrier = new osg::BarrierOperation(threads.size()+1);
- _endOfCompilebarrier->setKeep(false);
-
- for(GraphicsThreads::iterator gitr = threads.begin();
- gitr != threads.end();
- ++gitr)
- {
- (*gitr)->add(_endOfCompilebarrier.get());
- }
-
- // osg::notify(osg::NOTICE)<<"Waiting for Compile to complete"<<std::endl;
- // wait for the graphics threads to complete.
- _endOfCompilebarrier->block();
-
- // osg::notify(osg::NOTICE)<<"done ... Waiting for Compile to complete"<<std::endl;
+ _endOfLoadBlock->block();
+
}
+
}
bool requiresBlock = false;
@@ -454,6 +467,7 @@ class MasterOperation : public osg::Operation
FilenameNodeMap _nodesToAdd;
OpenThreads::Block _updatesMergedBlock;
+ osg::ref_ptr<osgUtil::IncrementalCompileOperation> _incrementalCompileOperation;
osg::ref_ptr<osg::BarrierOperation> _endOfCompilebarrier;
osg::ref_ptr<osg::RefBlockCount> _endOfLoadBlock;
@@ -618,6 +632,9 @@ int main(int argc, char** argv)
// add the record camera path handler
viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
+ // attach an IncrementaCompileOperation to allow the master loading
+ // to be handled with an incremental compile to avoid frame drops when large objects are added.
+ viewer.setIncrementalCompileOperation(new osgUtil::IncrementalCompileOperation());
double x = 0.0;
double y = 0.0;
@@ -631,7 +648,7 @@ int main(int argc, char** argv)
std::string masterFilename;
while(arguments.read("-m",masterFilename))
{
- masterOperation = new MasterOperation(masterFilename);
+ masterOperation = new MasterOperation(masterFilename, viewer.getIncrementalCompileOperation());
}
View
@@ -121,7 +121,7 @@ class OSG_EXPORT Referenced
#if defined(_OSG_REFERENCED_USE_ATOMIC_OPERATIONS)
struct ObserverSetData;
- mutable OpenThreads::AtomicPtr _observerSetDataPtr;
+ mutable OpenThreads::AtomicPtr _observerSetDataPtr;
mutable OpenThreads::Atomic _refCount;
#else
View
@@ -21,8 +21,8 @@ extern "C" {
#define OPENSCENEGRAPH_MAJOR_VERSION 2
#define OPENSCENEGRAPH_MINOR_VERSION 9
-#define OPENSCENEGRAPH_PATCH_VERSION 0
-#define OPENSCENEGRAPH_SOVERSION 55
+#define OPENSCENEGRAPH_PATCH_VERSION 1
+#define OPENSCENEGRAPH_SOVERSION 56
/**
* osgGetVersion() returns the library version number.
Oops, something went wrong.

0 comments on commit 591d716

Please sign in to comment.