Added name and keep member variables to osg::GraphicsThread::Operation to allow

the names of the operations to be logged for stats purposes, or used when
do searches of the operation list.  The keep member variable tells the graphics
thread run loop wether to remove the entry from the list once its been called.
This commit is contained in:
Robert Osfield 2005-08-30 19:03:02 +00:00
parent aba3b4fa67
commit f9bcde3cf0
4 changed files with 38 additions and 5 deletions

View File

@ -32,6 +32,7 @@
struct FrameOperation : public osg::GraphicsThread::Operation struct FrameOperation : public osg::GraphicsThread::Operation
{ {
FrameOperation(osg::CameraNode* camera, osg::FrameStamp* frameStamp): FrameOperation(osg::CameraNode* camera, osg::FrameStamp* frameStamp):
osg::GraphicsThread::Operation("Frame",true),
_camera(camera), _camera(camera),
_frameStamp(frameStamp) _frameStamp(frameStamp)
{ {
@ -174,6 +175,7 @@ int main( int argc, char **argv )
previous_tick = current_tick; previous_tick = current_tick;
// do the update traversal.
loadedModel->accept(updateVisitor); loadedModel->accept(updateVisitor);
// issue the frame for each camera. // issue the frame for each camera.

View File

@ -84,7 +84,27 @@ class OSG_EXPORT GraphicsThread : public Referenced, public OpenThreads::Thread
/** Base class for implementing GraphicsThread operations.*/ /** Base class for implementing GraphicsThread operations.*/
struct OSG_EXPORT Operation : public Referenced struct OSG_EXPORT Operation : public Referenced
{ {
Operation(const std::string& name, bool keep):
_name(name),
_keep(true) {}
/** Set the human readable name of the operation.*/
void setName(const std::string& name) { _name = name; }
/** Get the human readable name of the operation.*/
const std::string& gtName() const { return _name; }
/** Set whether the operation should be kept once its been applied.*/
void setKeep(bool keep) { _keep = keep; }
/** Get whether the operation should be kept once its been applied.*/
bool getKeep() const { return _keep; }
/** Do the actual task of this operation.*/
virtual void operator () (GraphicsContext*) {} virtual void operator () (GraphicsContext*) {}
std::string _name;
bool _keep;
}; };
/** Add operation to end of OperationQueue, this will be /** Add operation to end of OperationQueue, this will be
@ -118,10 +138,13 @@ class OSG_EXPORT GraphicsThread : public Referenced, public OpenThreads::Thread
/** SwapBufferOperation calls swap buffers on the GraphicsContext.*/ /** SwapBufferOperation calls swap buffers on the GraphicsContext.*/
struct OSG_EXPORT SwapBuffersOperation : public GraphicsThread::Operation struct OSG_EXPORT SwapBuffersOperation : public GraphicsThread::Operation
{ {
SwapBuffersOperation():
GraphicsThread::Operation("SwapBuffers",true) {}
virtual void operator () (GraphicsContext* context); virtual void operator () (GraphicsContext* context);
}; };
/** BarrierOperation allows one syncronize multiple GraphicsThreads with each other.*/ /** BarrierOperation allows one to syncronize multiple GraphicsThreads with each other.*/
struct OSG_EXPORT BarrierOperation : public GraphicsThread::Operation, public OpenThreads::Barrier struct OSG_EXPORT BarrierOperation : public GraphicsThread::Operation, public OpenThreads::Barrier
{ {
enum PreBlockOp enum PreBlockOp
@ -131,7 +154,10 @@ struct OSG_EXPORT BarrierOperation : public GraphicsThread::Operation, public Op
GL_FINISH GL_FINISH
}; };
BarrierOperation(int numThreads, PreBlockOp op=NO_OPERATION): OpenThreads::Barrier(numThreads), _preBlockOp(op) {} BarrierOperation(int numThreads, PreBlockOp op=NO_OPERATION):
GraphicsThread::Operation("Barrier", true),
OpenThreads::Barrier(numThreads),
_preBlockOp(op) {}
virtual void operator () (GraphicsContext* context); virtual void operator () (GraphicsContext* context);
@ -142,7 +168,8 @@ struct OSG_EXPORT BarrierOperation : public GraphicsThread::Operation, public Op
* then blocks waiting for context to be released, once the block is release the context is re-aqquired.*/ * 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 GraphicsThread::Operation, public Block struct OSG_EXPORT ReleaseContext_Block_MakeCurrentOperation : public GraphicsThread::Operation, public Block
{ {
ReleaseContext_Block_MakeCurrentOperation() {} ReleaseContext_Block_MakeCurrentOperation():
GraphicsThread::Operation("ReleaseContext_Block_MakeCurrent", false) {}
virtual void operator () (GraphicsContext* context); virtual void operator () (GraphicsContext* context);
}; };

View File

@ -50,7 +50,7 @@ class OSGPRODUCER_EXPORT GraphicsContextImplementation : public osg::GraphicsCon
/** Return true if the graphics context has been realised and is ready to use.*/ /** Return true if the graphics context has been realised and is ready to use.*/
virtual bool isRealizedImplementation() const { return _rs.valid() && _rs->isRealized(); } virtual bool isRealizedImplementation() const { return _rs.valid() && _rs->isRealized(); }
/** Release the graphics context.*/ /** Close the graphics context.*/
virtual void closeImplementation(); virtual void closeImplementation();
/** Make this graphics context current.*/ /** Make this graphics context current.*/

View File

@ -21,7 +21,11 @@ using namespace OpenThreads;
struct BlockOperation : public GraphicsThread::Operation, public Block struct BlockOperation : public GraphicsThread::Operation, public Block
{ {
BlockOperation() { reset(); } BlockOperation():
GraphicsThread::Operation("Block",false)
{
reset();
}
virtual void operator () (GraphicsContext*) virtual void operator () (GraphicsContext*)
{ {