[osg-users] Frame Count/Threading Models

paul1492 at yahoo.com paul1492 at yahoo.com
Mon Nov 23 12:35:44 PST 2009


Any help would be appreciated. 

How do I get a valid graphics context in a Pre Draw Callback so I can call glXQueryFrameCountNV()? 

See below for details.

Thanks,
Paul P.


----- Original Message ----
From: "paul1492 at yahoo.com" <paul1492 at yahoo.com>
To: osg-users at lists.openscenegraph.org
Sent: Wed, November 4, 2009 9:20:40 AM
Subject: [osg-users] Frame Count/Threading Models

I was using glXWaitVideoSyncSGI() in a Pre Draw Callback (the place I need it to be) to get the current Frame Count from the video card. I've recently found out that this Frame Count number from this function can be incorrect when I'm reading textures from the GPU to the CPU or writing textures from the CPU to the GPU. In particular, I would see about 100ms between calls to glXWaitVideoSyncSGI but the frame counter returned would either be consecutive (i.e. no missed frames) or skipping one number (i.e. one missed frame). I'm running at 60 Hz (16ms frames).

Therefore, I'm now trying to use glXQueryFrameCountNV() (I have G-SYNC II card and have enabled Frame Lock). It would appear I need to call this when I have a valid Graphics Context. I assume this isn't normally the case in a PreDrawCallback.  I've had to do this in the PreDrawCallback:
            if (camera.getGraphicsContext() &&
                camera.getGraphicsContext()->valid() &&
                camera.getGraphicsContext()->isRealized())
            {
                osg::GraphicsContext* gc = const_cast<osg::GraphicsContext*>(camera.getGraphicsContext());
                gc->makeCurrent();
            }
followed by my call to glXQueryFrameCountNV().

However, to make this work, I've had to set my osgViewer's threading model to SingleThreaded. If I don't do this I usually see a "Xlib: unexpected async reply (sequence 0x6a)!" message followed by a segmentation fault.

What am I doing wrong? Is there some better way to do something in a valid graphics context when not in a draw callback?

Paul P.


      
_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



      


More information about the osg-users mailing list