OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Adding osgCompute::Computation during runtime does not work...


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgCompute [osgCompute]
View previous topic :: View next topic  
Author Message
socke
User


Joined: 06 Sep 2010
Posts: 62

PostPosted: Thu Jul 21, 2011 9:25 pm    Post subject:
Adding osgCompute::Computation during runtime does not work...
Reply with quote

Hi,

I am adding an osgCompute::Computation node during runtime inside the updateTraversal of our viewer.

This works fine when added in the first updateTraversal frame, but fails in all later frames. What am I misunderstanding oder missing? Any hints?

Below the code:

Code:
void osgDAC::DACViewer::updateTraversal() {

..................... some stuff ....................

   framecnt_++;
   if (framecnt_ == 2) { // this fails, but works for framecnt_ == 1
      // osgCompute
      setThreadingModel(osgViewer::CompositeViewer::SingleThreaded);
      setReleaseContextAtEndOfFrameHint(false);

      osg::ref_ptr<osgCompute::Computation> computation = dacGPU::setupComputation();

      osg::ref_ptr<osgCompute::Module> module = computation->getModule( "osgcuda_warp" );
      if( !module )
      {
         osg::notify(osg::FATAL) << "Cannot find module identified by osgcuda_warp." << std::endl;
         return;
      }
      module->setUserData( getFrameStamp() );
      //osg::notify(osg::NOTICE)<<module->isEnabled()<<std::endl;
      
      // Add computation to scene
      getManager()->getGeometryRoot()->addChild(computation);
   }


} // UpdateTraversal Done



Thank you!

Cheers,
Johannes[/code]
Back to top
View user's profile Send private message
socke
User


Joined: 06 Sep 2010
Posts: 62

PostPosted: Sat Jul 23, 2011 8:15 am    Post subject:
Reply with quote

Finally I found it working, when manually assigning the context:

Code:
   framecnt_++;
   if (framecnt_ == 2) {
      // osgCompute
      setThreadingModel(osgViewer::CompositeViewer::SingleThreaded);
      setReleaseContextAtEndOfFrameHint(false);

      osgViewer::ViewerBase::Contexts ctxs;
      getContexts(ctxs, true);
      osgCompute::GLMemory::bindToContext(*ctxs[0]);

      osg::ref_ptr<osgCompute::Computation> computation = dacGPU::setupComputation();

      osg::ref_ptr<osgCompute::Module> module = computation->getModule( "osgcuda_warp" );
      if( !module )
      {
         osg::notify(osg::FATAL) << "Cannot find module identified by osgcuda_warp." << std::endl;
         return;
      }
      module->setUserData( getFrameStamp() );

      // Add computation to scene
      getManager()->getGeometryRoot()->addChild(computation);
   }


Best regards,

Johannes
Back to top
View user's profile Send private message
jens.svt
User


Joined: 16 Mar 2009
Posts: 30

PostPosted: Sun Jul 24, 2011 12:33 pm    Post subject:
Reply with quote

Hi Johannes,

that is great to hear. We fixed this problem in the current SVN version.
Now you can add a computation node whenever you want.

You should concider setting the following flags before realize() of your viewer, otherwise it might have no effect.
Code:

viewer->setThreadingModel(osgViewer::CompositeViewer::SingleThreaded);
viewer->setReleaseContextAtEndOfFrameHint(false);
...
viewer->realize();
...
viewer->run();



Best regards,
Jens
Back to top
View user's profile Send private message
socke
User


Joined: 06 Sep 2010
Posts: 62

PostPosted: Mon Jul 25, 2011 6:58 am    Post subject:
Reply with quote

Hi Jens,

thanks for your reply.

Currently we DO NOT set those flags before realize() because using the osgCompute functionality is only a "sub-case" of the application (only needed when the user whats to deform a geometry).

So if the user wants to start deformation osgCompute is initialized. For the moment setting setThreadingModel and setReleaseContextAtEndOfFrameHint during runtime works for us.

I will keep your hint in mind if we experience problem later on.


Thank you!

Cheers,
Johannes
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgCompute [osgCompute] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Fix FBX rotation matrix computation Farshid Lashkari Submission 1 Tue Apr 11, 2017 11:21 pm View latest post
No new posts problems getting shadow demo to work Lee Butler General 1 Mon Feb 20, 2017 4:02 am View latest post
No new posts bug: osgText doesn't work on MacOSX G... remoe General 19 Fri Jan 20, 2017 7:53 pm View latest post
No new posts Disable/Enable default keyevent durin... robertosfield General 4 Mon Nov 07, 2016 7:53 am View latest post
No new posts bug: Android cross compile (windows) ... remoe Build system [build] 0 Sat Oct 29, 2016 7:51 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP