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 | #ifdef VBOXCR_LOGFPS
|
---|
85 | uint64_t timeUsed;
|
---|
86 | #endif
|
---|
87 | } CRClient;
|
---|
88 |
|
---|
89 | typedef struct CRPoly_t {
|
---|
90 | int npoints;
|
---|
91 | double *points;
|
---|
92 | struct CRPoly_t *next;
|
---|
93 | } CRPoly;
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * There's one of these run queue entries per client
|
---|
97 | * The run queue is a circular, doubly-linked list of these objects.
|
---|
98 | */
|
---|
99 | typedef struct RunQueue_t {
|
---|
100 | CRClient *client;
|
---|
101 | int blocked;
|
---|
102 | struct RunQueue_t *next;
|
---|
103 | struct RunQueue_t *prev;
|
---|
104 | } RunQueue;
|
---|
105 |
|
---|
106 | typedef struct {
|
---|
107 | GLint freeWindowID;
|
---|
108 | GLint freeContextID;
|
---|
109 | GLint freeClientID;
|
---|
110 | } CRServerFreeIDsPool_t;
|
---|
111 |
|
---|
112 | typedef struct {
|
---|
113 | int32_t x, y;
|
---|
114 | uint32_t w, h;
|
---|
115 | uint64_t winID;
|
---|
116 | } CRScreenInfo;
|
---|
117 |
|
---|
118 | typedef struct {
|
---|
119 | unsigned short tcpip_port;
|
---|
120 |
|
---|
121 | CRScreenInfo screen[CR_MAX_GUEST_MONITORS];
|
---|
122 | int screenCount;
|
---|
123 |
|
---|
124 | int numClients;
|
---|
125 | CRClient *clients[CR_MAX_CLIENTS]; /**< array [numClients] */
|
---|
126 | CRClient *curClient;
|
---|
127 | CRCurrentStatePointers current;
|
---|
128 |
|
---|
129 | GLboolean firstCallCreateContext;
|
---|
130 | GLboolean firstCallMakeCurrent;
|
---|
131 | GLboolean bIsInLoadingState; /* Indicates if we're in process of loading VM snapshot */
|
---|
132 | GLboolean bIsInSavingState; /* Indicates if we're in process of saving VM snapshot */
|
---|
133 | GLint currentWindow;
|
---|
134 | GLint currentNativeWindow;
|
---|
135 |
|
---|
136 | CRHashTable *muralTable; /**< hash table where all murals are stored */
|
---|
137 | CRHashTable *pWindowCreateInfoTable; /**< hash table with windows creation info */
|
---|
138 |
|
---|
139 | int client_spu_id;
|
---|
140 |
|
---|
141 | CRServerFreeIDsPool_t idsPool;
|
---|
142 |
|
---|
143 | int mtu;
|
---|
144 | int buffer_size;
|
---|
145 | char protocol[1024];
|
---|
146 |
|
---|
147 | SPU *head_spu;
|
---|
148 | SPUDispatchTable dispatch;
|
---|
149 |
|
---|
150 | CRNetworkPointer return_ptr;
|
---|
151 | CRNetworkPointer writeback_ptr;
|
---|
152 |
|
---|
153 | CRLimitsState limits; /**< GL limits for any contexts we create */
|
---|
154 |
|
---|
155 | int SpuContext; /**< Rendering context for the head SPU */
|
---|
156 | int SpuContextVisBits; /**< Context's visual attributes */
|
---|
157 | char *SpuContextDpyName; /**< Context's dpyName */
|
---|
158 |
|
---|
159 | CRHashTable *contextTable; /**< hash table for rendering contexts */
|
---|
160 | CRHashTable *pContextCreateInfoTable; /**< hash table with contexts creation info */
|
---|
161 | CRContext *DummyContext; /**< used when no other bound context */
|
---|
162 |
|
---|
163 | CRHashTable *programTable; /**< for vertex programs */
|
---|
164 | GLuint currentProgram;
|
---|
165 |
|
---|
166 | /** configuration options */
|
---|
167 | /*@{*/
|
---|
168 | int useL2;
|
---|
169 | int ignore_papi;
|
---|
170 | unsigned int maxBarrierCount;
|
---|
171 | unsigned int clearCount;
|
---|
172 | int optimizeBucket;
|
---|
173 | int only_swap_once;
|
---|
174 | int debug_barriers;
|
---|
175 | int sharedDisplayLists;
|
---|
176 | int sharedTextureObjects;
|
---|
177 | int sharedPrograms;
|
---|
178 | int sharedWindows;
|
---|
179 | int uniqueWindows;
|
---|
180 | int localTileSpec;
|
---|
181 | int useDMX;
|
---|
182 | int overlapBlending;
|
---|
183 | int vpProjectionMatrixParameter;
|
---|
184 | const char *vpProjectionMatrixVariable;
|
---|
185 | int stereoView;
|
---|
186 | int vncMode; /* cmd line option */
|
---|
187 | /*@}*/
|
---|
188 | /** view_matrix config */
|
---|
189 | /*@{*/
|
---|
190 | GLboolean viewOverride;
|
---|
191 | CRmatrix viewMatrix[2]; /**< left and right eye */
|
---|
192 | /*@}*/
|
---|
193 | /** projection_matrix config */
|
---|
194 | /*@{*/
|
---|
195 | GLboolean projectionOverride;
|
---|
196 | CRmatrix projectionMatrix[2]; /**< left and right eye */
|
---|
197 | int currentEye;
|
---|
198 | /*@}*/
|
---|
199 |
|
---|
200 | /** for warped tiles */
|
---|
201 | /*@{*/
|
---|
202 | GLfloat alignment_matrix[16], unnormalized_alignment_matrix[16];
|
---|
203 | /*@}*/
|
---|
204 |
|
---|
205 | /** tile overlap/blending info - this should probably be per-mural */
|
---|
206 | /*@{*/
|
---|
207 | CRPoly **overlap_geom;
|
---|
208 | CRPoly *overlap_knockout;
|
---|
209 | float *overlap_intens;
|
---|
210 | int num_overlap_intens;
|
---|
211 | int num_overlap_levels;
|
---|
212 | /*@}*/
|
---|
213 |
|
---|
214 | CRHashTable *barriers, *semaphores;
|
---|
215 |
|
---|
216 | RunQueue *run_queue;
|
---|
217 |
|
---|
218 | GLuint currentSerialNo;
|
---|
219 |
|
---|
220 | PFNCRSERVERPRESENTFBO pfnPresentFBO;
|
---|
221 | } CRServer;
|
---|
222 |
|
---|
223 |
|
---|
224 | extern DECLEXPORT(void) crServerInit( int argc, char *argv[] );
|
---|
225 | extern DECLEXPORT(int) CRServerMain( int argc, char *argv[] );
|
---|
226 | extern DECLEXPORT(void) crServerServiceClients(void);
|
---|
227 | extern DECLEXPORT(void) crServerAddNewClient(void);
|
---|
228 | extern DECLEXPORT(SPU*) crServerHeadSPU(void);
|
---|
229 | extern DECLEXPORT(void) crServerSetPort(int port);
|
---|
230 |
|
---|
231 | extern DECLEXPORT(GLboolean) crVBoxServerInit(void);
|
---|
232 | extern DECLEXPORT(void) crVBoxServerTearDown(void);
|
---|
233 | extern DECLEXPORT(int32_t) crVBoxServerAddClient(uint32_t u32ClientID);
|
---|
234 | extern DECLEXPORT(void) crVBoxServerRemoveClient(uint32_t u32ClientID);
|
---|
235 | extern DECLEXPORT(int32_t) crVBoxServerClientWrite(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t cbBuffer);
|
---|
236 | extern DECLEXPORT(int32_t) crVBoxServerClientRead(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t *pcbBuffer);
|
---|
237 | extern DECLEXPORT(int32_t) crVBoxServerClientSetVersion(uint32_t u32ClientID, uint32_t vMajor, uint32_t vMinor);
|
---|
238 |
|
---|
239 | extern DECLEXPORT(int32_t) crVBoxServerSaveState(PSSMHANDLE pSSM);
|
---|
240 | extern DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version);
|
---|
241 |
|
---|
242 | extern DECLEXPORT(int32_t) crVBoxServerSetScreenCount(int sCount);
|
---|
243 | extern DECLEXPORT(int32_t) crVBoxServerUnmapScreen(int sIndex);
|
---|
244 | extern DECLEXPORT(int32_t) crVBoxServerMapScreen(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h, uint64_t winID);
|
---|
245 |
|
---|
246 | extern DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, GLint *pRects);
|
---|
247 |
|
---|
248 | extern DECLEXPORT(void) crVBoxServerSetPresentFBOCB(PFNCRSERVERPRESENTFBO pfnPresentFBO);
|
---|
249 |
|
---|
250 | #ifdef __cplusplus
|
---|
251 | }
|
---|
252 | #endif
|
---|
253 |
|
---|
254 | #endif
|
---|
255 |
|
---|