Hi Andy,

On 9/11/06, Andy Preece <[EMAIL PROTECTED]> wrote:

Hi Don,

...  

How to I make my OSG program sync to the video vertical retrace (on Windows XP, with ATI GFX)?

Producer::RenderSurface -> Sync() seems to just call glFinish(). Is this sufficient?

Is there a way to set the desired target update rate (as you can in Performer)?



I've done this only a couple of times on Windows/ATI.  There is a slider in the Desktop ->propoerties dialogue that slides between Quality and Performance or some such thing.  You have to slide it all the way to Quality and this seems to enable sync on vertical retrace.  The way you will know is that a simple scene (the cow) will render at no higher a frame rate than the vertical retrace of the display device.

RenderSurface->sync() is _not_ "swap buffers sync on vertical retrace".  see the article on synchronization:

http://donburns.net/OSG/Articles/Synchronization/index.html

-don

Regards,

Andy


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Don Burns
Sent: 08 September 2006 18:12


To: osg users
Subject: Re: [osg-users] Stats display

 

Hi Andy,

There is an issue with precedence of dependence here.  CameraGroup's contain Cameras, and Cameras have REnderSurfaces.  If you use a RenderSurface directly, you don't have a Camera and likewise, you don't have a CameraGroup. 

FrameStats in CameraGroup are computed by simply ticking the Producer::Timer before and after each phase of a frame.  You can do the same thing with either the Producer::Timer or the osg::Timer (same thing, an unfornate overlap):

mainLoop()
{
     beginUpdate = timer->tick();
     sceneView->update();
     endUpdate = timer->tick();

     beginCull = timer->tick();
     sceneView->cull();
     endCull = timer->tick();

     beginDispatch = timer->tick();
     sceneView->draw();
     endDispatch = timer->tick();

renderSurface->swapBuffers();


    updateTime   = timer->delta_s( beginUpdate, endUpdate );
    cullTime     = timer->delta_s( beginCull, endCull );
    dispatchTime = timer->delta_s( beginDispatch, endDispatch );
}

Now, you can also get draw times (in the graphics card) by adding the following to the above code:

osg::Timer_t beginUpdate, endUpdate, beginCull, endCull, beginDispatch, endDispatch;
double updateTime, cullTime, dispatchTime; // in seconds
osg::Timer *timer = osg::Timer::instance();

Producer::PipeStats *pipeStats = Producer::PipeStats::instance();
pipeStats->setReturnTime( Producer::PipeStats::seconds );

GLuint drawToken = pipeStats->genQuery();
GLuint swapBuffersToken = pipeStats->genQuery();
double drawTime, swapBuffersTime;


mainLoop()
{
    beginUpdate = timer->tick();
    sceneView->update();
    endUpdate = timer->tick();

    beginCull = timer->tick();
    sceneView->cull();
    endCull = timer->tick();

    beginDispatch = timer->tick();
    pipeStats->begin( drawToken );
    sceneView->draw();
    endDispatch = timer->tick();
    pipeStats->end();

    pipeStats->begin( swapBuffersToken );
    renderSurface->swapBuffers();
    pipeStats->end();


    updateTime   = timer->delta_s( beginUpdate, endUpdate );
    cullTime     = timer->delta_s( beginCull, endCull );
    dispatchTime = timer->delta_s( beginDispatch, endDispatch );


    drawTime = pipeStats->getElapsedTime( drawToken );
    swapBuffersTime = pipeStats->getElapsedTime( swapBuffersToken );

}


Note that getElapsedTime will stall the main loop, while the the tokens are retrieved from the pipeline.  If you want to know just how long it stalls it, you can call this version of getElapsedTime:
   

double waitTime;
drawTime = pipeStats->getElapsedTime( drawToken, waitTime );
std::cout << "Waited " << waitTime << " seconds to retieve the draw time" << std::endl;

swapBuffersTime = pipeStats->getElapsedTime( swapBuffersToken, waitTime );
std::cout << "Waited " << waitTime << " seconds to retieve the swapBuffers time" << std::endl;


 With a little enginuity you can minimize the wait time by double buffering your tokens and retrieving your draw and swapbuffer times a frame late. 

To get statistics on the scene graph, use osgUtil::Statistics.

Please ignore Robert's suggestions to not use Producer.

-don

On 9/8/06, Andy Preece <[EMAIL PROTECTED] > wrote:

Hi Robert,

 

Apologies in advance for my ignorance here. Still trying to lean the OSG basics!

 

I am working with the OSGMFC example application, compiling under MS Visual Studio 2005. In the example it has the following code snippet in the window Create() callback function.

 

// create the window to draw to.

m_RenderSurface = new Producer::RenderSurface;

m_RenderSurface->setWindow(GetSafeHwnd());

m_RenderSurface->useBorder(false);

m_RenderSurface->setInputRectangle( Producer::RenderSurface::InputRectangle(0.0,1.0,0.0,1.0));

m_RenderSurface->fullScreen(false);

   

// create the view of the scene.

m_SceneView = new osgUtil::SceneView;

// Do SceneView set up

 

> If you don't use Producer then the Producer stats are of little use. 

 

By having a RenderSurface am I not using Producer?

How do I get to a Producer::CameraGroup from a Producer::RenderSurface?

(From trawling through the src code my assumption is that you can only get to a Producer::CameraGroup is you use osgProducer classes, such as osgProducer::Viewer)

 

Is it possible to write an OSG program without Producer? Any examples?

Do you recommend I swap from using osgUtil::SceneView to using osgProducer::Viewer? Are there any advantages to using osgUtil::SceneView?

 

On a different subject, how to I make my OSG program sync to the video vertical retrace (on Windows XP, with ATI GFX)?

Is there a way to set the desired target update rate (as you can in Performer)?

 

> If you want your own timing results you simply need to use osg::Timer and record the start/end of the update, cull and draw and do the frame stats yourself. 

 

OK. That's fine with me, but at some point I would like to get more that just the frame rate (i.e. how many geodes/tris rendered, how many state swaps etc). How do I get this information from an osgUtil::SceneView?

 

Regards,

Andy

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Robert Osfield
Sent: 08 September 2006 10:08


To: osg users
Subject: Re: [osg-users] Stats display

 

Hi Andy,

On 9/8/06, Andy Preece <[EMAIL PROTECTED]> wrote:

Thanks, I was looking at the code before emailing, but I could not find away to get a Producer::CameraGroup pointer/reference from an osgUtil::SceneView.

Actually what I really need is a way to get at the Producer::CameraGroup::FrameStats information. How do I do this?


If you doin't use Producer then the Producer stats are of little use.  If you want your own timing results you simply need to use osg::Timer and record the start/end of the update, cull and draw and do the frame stats  yourself. 

Robert.


________________________________________________________________________
This e-mail has been scanned for all viruses by Star.The service is powered by MessageLabs.
________________________________________________________________________


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

 


________________________________________________________________________
This e-mail has been scanned for all viruses by Star.The service is powered by MessageLabs.
________________________________________________________________________

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to