I'm sure you already knew this, but just in case not... :)
svn diff \
--old http://www.openscenegraph.com/svn/osg/OpenSceneGraph/[EMAIL PROTECTED] \
--new http://www.openscenegraph.com/svn/osg/OpenSceneGraph/[EMAIL PROTECTED]
...will give you the diff, which I've also attached. SVN rocks. :)
On Fri, 2007-07-13 at 21:46 +0100, Robert Osfield wrote:
> Hi Adrian,
>
> I did some testing this evening and found that when running in the
> CullThreadPerCameraDrawThreadPerContext thread model I get a hang on
> start up. All the rest of the threading models works fine,
> CullThreadPerCameraDrawThreadPerContext even works fine when I run on
> a single head.
>
> I have isolated this particular problem to being in revision 7118 and
> later, 7117 works fine in all threading models, at least on my
> machine. I don't know if this issue is related to the one you've seen
> but perhaps it might be and you'll at least know which revision to go
> back to.
>
> The changes I made since 7117 aren't major changes, I don't know yet
> exactly what went wrong, but at least I know roughly where to look.
> I'll do this over the weekend.
>
> Robert.
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
>
Index: include/osgUtil/GLObjectsVisitor
===================================================================
--- include/osgUtil/GLObjectsVisitor (revision 7117)
+++ include/osgUtil/GLObjectsVisitor (revision 7118)
@@ -113,6 +113,20 @@
};
+class GLObjectsOperation : public osg::GraphicsOperation
+{
+ public:
+
+ GLObjectsOperation(osg::Node* subgraph, GLObjectsVisitor::Mode mode = GLObjectsVisitor::COMPILE_DISPLAY_LISTS|GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES|GLObjectsVisitor::CHECK_BLACK_LISTED_MODES);
+
+ virtual void operator () (osg::GraphicsContext* context);
+
+ protected:
+
+ osg::ref_ptr<osg::Node> _subgraph;
+ GLObjectsVisitor::Mode _mode;
+};
+
}
#endif
Index: include/osg/OperationThread
===================================================================
--- include/osg/OperationThread (revision 7117)
+++ include/osg/OperationThread (revision 7118)
@@ -130,7 +130,7 @@
OperationThreads _operationThreads;
};
-/** GraphicsThread is a helper class for running OpenGL GraphicsOperation within a single thread assigned to a specific GraphicsContext.*/
+/** OperationThread is a helper class for running Operation within a single thread.*/
class OSG_EXPORT OperationThread : public Referenced, public OpenThreads::Thread
{
public:
Index: include/osg/GraphicsThread
===================================================================
--- include/osg/GraphicsThread (revision 7117)
+++ include/osg/GraphicsThread (revision 7118)
@@ -18,6 +18,9 @@
namespace osg {
+class GraphicsContext;
+
+/** GraphicsThread is a helper class for running OpenGL GraphicsOperation within a single thread assigned to a specific GraphicsContext.*/
class OSG_EXPORT GraphicsThread : public osg::OperationThread
{
public:
@@ -28,17 +31,30 @@
virtual void run();
};
+struct OSG_EXPORT GraphicsOperation : public Operation
+{
+ GraphicsOperation(const std::string& name, bool keep):
+ Operation(name,keep) {}
+
+ /** Override the standard Operation opertator and dynamic cast object to a GraphicsContext,
+ * on success call operation()(GraphicsContext*).*/
+ virtual void operator () (Object* object);
+
+ virtual void operator () (GraphicsContext* context) = 0;
+};
+
+
/** SwapBufferOperation calls swap buffers on the GraphicsContext.*/
-struct OSG_EXPORT SwapBuffersOperation : public Operation
+struct OSG_EXPORT SwapBuffersOperation : public GraphicsOperation
{
SwapBuffersOperation():
- Operation("SwapBuffers",true) {}
+ GraphicsOperation("SwapBuffers",true) {}
- virtual void operator () (Object* context);
+ virtual void operator () (GraphicsContext* context);
};
/** BarrierOperation allows one to syncronize multiple GraphicsThreads with each other.*/
-struct OSG_EXPORT BarrierOperation : public Operation, public OpenThreads::Barrier
+struct OSG_EXPORT BarrierOperation : public GraphicsOperation, public OpenThreads::Barrier
{
enum PreBlockOp
{
@@ -48,36 +64,36 @@
};
BarrierOperation(int numThreads, PreBlockOp op=NO_OPERATION):
- Operation("Barrier", true),
+ GraphicsOperation("Barrier", true),
OpenThreads::Barrier(numThreads),
_preBlockOp(op) {}
virtual void release();
- virtual void operator () (Object* context);
+ virtual void operator () (GraphicsContext* context);
PreBlockOp _preBlockOp;
};
/** ReleaseContext_Block_MakeCurrentOperation releases the context for another thread to aquire,
* then blocks waiting for context to be released, once the block is release the context is re-aqquired.*/
-struct OSG_EXPORT ReleaseContext_Block_MakeCurrentOperation : public Operation, public RefBlock
+struct OSG_EXPORT ReleaseContext_Block_MakeCurrentOperation : public GraphicsOperation, public RefBlock
{
ReleaseContext_Block_MakeCurrentOperation():
- Operation("ReleaseContext_Block_MakeCurrent", false) {}
+ GraphicsOperation("ReleaseContext_Block_MakeCurrent", false) {}
virtual void release();
- virtual void operator () (Object* context);
+ virtual void operator () (GraphicsContext* context);
};
-struct OSG_EXPORT BlockAndFlushOperation : public Operation, public OpenThreads::Block
+struct OSG_EXPORT BlockAndFlushOperation : public GraphicsOperation, public OpenThreads::Block
{
BlockAndFlushOperation();
virtual void release();
- virtual void operator () (Object*);
+ virtual void operator () (GraphicsContext*);
};
}
Index: include/osgDB/DatabasePager
===================================================================
--- include/osgDB/DatabasePager (revision 7117)
+++ include/osgDB/DatabasePager (revision 7118)
@@ -373,11 +373,11 @@
double _minimumTimeAvailableForGLCompileAndDeletePerFrame;
unsigned int _maximumNumOfObjectsToCompilePerFrame;
- struct CompileOperation : public osg::Operation
+ struct CompileOperation : public osg::GraphicsOperation
{
CompileOperation(DatabasePager* databasePager);
- virtual void operator () (osg::Object* object);
+ virtual void operator () (osg::GraphicsContext* context);
osg::observer_ptr<DatabasePager> _databasePager;
};
Index: src/osgUtil/GLObjectsVisitor.cpp
===================================================================
--- src/osgUtil/GLObjectsVisitor.cpp (revision 7117)
+++ src/osgUtil/GLObjectsVisitor.cpp (revision 7118)
@@ -138,3 +138,19 @@
stateset.checkValidityOfAssociatedModes(*_renderInfo.getState());
}
}
+
+GLObjectsOperation::GLObjectsOperation(osg::Node* subgraph, GLObjectsVisitor::Mode mode):
+ osg::GraphicsOperation("GLObjectOperation",false),
+ _subgraph(subgraph),
+ _mode(mode)
+{
+}
+
+void GLObjectsOperation::operator () (osg::GraphicsContext* context)
+{
+ GLObjectsVisitor glObjectsVisitor(_mode);
+
+ glObjectsVisitor.setState(context->getState());
+
+ _subgraph->accept(glObjectsVisitor);
+}
Index: src/osg/GraphicsThread.cpp
===================================================================
--- src/osg/GraphicsThread.cpp (revision 7117)
+++ src/osg/GraphicsThread.cpp (revision 7118)
@@ -41,35 +41,16 @@
}
-struct BlockOperation : public Operation, public Block
+void GraphicsOperation::operator () (Object* object)
{
- BlockOperation():
- Operation("Block",false)
- {
- reset();
- }
-
- virtual void release()
- {
- Block::release();
- }
-
- virtual void operator () (Object*)
- {
- glFlush();
- Block::release();
- }
-};
-
+ osg::GraphicsContext* context = dynamic_cast<osg::GraphicsContext*>(object);
+ if (context) operator() (context);
+}
-void SwapBuffersOperation::operator () (Object* object)
+void SwapBuffersOperation::operator () (GraphicsContext* context)
{
- GraphicsContext* context = dynamic_cast<GraphicsContext*>(object);
- if (context)
- {
- context->swapBuffersImplementation();
- context->clear();
- }
+ context->swapBuffersImplementation();
+ context->clear();
}
void BarrierOperation::release()
@@ -77,7 +58,7 @@
Barrier::release();
}
-void BarrierOperation::operator () (Object*)
+void BarrierOperation::operator () (GraphicsContext*)
{
if (_preBlockOp==GL_FLUSH) glFlush();
if (_preBlockOp==GL_FINISH) glFinish();
@@ -91,11 +72,8 @@
}
-void ReleaseContext_Block_MakeCurrentOperation::operator () (Object* object)
+void ReleaseContext_Block_MakeCurrentOperation::operator () (GraphicsContext* context)
{
- GraphicsContext* context = dynamic_cast<GraphicsContext*>(object);
- if (!context) return;
-
// release the graphics context.
context->releaseContext();
@@ -111,7 +89,7 @@
BlockAndFlushOperation::BlockAndFlushOperation():
- Operation("Block",false)
+ GraphicsOperation("Block",false)
{
reset();
}
@@ -121,7 +99,7 @@
Block::release();
}
-void BlockAndFlushOperation::operator () (Object*)
+void BlockAndFlushOperation::operator () (GraphicsContext*)
{
glFlush();
Block::release();
Index: src/osgDB/DatabasePager.cpp
===================================================================
--- src/osgDB/DatabasePager.cpp (revision 7117)
+++ src/osgDB/DatabasePager.cpp (revision 7118)
@@ -903,17 +903,15 @@
DatabasePager::CompileOperation::CompileOperation(osgDB::DatabasePager* databasePager):
- osg::Operation("DatabasePager::CompileOperation",false),
+ osg::GraphicsOperation("DatabasePager::CompileOperation",false),
_databasePager(databasePager)
{
}
-void DatabasePager::CompileOperation::operator () (osg::Object* object)
+void DatabasePager::CompileOperation::operator () (osg::GraphicsContext* context)
{
- osg::GraphicsContext* context = dynamic_cast<osg::GraphicsContext*>(object);
- if (!context) return;
-
// osg::notify(osg::NOTICE)<<"Background thread compiling"<<std::endl;
+
if (_databasePager.valid()) _databasePager->compileAllGLObjects(*(context->getState()));
}
Index: src/osgWrappers/osgUtil/GLObjectsVisitor.cpp
===================================================================
--- src/osgWrappers/osgUtil/GLObjectsVisitor.cpp (revision 7117)
+++ src/osgWrappers/osgUtil/GLObjectsVisitor.cpp (revision 7118)
@@ -12,6 +12,7 @@
#include <osg/Drawable>
#include <osg/Geode>
+#include <osg/GraphicsContext>
#include <osg/Node>
#include <osg/RenderInfo>
#include <osg/State>
@@ -26,6 +27,15 @@
#undef OUT
#endif
+BEGIN_OBJECT_REFLECTOR(osgUtil::GLObjectsOperation)
+ I_DeclaringFile("osgUtil/GLObjectsVisitor");
+ I_BaseType(osg::GraphicsOperation);
+ I_ConstructorWithDefaults2(IN, osg::Node *, subgraph, , IN, osgUtil::GLObjectsVisitor::Mode, mode, osgUtil::GLObjectsVisitor::COMPILE_DISPLAY_LISTS|osgUtil::GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES|osgUtil::GLObjectsVisitor::CHECK_BLACK_LISTED_MODES,
+ ____GLObjectsOperation__osg_Node_P1__GLObjectsVisitor_Mode,
+ "",
+ "");
+END_REFLECTOR
+
TYPE_NAME_ALIAS(unsigned int, osgUtil::GLObjectsVisitor::Mode)
BEGIN_ENUM_REFLECTOR(osgUtil::GLObjectsVisitor::ModeValues)
Index: src/osgWrappers/osg/GraphicsThread.cpp
===================================================================
--- src/osgWrappers/osg/GraphicsThread.cpp (revision 7117)
+++ src/osgWrappers/osg/GraphicsThread.cpp (revision 7118)
@@ -10,6 +10,7 @@
#include <osgIntrospection/StaticMethodInfo>
#include <osgIntrospection/Attributes>
+#include <osg/GraphicsContext>
#include <osg/GraphicsThread>
#include <osg/Object>
@@ -30,7 +31,7 @@
BEGIN_OBJECT_REFLECTOR(osg::BarrierOperation)
I_DeclaringFile("osg/GraphicsThread");
- I_BaseType(osg::Operation);
+ I_BaseType(osg::GraphicsOperation);
I_BaseType(OpenThreads::Barrier);
I_ConstructorWithDefaults2(IN, int, numThreads, , IN, osg::BarrierOperation::PreBlockOp, op, osg::BarrierOperation::NO_OPERATION,
____BarrierOperation__int__PreBlockOp,
@@ -46,7 +47,7 @@
BEGIN_OBJECT_REFLECTOR(osg::BlockAndFlushOperation)
I_DeclaringFile("osg/GraphicsThread");
- I_BaseType(osg::Operation);
+ I_BaseType(osg::GraphicsOperation);
I_BaseType(OpenThreads::Block);
I_Constructor0(____BlockAndFlushOperation,
"",
@@ -58,6 +59,15 @@
"");
END_REFLECTOR
+BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::GraphicsOperation)
+ I_DeclaringFile("osg/GraphicsThread");
+ I_BaseType(osg::Operation);
+ I_Constructor2(IN, const std::string &, name, IN, bool, keep,
+ ____GraphicsOperation__C5_std_string_R1__bool,
+ "",
+ "");
+END_REFLECTOR
+
BEGIN_OBJECT_REFLECTOR(osg::GraphicsThread)
I_DeclaringFile("osg/GraphicsThread");
I_BaseType(osg::OperationThread);
@@ -73,7 +83,7 @@
BEGIN_OBJECT_REFLECTOR(osg::ReleaseContext_Block_MakeCurrentOperation)
I_DeclaringFile("osg/GraphicsThread");
- I_BaseType(osg::Operation);
+ I_BaseType(osg::GraphicsOperation);
I_BaseType(osg::RefBlock);
I_Constructor0(____ReleaseContext_Block_MakeCurrentOperation,
"",
@@ -81,13 +91,13 @@
I_Method0(void, release,
Properties::VIRTUAL,
__void__release,
- "if this operation is a barrier then release it. ",
+ "",
"");
END_REFLECTOR
BEGIN_OBJECT_REFLECTOR(osg::SwapBuffersOperation)
I_DeclaringFile("osg/GraphicsThread");
- I_BaseType(osg::Operation);
+ I_BaseType(osg::GraphicsOperation);
I_Constructor0(____SwapBuffersOperation,
"",
"");
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/