HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_Sync.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RE_Sync.h ( RE Library, C++)
7  *
8  * COMMENTS:
9  * Implements the GL_ARB_sync extension, which can be used to wait until
10  * a certain GL command has been processed by the server. Either the client
11  * or the server can wait. In the case of the client, the thread making
12  * GL calls will be suspended until the sync command is processed. For the
13  * Server, the GL command stream is suspended until the sync command is
14  * processed.
15  *
16  * Sync objects can be used to synchronize multiple contexts as well,
17  * which is useful for the loader/renderer paradigm.
18  *
19  *
20  * RE_RenderWait implements a client sync.
21  * RE_CommandSync implements a server sync.
22  */
23 #ifndef RE_Sync_h
24 #define RE_Sync_h
25 
26 #include <SYS/SYS_Types.h>
27 #include "RE_API.h"
28 
29 class re_OGLSync;
30 class RE_Render;
31 
33 {
34 public:
35  RE_RenderWait();
36  ~RE_RenderWait();
37 
38  // Inserts a sync command into the GL render stream.
39  bool insertSyncPoint(RE_Render *r);
40 
41  // Checks to see if a sync point has been created. Useful for syncing
42  // multiple threads, as the client thread may not have created the sync yet
43  // that another thread waits on.
44  bool doesSyncPointExist() const { return mySyncObject != NULL; }
45 
46  // All of the wait and sync methods returns true if the sync point was
47  // reached. They will return false if an error occurred, if the timeout
48  // expires, or if the sync has not be already set with insertSyncPoint().
49 
50  // Checks if the point has been reached, or returns false immediately.
51  bool poll(RE_Render *r);
52 
53  // Waits indefinitely for the sync point to be reached.
54  bool wait(RE_Render *r);
55 
56  // Waits until sync point is hit or the timeout expires.
57  bool wait(RE_Render *r, uint64 timeout_in_ns);
58 
59  // resets the sync object for reuse, so that previous results aren't
60  // mistakenly interpreted as complete.
61  void reset();
62 
63 private:
64  re_OGLSync *mySyncObject;
65 };
66 
67 
69 {
70 public:
72  ~RE_CommandSync();
73 
74  // Inserts a sync point into the command stream. Will return false if the
75  // sync extension is not supported, otherwise true.
76  bool insertSyncPoint(RE_Render *r);
77 
78  // Inserts a wait point into the command stream, which waits until the
79  // previous sync point has completed. Will return false if no sync point
80  // was previously set.
81  bool insertWaitPoint(RE_Render *r);
82 
83  void reset();
84 private:
85  re_OGLSync *mySyncObject;
86 };
87 
88 #endif
#define RE_API
Definition: RE_API.h:10
bool doesSyncPointExist() const
Definition: RE_Sync.h:44
unsigned long long uint64
Definition: SYS_Types.h:108
GLboolean r
Definition: glcorearb.h:1221