1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved.
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #ifndef INCLUDE_CR_SERVER_H
|
---|
8 | #define INCLUDE_CR_SERVER_H
|
---|
9 |
|
---|
10 | #include "cr_spu.h"
|
---|
11 | #include "cr_net.h"
|
---|
12 | #include "cr_hash.h"
|
---|
13 | #include "cr_protocol.h"
|
---|
14 | #include "cr_glstate.h"
|
---|
15 | #include "spu_dispatch_table.h"
|
---|
16 |
|
---|
17 | #include "state/cr_currentpointers.h"
|
---|
18 |
|
---|
19 | #include <iprt/types.h>
|
---|
20 | #include <iprt/err.h>
|
---|
21 |
|
---|
22 | #include <VBox/ssm.h>
|
---|
23 |
|
---|
24 | #ifdef __cplusplus
|
---|
25 | extern "C" {
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | #define CR_MAX_WINDOWS 100
|
---|
29 | #define CR_MAX_CLIENTS 20
|
---|
30 |
|
---|
31 | /*@todo must match MaxGuestMonitors from SchemaDefs.h*/
|
---|
32 | #define CR_MAX_GUEST_MONITORS 8
|
---|
33 |
|
---|
34 | typedef DECLCALLBACKPTR(void, PFNCRSERVERPRESENTFBO) (void *data, int32_t screenId, int32_t x, int32_t y, uint32_t w, uint32_t h);
|
---|
35 |
|
---|
36 | typedef struct {
|
---|
37 | CRrecti imagewindow; /**< coordinates in mural space */
|
---|
38 | CRrectf bounds; /**< normalized coordinates in [-1,-1] x [1,1] */
|
---|
39 | CRrecti outputwindow; /**< coordinates in server's rendering window */
|
---|
40 | CRrecti clippedImagewindow; /**< imagewindow clipped to current viewport */
|
---|
41 | CRmatrix baseProjection; /**< pre-multiplied onto projection matrix */
|
---|
42 | CRrecti scissorBox; /**< passed to back-end OpenGL */
|
---|
43 | CRrecti viewport; /**< passed to back-end OpenGL */
|
---|
44 | GLuint serialNo; /**< an optimization */
|
---|
45 | } CRExtent;
|
---|
46 |
|
---|
47 | struct BucketingInfo;
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Mural info
|
---|
51 | */
|
---|
52 | typedef struct {
|
---|
53 | GLuint width, height;
|
---|
54 | GLint gX, gY; /*guest coordinates*/
|
---|
55 | GLint hX, hY; /*host coordinates, screenID related*/
|
---|
56 |
|
---|
57 | int spuWindow; /*the SPU's corresponding window ID */
|
---|
58 |
|
---|
59 | int screenId;
|
---|
60 |
|
---|
61 | GLboolean bVisible; /*guest window is visible*/
|
---|
62 | GLboolean bUseFBO; /*redirect to FBO instead of real host window*/
|
---|
63 |
|
---|
64 | GLint cVisibleRects; /*count of visible rects*/
|
---|
65 | GLint *pVisibleRects; /*visible rects left, top, right, bottom*/
|
---|
66 |
|
---|
67 | GLuint idFBO, idColorTex, idDepthStencilRB;
|
---|
68 | GLuint fboWidth, fboHeight;
|
---|
69 | } CRMuralInfo;
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * A client is basically an upstream Cr Node (connected via mothership)
|
---|
73 | */
|
---|
74 | typedef struct _crclient {
|
---|
75 | int spu_id; /**< id of the last SPU in the client's SPU chain */
|
---|
76 | CRConnection *conn; /**< network connection from the client */
|
---|
77 | int number; /**< a unique number for each client */
|
---|
78 | GLint currentContextNumber;
|
---|
79 | CRContext *currentCtx;
|
---|
80 | GLint currentWindow;
|
---|
81 | CRMuralInfo *currentMural;
|
---|
82 | GLint windowList[CR_MAX_WINDOWS];
|
---|
83 | GLint contextList[CR_MAX_CONTEXTS];
|
---|
84 | } CRClient;
|
---|
85 |
|
---|
86 | typedef struct CRPoly_t {
|
---|
87 | int npoints;
|
---|
88 | double *points;
|
---|
89 | struct CRPoly_t *next;
|
---|
90 | } CRPoly;
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * There's one of these run queue entries per client
|
---|
94 | * The run queue is a circular, doubly-linked list of these objects.
|
---|
95 | */
|
---|
96 | typedef struct RunQueue_t {
|
---|
97 | CRClient *client;
|
---|
98 | int blocked;
|
---|
99 | struct RunQueue_t *next;
|
---|
100 | struct RunQueue_t *prev;
|
---|
101 | } RunQueue;
|
---|
102 |
|
---|
103 | typedef struct {
|
---|
104 | GLint freeWindowID;
|
---|
105 | GLint freeContextID;
|
---|
106 | GLint freeClientID;
|
---|
107 | } CRServerFreeIDsPool_t;
|
---|
108 |
|
---|
109 | typedef struct {
|
---|
110 | int32_t x, y;
|
---|
111 | uint32_t w, h;
|
---|
112 | uint64_t winID;
|
---|
113 | } CRScreenInfo;
|
---|
114 |
|
---|
115 | typedef struct {
|
---|
116 | unsigned short tcpip_port;
|
---|
117 |
|
---|
118 | CRScreenInfo screen[CR_MAX_GUEST_MONITORS];
|
---|
119 | int screenCount;
|
---|
120 |
|
---|
121 | int numClients;
|
---|
122 | CRClient *clients[CR_MAX_CLIENTS]; /**< array [numClients] */
|
---|
123 | CRClient *curClient;
|
---|
124 | CRCurrentStatePointers current;
|
---|
125 |
|
---|
126 | GLboolean firstCallCreateContext;
|
---|
127 | GLboolean firstCallMakeCurrent;
|
---|
128 | GLboolean bIsInLoadingState; /* Indicates if we're in process of loading VM snapshot */
|
---|
129 | GLboolean bIsInSavingState; /* Indicates if we're in process of saving VM snapshot */
|
---|
130 | GLint currentWindow;
|
---|
131 | GLint currentNativeWindow;
|
---|
132 |
|
---|
133 | CRHashTable *muralTable; /**< hash table where all murals are stored */
|
---|
134 | CRHashTable *pWindowCreateInfoTable; /**< hash table with windows creation info */
|
---|
135 |
|
---|
136 | int client_spu_id;
|
---|
137 |
|
---|
138 | CRServerFreeIDsPool_t idsPool;
|
---|
139 |
|
---|
140 | int mtu;
|
---|
141 | int buffer_size;
|
---|
142 | char protocol[1024];
|
---|
143 |
|
---|
144 | SPU *head_spu;
|
---|
145 | SPUDispatchTable dispatch;
|
---|
146 |
|
---|
147 | CRNetworkPointer return_ptr;
|
---|
148 | CRNetworkPointer writeback_ptr;
|
---|
149 |
|
---|
150 | CRLimitsState limits; /**< GL limits for any contexts we create */
|
---|
151 |
|
---|
152 | int SpuContext; /**< Rendering context for the head SPU */
|
---|
153 | int SpuContextVisBits; /**< Context's visual attributes */
|
---|
154 | char *SpuContextDpyName; /**< Context's dpyName */
|
---|
155 |
|
---|
156 | CRHashTable *contextTable; /**< hash table for rendering contexts */
|
---|
157 | CRHashTable *pContextCreateInfoTable; /**< hash table with contexts creation info */
|
---|
158 | CRContext *DummyContext; /**< used when no other bound context */
|
---|
159 |
|
---|
160 | CRHashTable *programTable; /**< for vertex programs */
|
---|
161 | GLuint currentProgram;
|
---|
162 |
|
---|
163 | /** configuration options */
|
---|
164 | /*@{*/
|
---|
165 | int useL2;
|
---|
166 | int ignore_papi;
|
---|
167 | unsigned int maxBarrierCount;
|
---|
168 | unsigned int clearCount;
|
---|
169 | int optimizeBucket;
|
---|
170 | int only_swap_once;
|
---|
171 | int debug_barriers;
|
---|
172 | int sharedDisplayLists;
|
---|
173 | int sharedTextureObjects;
|
---|
174 | int sharedPrograms;
|
---|
175 | int sharedWindows;
|
---|
176 | int uniqueWindows;
|
---|
177 | int localTileSpec;
|
---|
178 | int useDMX;
|
---|
179 | int overlapBlending;
|
---|
180 | int vpProjectionMatrixParameter;
|
---|
181 | const char *vpProjectionMatrixVariable;
|
---|
182 | int stereoView;
|
---|
183 | int vncMode; /* cmd line option */
|
---|
184 | /*@}*/
|
---|
185 | /** view_matrix config */
|
---|
186 | /*@{*/
|
---|
187 | GLboolean viewOverride;
|
---|
188 | CRmatrix viewMatrix[2]; /**< left and right eye */
|
---|
189 | /*@}*/
|
---|
190 | /** projection_matrix config */
|
---|
191 | /*@{*/
|
---|
192 | GLboolean projectionOverride;
|
---|
193 | CRmatrix projectionMatrix[2]; /**< left and right eye */
|
---|
194 | int currentEye;
|
---|
195 | /*@}*/
|
---|
196 |
|
---|
197 | /** for warped tiles */
|
---|
198 | /*@{*/
|
---|
199 | GLfloat alignment_matrix[16], unnormalized_alignment_matrix[16];
|
---|
200 | /*@}*/
|
---|
201 |
|
---|
202 | /** tile overlap/blending info - this should probably be per-mural */
|
---|
203 | /*@{*/
|
---|
204 | CRPoly **overlap_geom;
|
---|
205 | CRPoly *overlap_knockout;
|
---|
206 | float *overlap_intens;
|
---|
207 | int num_overlap_intens;
|
---|
208 | int num_overlap_levels;
|
---|
209 | /*@}*/
|
---|
210 |
|
---|
211 | CRHashTable *barriers, *semaphores;
|
---|
212 |
|
---|
213 | RunQueue *run_queue;
|
---|
214 |
|
---|
215 | GLuint currentSerialNo;
|
---|
216 |
|
---|
217 | PFNCRSERVERPRESENTFBO pfnPresentFBO;
|
---|
218 | } CRServer;
|
---|
219 |
|
---|
220 |
|
---|
221 | extern DECLEXPORT(void) crServerInit( int argc, char *argv[] );
|
---|
222 | extern DECLEXPORT(int) CRServerMain( int argc, char *argv[] );
|
---|
223 | extern DECLEXPORT(void) crServerServiceClients(void);
|
---|
224 | extern DECLEXPORT(void) crServerAddNewClient(void);
|
---|
225 | extern DECLEXPORT(SPU*) crServerHeadSPU(void);
|
---|
226 | extern DECLEXPORT(void) crServerSetPort(int port);
|
---|
227 |
|
---|
228 | extern DECLEXPORT(GLboolean) crVBoxServerInit(void);
|
---|
229 | extern DECLEXPORT(void) crVBoxServerTearDown(void);
|
---|
230 | extern DECLEXPORT(int32_t) crVBoxServerAddClient(uint32_t u32ClientID);
|
---|
231 | extern DECLEXPORT(void) crVBoxServerRemoveClient(uint32_t u32ClientID);
|
---|
232 | extern DECLEXPORT(int32_t) crVBoxServerClientWrite(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t cbBuffer);
|
---|
233 | extern DECLEXPORT(int32_t) crVBoxServerClientRead(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t *pcbBuffer);
|
---|
234 | extern DECLEXPORT(int32_t) crVBoxServerClientSetVersion(uint32_t u32ClientID, uint32_t vMajor, uint32_t vMinor);
|
---|
235 |
|
---|
236 | extern DECLEXPORT(int32_t) crVBoxServerSaveState(PSSMHANDLE pSSM);
|
---|
237 | extern DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version);
|
---|
238 |
|
---|
239 | extern DECLEXPORT(int32_t) crVBoxServerSetScreenCount(int sCount);
|
---|
240 | extern DECLEXPORT(int32_t) crVBoxServerUnmapScreen(int sIndex);
|
---|
241 | extern DECLEXPORT(int32_t) crVBoxServerMapScreen(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h, uint64_t winID);
|
---|
242 |
|
---|
243 | extern DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, GLint *pRects);
|
---|
244 |
|
---|
245 | extern DECLEXPORT(void) crVBoxServerSetPresentFBOCB(PFNCRSERVERPRESENTFBO pfnPresentFBO);
|
---|
246 |
|
---|
247 | #ifdef __cplusplus
|
---|
248 | }
|
---|
249 | #endif
|
---|
250 |
|
---|
251 | #endif
|
---|
252 |
|
---|