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 

OpenGL sync object and OSG

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

Joined: 28 Nov 2010
Posts: 87

PostPosted: Thu Jul 11, 2013 7:03 am    Post subject:
OpenGL sync object and OSG
Reply with quote

Hi forum,

To Synchronize the data transfer between the GPU(OpenCL) and CPU i need to use the OpenGL Sync object. If i have to code in OpenGL , the snippet could be laid out as follows:


cl_event release_event;
cl_int  errNum;

//OpenGL fence object is created. This creates and inserts a fence sync into
//OpenGL command stream

//The following command creates an OpenCL event linked to the fence. The OpenCL
//event is then used in the event list for clEnqueueAcquireGLObjects(), ensuring that
//the acquire call will proceed only after the fence has completed.
cl_event gl_event = clCreateEventFromGLsyncKHR(context,sync,NULL);

errNum = clEnqueueAcquireGLObjects(commandQueue,1,&cl_tex_mem,0,&gl_event,NULL);

//Several other OpenCL commands go on here - mainly kernel execution that will
//be handled by the computation node

//The following command will return an event object and stored in the release_event.
//It can be used to sync upon its completion
errNum = clEnqueueReleaseGLObjects(commandQueue,1,&cl_tex_mem,0,NULL,&release_event);

//creates the OpenGL sync object linked to the release_event
GLsync cl_sync = glCreateSyncFromCLeventARB(context, release_event,0);

//a wait is inserted into the OpenGL command stream
//that will wait upon the completion of the release_event associated with the clEnqueueReleaseGLObjects().
glWaitSync(cl_sync,0, GL_TIMEOUT_IGNORED);

Please Avoid the OpenCL references if it does not make any sense to you. I need some hint on how the gl commands will be distributed in pre and post draw callbacks.

Should i create two separate classes that deals with the pre draw callback and post draw callback or just post draw callback will be enough?

Best Regards
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 'fatal error C1128: number of section... Jason Beverage General 2 Wed Apr 18, 2018 7:59 pm View latest post
No new posts Texture Buffer Object Initialization ... EonStrife General 0 Tue Feb 27, 2018 7:53 am View latest post
No new posts META_object macro returning osg::Obje... hartwigw General 8 Sat Nov 25, 2017 10:05 am View latest post
No new posts Mouse position to object space GeekOwl General 4 Thu Nov 23, 2017 11:45 am View latest post
No new posts Draw thread per opengl context instea... BenM General 6 Thu Nov 09, 2017 2:23 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