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 "cr_vreg.h"
|
---|
16 | #include "cr_blitter.h"
|
---|
17 | #include "spu_dispatch_table.h"
|
---|
18 | #include "cr_dump.h"
|
---|
19 |
|
---|
20 | #include "state/cr_currentpointers.h"
|
---|
21 |
|
---|
22 | #include <iprt/types.h>
|
---|
23 | #include <iprt/err.h>
|
---|
24 | #include <iprt/string.h>
|
---|
25 | #include <iprt/list.h>
|
---|
26 | #include <iprt/thread.h>
|
---|
27 | #include <iprt/critsect.h>
|
---|
28 | #include <iprt/semaphore.h>
|
---|
29 |
|
---|
30 | #include <VBox/vmm/ssm.h>
|
---|
31 |
|
---|
32 | #ifdef VBOX_WITH_CRHGSMI
|
---|
33 | # include <VBox/VBoxVideo.h>
|
---|
34 | #endif
|
---|
35 | #include <VBox/Hardware/VBoxVideoVBE.h>
|
---|
36 |
|
---|
37 | #include "cr_vreg.h"
|
---|
38 |
|
---|
39 | #ifdef __cplusplus
|
---|
40 | extern "C" {
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #define CR_MAX_WINDOWS 100
|
---|
44 | #define CR_MAX_CLIENTS 64
|
---|
45 |
|
---|
46 | /*@todo must match MaxGuestMonitors from SchemaDefs.h*/
|
---|
47 | #define CR_MAX_GUEST_MONITORS VBOX_VIDEO_MAX_SCREENS
|
---|
48 |
|
---|
49 | typedef DECLCALLBACKPTR(void, PFNCRSERVERPRESENTFBO) (void *data, int32_t screenId, int32_t x, int32_t y, uint32_t w, uint32_t h);
|
---|
50 |
|
---|
51 | /* Callbacks for output of the rendered frames.
|
---|
52 | *
|
---|
53 | * This allows to pass rendered frames to an external component rather than draw them on screen.
|
---|
54 | *
|
---|
55 | * An external component registers the redirection callbacks using crVBoxServerOutputRedirectSet.
|
---|
56 | *
|
---|
57 | * The list of formats supported by the caller is obtained using CRORContextProperty.
|
---|
58 | * The actual format choosed by the service is passed as a CRORBegin parameter.
|
---|
59 | */
|
---|
60 | typedef struct {
|
---|
61 | const void *pvContext; /* Supplied by crVBoxServerOutputRedirectSet. */
|
---|
62 | DECLR3CALLBACKMEMBER(void, CRORBegin, (const void *pvContext, void **ppvInstance,
|
---|
63 | const char *pszFormat));
|
---|
64 | DECLR3CALLBACKMEMBER(void, CRORGeometry, (void *pvInstance,
|
---|
65 | int32_t x, int32_t y, uint32_t w, uint32_t h));
|
---|
66 | DECLR3CALLBACKMEMBER(void, CRORVisibleRegion, (void *pvInstance,
|
---|
67 | uint32_t cRects, const RTRECT *paRects));
|
---|
68 | DECLR3CALLBACKMEMBER(void, CRORFrame, (void *pvInstance,
|
---|
69 | void *pvData, uint32_t cbData));
|
---|
70 | DECLR3CALLBACKMEMBER(void, CROREnd, (void *pvInstance));
|
---|
71 | DECLR3CALLBACKMEMBER(int, CRORContextProperty, (const void *pvContext, uint32_t index,
|
---|
72 | void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut));
|
---|
73 | } CROutputRedirect;
|
---|
74 |
|
---|
75 | typedef struct {
|
---|
76 | CRrecti imagewindow; /**< coordinates in mural space */
|
---|
77 | CRrectf bounds; /**< normalized coordinates in [-1,-1] x [1,1] */
|
---|
78 | CRrecti outputwindow; /**< coordinates in server's rendering window */
|
---|
79 | CRrecti clippedImagewindow; /**< imagewindow clipped to current viewport */
|
---|
80 | CRmatrix baseProjection; /**< pre-multiplied onto projection matrix */
|
---|
81 | CRrecti scissorBox; /**< passed to back-end OpenGL */
|
---|
82 | CRrecti viewport; /**< passed to back-end OpenGL */
|
---|
83 | GLuint serialNo; /**< an optimization */
|
---|
84 | } CRExtent;
|
---|
85 |
|
---|
86 | struct BucketingInfo;
|
---|
87 |
|
---|
88 | typedef struct {
|
---|
89 | char *pszDpyName;
|
---|
90 | GLint visualBits;
|
---|
91 | int32_t externalID;
|
---|
92 | } CRCreateInfo_t;
|
---|
93 |
|
---|
94 |
|
---|
95 | /* VRAM->RAM worker thread */
|
---|
96 |
|
---|
97 | typedef enum
|
---|
98 | {
|
---|
99 | CR_SERVER_RPW_STATE_UNINITIALIZED = 0,
|
---|
100 | CR_SERVER_RPW_STATE_INITIALIZING,
|
---|
101 | CR_SERVER_RPW_STATE_INITIALIZED,
|
---|
102 | CR_SERVER_RPW_STATE_UNINITIALIZING,
|
---|
103 | } CR_SERVER_RPW_STATE;
|
---|
104 |
|
---|
105 | /* worker control command */
|
---|
106 | typedef enum
|
---|
107 | {
|
---|
108 | CR_SERVER_RPW_CTL_TYPE_UNDEFINED = 0,
|
---|
109 | CR_SERVER_RPW_CTL_TYPE_WAIT_COMPLETE,
|
---|
110 | CR_SERVER_RPW_CTL_TYPE_TERM
|
---|
111 | } CR_SERVER_RPW_CTL_TYPE;
|
---|
112 |
|
---|
113 | struct CR_SERVER_RPW_ENTRY;
|
---|
114 |
|
---|
115 | typedef struct CR_SERVER_RPW_CTL {
|
---|
116 | CR_SERVER_RPW_CTL_TYPE enmType;
|
---|
117 | int rc;
|
---|
118 | RTSEMEVENT hCompleteEvent;
|
---|
119 | /* valid for *_WAIT_COMPLETE and *_CANCEL */
|
---|
120 | struct CR_SERVER_RPW_ENTRY *pEntry;
|
---|
121 | } CR_SERVER_RPW_CTL;
|
---|
122 |
|
---|
123 |
|
---|
124 | struct CR_SERVER_RPW_ENTRY;
|
---|
125 |
|
---|
126 | typedef DECLCALLBACKPTR(void, PFNCR_SERVER_RPW_DATA) (const struct CR_SERVER_RPW_ENTRY* pEntry, void *pvEntryTexData);
|
---|
127 |
|
---|
128 | typedef DECLCALLBACKPTR(void, PFNCRSERVERNOTIFYEVENT) (int32_t screenId, uint32_t uEvent, void*pvData);
|
---|
129 |
|
---|
130 | typedef struct CR_SERVER_RPW_ENTRY
|
---|
131 | {
|
---|
132 | RTRECTSIZE Size;
|
---|
133 | /* We have to use 4 textures here.
|
---|
134 | *
|
---|
135 | * 1. iDrawTex - the texture clients can draw to and then submit it for contents acquisition via crServerRpwEntrySubmit
|
---|
136 | * 2. iSubmittedTex - the texture submitted to the worker for processing and, whose processing has not start yet,
|
---|
137 | * i.e. it is being in the queue and can be safely removed/replaced [from] there
|
---|
138 | * 3. iWorkerTex - the texture being prepared & passed by the worker to the GPU (stage 1 of a worker contents acquisition process)
|
---|
139 | * 4. iGpuTex - the texture passed/processed to/by the GPU, whose data is then acquired by the server (stage 2 of a worker contents acquisition process)
|
---|
140 | *
|
---|
141 | * - There can be valid distinct iGpuTex, iWorkerTex, iSubmittedTex and iDrawTex present simultaneously.
|
---|
142 | * - Either or both of iSubmittedTex and iFreeTex are always valid
|
---|
143 | *
|
---|
144 | * Detail:
|
---|
145 | *
|
---|
146 | * - iSubmittedTex and iFreeTex modifications are performed under CR_SERVER_RPW::CritSect lock.
|
---|
147 | *
|
---|
148 | * - iDrawTex can only be changed by client side (i.e. the crServerRpwEntrySubmit caller), this is why client thread can access it w/o a lock
|
---|
149 | * - iSubmittedTex and iFreeTex can be modified by both client and worker, so lock is always required
|
---|
150 | *
|
---|
151 | * - iDrawTex can be accessed by client code only
|
---|
152 | * - iWorkerTex and iGpuTex can be accessed by worker code only
|
---|
153 | * - iSubmittedTex and iFreeTex can be accessed under CR_SERVER_RPW::CritSect lock only
|
---|
154 | * - either or both of iSubmittedTex and iFreeTex are always valid (see below for more explanation),
|
---|
155 | * this is why client can easily determine the new iDrawTex value on Submit, i.e. :
|
---|
156 | *
|
---|
157 | * (if initial iSubmittedTex was valid)
|
---|
158 | * ---------------
|
---|
159 | * | ^
|
---|
160 | * > |
|
---|
161 | * Submit-> iDrawTex -> iSubmittedTex
|
---|
162 | * ^
|
---|
163 | * | (if initial iSubmittedTex was NOT valid)
|
---|
164 | * iFreeTex
|
---|
165 | *
|
---|
166 | * - The worker can invalidate the iSubmittedTex (i.e. do iSubmittedTex -> iWorkerTex) only after it is done
|
---|
167 | * with the last iWorkerTex -> iGpuTex transformation freeing the previously used iGpuTex to iFreeTex.
|
---|
168 | *
|
---|
169 | * - A simplified worker iXxxTex transformation logic is:
|
---|
170 | * 1. iFreeTex is initially valid
|
---|
171 | * 2. iSubmittedTex -> iWorkerTex;
|
---|
172 | * 3. submit iWorkerTex acquire request to the GPU
|
---|
173 | * 4. complete current iGpuTex
|
---|
174 | * 5. iGpuTex -> iFreeTex
|
---|
175 | * 6. iWorkerTex -> iGpuTex
|
---|
176 | * 7. goto 1
|
---|
177 | *
|
---|
178 | * */
|
---|
179 | int8_t iTexDraw;
|
---|
180 | int8_t iTexSubmitted;
|
---|
181 | int8_t iTexWorker;
|
---|
182 | int8_t iTexGpu;
|
---|
183 | int8_t iCurPBO;
|
---|
184 | GLuint aidWorkerTexs[4];
|
---|
185 | GLuint aidPBOs[2];
|
---|
186 | RTLISTNODE WorkEntry;
|
---|
187 | RTLISTNODE WorkerWorkEntry;
|
---|
188 | RTLISTNODE GpuSubmittedEntry;
|
---|
189 | PFNCR_SERVER_RPW_DATA pfnData;
|
---|
190 | } CR_SERVER_RPW_ENTRY;
|
---|
191 |
|
---|
192 | typedef struct CR_SERVER_RPW {
|
---|
193 | RTLISTNODE WorkList;
|
---|
194 | RTCRITSECT CritSect;
|
---|
195 | RTSEMEVENT hSubmitEvent;
|
---|
196 | /* only one outstanding command is supported,
|
---|
197 | * and ctl requests must be cynchronized, hold it right here */
|
---|
198 | CR_SERVER_RPW_CTL Ctl;
|
---|
199 | int ctxId;
|
---|
200 | GLint ctxVisBits;
|
---|
201 | RTTHREAD hThread;
|
---|
202 | } CR_SERVER_RPW;
|
---|
203 | /* */
|
---|
204 |
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * Mural info
|
---|
208 | */
|
---|
209 | typedef struct {
|
---|
210 | GLuint width, height;
|
---|
211 | GLint gX, gY; /*guest coordinates*/
|
---|
212 | GLint hX, hY; /*host coordinates, screenID related*/
|
---|
213 |
|
---|
214 | int spuWindow; /*the SPU's corresponding window ID */
|
---|
215 |
|
---|
216 | int screenId;
|
---|
217 |
|
---|
218 | GLboolean bVisible; /*guest window is visible*/
|
---|
219 | GLubyte u8Unused; /*redirect to FBO instead of real host window*/
|
---|
220 | GLboolean bFbDraw; /*GL_FRONT buffer is drawn to directly*/
|
---|
221 | GLboolean fDataPresented;
|
---|
222 |
|
---|
223 | GLint cVisibleRects; /*count of visible rects*/
|
---|
224 | GLint *pVisibleRects; /*visible rects left, top, right, bottom*/
|
---|
225 | GLboolean bReceivedRects; /*indicates if guest did any updates for visible regions*/
|
---|
226 |
|
---|
227 | GLuint cBuffers;
|
---|
228 | GLuint iBbBuffer;
|
---|
229 | GLuint aidFBOs[2];
|
---|
230 | GLuint aidColorTexs[2];
|
---|
231 |
|
---|
232 | void *pvOutputRedirectInstance;
|
---|
233 |
|
---|
234 | CRCreateInfo_t CreateInfo;
|
---|
235 |
|
---|
236 | /* to avoid saved state breakage we need to keep RT_OFFSETOF(CRMuralInfo, CreateInfo) intact
|
---|
237 | * this is why we place some FBO stuff to the tail
|
---|
238 | * @todo: once we need to increment a saved state version, we could refactor this structure */
|
---|
239 | GLint iCurDrawBuffer;
|
---|
240 | GLint iCurReadBuffer;
|
---|
241 |
|
---|
242 | GLuint idDepthStencilRB;
|
---|
243 | GLuint fboWidth, fboHeight;
|
---|
244 | GLuint idPBO;
|
---|
245 |
|
---|
246 | GLuint cDisabled;
|
---|
247 |
|
---|
248 | GLuint fPresentMode; /*redirect to FBO instead of real host window*/
|
---|
249 |
|
---|
250 | GLboolean fHasParentWindow;
|
---|
251 |
|
---|
252 | GLboolean fRootVrOn;
|
---|
253 | GLboolean fForcePresentState;
|
---|
254 |
|
---|
255 | VBOXVR_SCR_COMPOSITOR_ENTRY CEntry;
|
---|
256 | VBOXVR_SCR_COMPOSITOR Compositor;
|
---|
257 |
|
---|
258 | /* if root Visible regions are set, these two contain actual regions being passed to render spu */
|
---|
259 | VBOXVR_SCR_COMPOSITOR_ENTRY RootVrCEntry;
|
---|
260 | VBOXVR_SCR_COMPOSITOR RootVrCompositor;
|
---|
261 |
|
---|
262 | CR_SERVER_RPW_ENTRY RpwEntry;
|
---|
263 |
|
---|
264 | /* bitfield representing contexts the mural has been ever current with
|
---|
265 | * we just reuse CR_STATE_SHAREDOBJ_USAGE_XXX API here for simplicity */
|
---|
266 | CRbitvalue ctxUsage[CR_MAX_BITARRAY];
|
---|
267 | } CRMuralInfo;
|
---|
268 |
|
---|
269 | typedef struct {
|
---|
270 | CRContext *pContext;
|
---|
271 | int SpuContext;
|
---|
272 | CRCreateInfo_t CreateInfo;
|
---|
273 | CRMuralInfo * currentMural;
|
---|
274 | } CRContextInfo;
|
---|
275 |
|
---|
276 | /**
|
---|
277 | * A client is basically an upstream Cr Node (connected via mothership)
|
---|
278 | */
|
---|
279 | typedef struct _crclient {
|
---|
280 | int spu_id; /**< id of the last SPU in the client's SPU chain */
|
---|
281 | CRConnection *conn; /**< network connection from the client */
|
---|
282 | int number; /**< a unique number for each client */
|
---|
283 | uint64_t pid; /*guest pid*/
|
---|
284 | GLint currentContextNumber;
|
---|
285 | CRContextInfo *currentCtxInfo;
|
---|
286 | GLint currentWindow;
|
---|
287 | CRMuralInfo *currentMural;
|
---|
288 | GLint windowList[CR_MAX_WINDOWS];
|
---|
289 | GLint contextList[CR_MAX_CONTEXTS];
|
---|
290 | #ifdef VBOXCR_LOGFPS
|
---|
291 | uint64_t timeUsed;
|
---|
292 | #endif
|
---|
293 | } CRClient;
|
---|
294 |
|
---|
295 | typedef struct _crclientnode {
|
---|
296 | CRClient *pClient;
|
---|
297 | struct _crclientnode *prev, *next;
|
---|
298 | } CRClientNode;
|
---|
299 |
|
---|
300 | typedef struct CRPoly_t {
|
---|
301 | int npoints;
|
---|
302 | double *points;
|
---|
303 | struct CRPoly_t *next;
|
---|
304 | } CRPoly;
|
---|
305 |
|
---|
306 | /**
|
---|
307 | * There's one of these run queue entries per client
|
---|
308 | * The run queue is a circular, doubly-linked list of these objects.
|
---|
309 | */
|
---|
310 | typedef struct RunQueue_t {
|
---|
311 | CRClient *client;
|
---|
312 | int blocked;
|
---|
313 | struct RunQueue_t *next;
|
---|
314 | struct RunQueue_t *prev;
|
---|
315 | } RunQueue;
|
---|
316 |
|
---|
317 | typedef struct {
|
---|
318 | GLint freeWindowID;
|
---|
319 | GLint freeContextID;
|
---|
320 | GLint freeClientID;
|
---|
321 | } CRServerFreeIDsPool_t;
|
---|
322 |
|
---|
323 | typedef struct {
|
---|
324 | int32_t x, y;
|
---|
325 | uint32_t w, h;
|
---|
326 | uint64_t winID;
|
---|
327 | } CRScreenInfo;
|
---|
328 |
|
---|
329 | typedef struct {
|
---|
330 | int32_t x, y;
|
---|
331 | uint32_t w, h;
|
---|
332 | } CRScreenViewportInfo;
|
---|
333 |
|
---|
334 |
|
---|
335 | /* DISPLAY */
|
---|
336 |
|
---|
337 | typedef struct CR_DISPLAY_ENTRY
|
---|
338 | {
|
---|
339 | VBOXVR_SCR_COMPOSITOR_ENTRY CEntry;
|
---|
340 | } CR_DISPLAY_ENTRY, *PCR_DISPLAY_ENTRY;
|
---|
341 |
|
---|
342 | /* @todo:
|
---|
343 | * 1. use compositor stored inside mural to use current MuralFBO and window-related API
|
---|
344 | * 2. CR_SERVER_REDIR_F_NONE and CR_SERVER_REDIR_F_FBO should be trated identically for presented window
|
---|
345 | * since we just need to blit the given textures to it if we are NOT in CR_SERVER_REDIR_F_FBO_RAM mode */
|
---|
346 | typedef struct CR_DISPLAY
|
---|
347 | {
|
---|
348 | VBOXVR_SCR_COMPOSITOR Compositor;
|
---|
349 | CRMuralInfo Mural;
|
---|
350 | } CR_DISPLAY, *PCR_DISPLAY;
|
---|
351 |
|
---|
352 | int CrDpInit(PCR_DISPLAY pDisplay);
|
---|
353 | void CrDpTerm(PCR_DISPLAY pDisplay);
|
---|
354 | void CrDpResize(PCR_DISPLAY pDisplay, uint32_t width, uint32_t height,
|
---|
355 | uint32_t stretchedWidth, uint32_t stretchedHeight);
|
---|
356 | void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, const VBOXVR_TEXTURE *pTextureData);
|
---|
357 | void CrDpEntryCleanup(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry);
|
---|
358 | int CrDpEntryRegionsSet(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions);
|
---|
359 | int CrDpEntryRegionsAdd(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions);
|
---|
360 | int CrDpPresentEntry(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry);
|
---|
361 | DECLINLINE(bool) CrDpEntryIsUsed(PCR_DISPLAY_ENTRY pEntry)
|
---|
362 | {
|
---|
363 | return CrVrScrCompositorEntryIsInList(&pEntry->CEntry);
|
---|
364 | }
|
---|
365 |
|
---|
366 | DECLINLINE(CRMuralInfo*) CrDpGetMural(PCR_DISPLAY pDisplay)
|
---|
367 | {
|
---|
368 | return &pDisplay->Mural;
|
---|
369 | }
|
---|
370 |
|
---|
371 | typedef struct CR_DISPLAY_ENTRY_MAP
|
---|
372 | {
|
---|
373 | CRHashTable * pTextureMap;
|
---|
374 | } CR_DISPLAY_ENTRY_MAP, *PCR_DISPLAY_ENTRY_MAP;
|
---|
375 |
|
---|
376 | int CrDemInit(PCR_DISPLAY_ENTRY_MAP pMap);
|
---|
377 | void CrDemTerm(PCR_DISPLAY_ENTRY_MAP pMap);
|
---|
378 | PCR_DISPLAY_ENTRY CrDemEntryGetCreate(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture, CRContextInfo *pCtxInfo);
|
---|
379 | void CrDemEntryDestroy(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture);
|
---|
380 |
|
---|
381 | /* */
|
---|
382 |
|
---|
383 | /* helpers */
|
---|
384 |
|
---|
385 | void CrHlpFreeTexImage(CRContext *pCurCtx, GLuint idPBO, void *pvData);
|
---|
386 | void* CrHlpGetTexImage(CRContext *pCurCtx, PVBOXVR_TEXTURE pTexture, GLuint idPBO, GLenum enmFormat);
|
---|
387 | void CrHlpPutTexImage(CRContext *pCurCtx, PVBOXVR_TEXTURE pTexture, GLenum enmFormat, void *pvData);
|
---|
388 |
|
---|
389 | /* */
|
---|
390 |
|
---|
391 | /* BFB (BlitFramebuffer Blitter) flags
|
---|
392 | * so far only CR_SERVER_BFB_ON_ALWAIS is supported and is alwais used if any flag is set */
|
---|
393 | #define CR_SERVER_BFB_DISABLED 0
|
---|
394 | #define CR_SERVER_BFB_ON_INVERTED_BLIT 1
|
---|
395 | #define CR_SERVER_BFB_ON_STRAIGHT_BLIT 2
|
---|
396 | #define CR_SERVER_BFB_ON_ALWAIS (CR_SERVER_BFB_ON_INVERTED_BLIT | CR_SERVER_BFB_ON_STRAIGHT_BLIT)
|
---|
397 |
|
---|
398 | typedef struct {
|
---|
399 | unsigned short tcpip_port;
|
---|
400 |
|
---|
401 | CRScreenInfo screen[CR_MAX_GUEST_MONITORS];
|
---|
402 | CRScreenViewportInfo screenVieport[CR_MAX_GUEST_MONITORS];
|
---|
403 | int screenCount;
|
---|
404 |
|
---|
405 | int numClients;
|
---|
406 | CRClient *clients[CR_MAX_CLIENTS]; /**< array [numClients] */
|
---|
407 | CRClient *curClient;
|
---|
408 | CRClientNode *pCleanupClient; /*list of clients with pending clean up*/
|
---|
409 | CRCurrentStatePointers current;
|
---|
410 |
|
---|
411 | GLboolean firstCallCreateContext;
|
---|
412 | GLboolean firstCallMakeCurrent;
|
---|
413 | GLboolean bIsInLoadingState; /* Indicates if we're in process of loading VM snapshot */
|
---|
414 | GLboolean bIsInSavingState; /* Indicates if we're in process of saving VM snapshot */
|
---|
415 | GLboolean bForceMakeCurrentOnClientSwitch;
|
---|
416 | CRContextInfo *currentCtxInfo;
|
---|
417 | GLint currentWindow;
|
---|
418 | GLint currentNativeWindow;
|
---|
419 | CRMuralInfo *currentMural;
|
---|
420 |
|
---|
421 | CRHashTable *muralTable; /**< hash table where all murals are stored */
|
---|
422 |
|
---|
423 | int client_spu_id;
|
---|
424 |
|
---|
425 | int mtu;
|
---|
426 | int buffer_size;
|
---|
427 | char protocol[1024];
|
---|
428 |
|
---|
429 | SPU *head_spu;
|
---|
430 | SPUDispatchTable dispatch;
|
---|
431 |
|
---|
432 | CRNetworkPointer return_ptr;
|
---|
433 | CRNetworkPointer writeback_ptr;
|
---|
434 |
|
---|
435 | CRLimitsState limits; /**< GL limits for any contexts we create */
|
---|
436 |
|
---|
437 | CRContextInfo MainContextInfo;
|
---|
438 |
|
---|
439 | CRHashTable *contextTable; /**< hash table for rendering contexts */
|
---|
440 |
|
---|
441 | CRHashTable *programTable; /**< for vertex programs */
|
---|
442 | GLuint currentProgram;
|
---|
443 |
|
---|
444 | /* visBits -> dummy mural association */
|
---|
445 | CRHashTable *dummyMuralTable;
|
---|
446 |
|
---|
447 | GLboolean fRootVrOn;
|
---|
448 | VBOXVR_LIST RootVr;
|
---|
449 | /* we need to translate Root Vr to each window coords, this one cpecifies the current translation point
|
---|
450 | * note that since window attributes modifications is performed in HGCM thread only and thus is serialized,
|
---|
451 | * we deal with the global RootVr data directly */
|
---|
452 | RTPOINT RootVrCurPoint;
|
---|
453 |
|
---|
454 | /* blitter so far used for working around host drivers BlitFramebuffer bugs
|
---|
455 | * by implementing */
|
---|
456 | uint32_t fBlitterMode;
|
---|
457 | CR_BLITTER Blitter;
|
---|
458 |
|
---|
459 | CR_SERVER_RPW RpwWorker;
|
---|
460 |
|
---|
461 | /** configuration options */
|
---|
462 | /*@{*/
|
---|
463 | int useL2;
|
---|
464 | int ignore_papi;
|
---|
465 | unsigned int maxBarrierCount;
|
---|
466 | unsigned int clearCount;
|
---|
467 | int optimizeBucket;
|
---|
468 | int only_swap_once;
|
---|
469 | int debug_barriers;
|
---|
470 | int sharedDisplayLists;
|
---|
471 | int sharedTextureObjects;
|
---|
472 | int sharedPrograms;
|
---|
473 | int sharedWindows;
|
---|
474 | int uniqueWindows;
|
---|
475 | int localTileSpec;
|
---|
476 | int useDMX;
|
---|
477 | int overlapBlending;
|
---|
478 | int vpProjectionMatrixParameter;
|
---|
479 | const char *vpProjectionMatrixVariable;
|
---|
480 | int stereoView;
|
---|
481 | int vncMode; /* cmd line option */
|
---|
482 | /*@}*/
|
---|
483 | /** view_matrix config */
|
---|
484 | /*@{*/
|
---|
485 | GLboolean viewOverride;
|
---|
486 | CRmatrix viewMatrix[2]; /**< left and right eye */
|
---|
487 | /*@}*/
|
---|
488 | /** projection_matrix config */
|
---|
489 | /*@{*/
|
---|
490 | GLboolean projectionOverride;
|
---|
491 | CRmatrix projectionMatrix[2]; /**< left and right eye */
|
---|
492 | int currentEye;
|
---|
493 | /*@}*/
|
---|
494 |
|
---|
495 | /** for warped tiles */
|
---|
496 | /*@{*/
|
---|
497 | GLfloat alignment_matrix[16], unnormalized_alignment_matrix[16];
|
---|
498 | /*@}*/
|
---|
499 |
|
---|
500 | /** tile overlap/blending info - this should probably be per-mural */
|
---|
501 | /*@{*/
|
---|
502 | CRPoly **overlap_geom;
|
---|
503 | CRPoly *overlap_knockout;
|
---|
504 | float *overlap_intens;
|
---|
505 | int num_overlap_intens;
|
---|
506 | int num_overlap_levels;
|
---|
507 | /*@}*/
|
---|
508 |
|
---|
509 | CRHashTable *barriers, *semaphores;
|
---|
510 |
|
---|
511 | RunQueue *run_queue;
|
---|
512 |
|
---|
513 | GLuint currentSerialNo;
|
---|
514 |
|
---|
515 | PFNCRSERVERPRESENTFBO pfnPresentFBO;
|
---|
516 | GLuint fPresentMode; /*Force server to render 3d data offscreen
|
---|
517 | *using callback above to update vbox framebuffers*/
|
---|
518 | GLuint fPresentModeDefault; /*can be set with CR_SERVER_DEFAULT_RENDER_TYPE*/
|
---|
519 | GLuint fVramPresentModeDefault;
|
---|
520 | GLboolean bUsePBOForReadback; /*Use PBO's for data readback*/
|
---|
521 |
|
---|
522 | GLboolean bUseOutputRedirect; /* Whether the output redirect was set. */
|
---|
523 | CROutputRedirect outputRedirect;
|
---|
524 |
|
---|
525 | GLboolean bUseMultipleContexts;
|
---|
526 |
|
---|
527 | GLboolean bWindowsInitiallyHidden;
|
---|
528 |
|
---|
529 | /* OR-ed CR_VBOX_CAP_XXX cap values
|
---|
530 | * describing VBox Chromium functionality caps visible to guest
|
---|
531 | * Currently can have only CR_VBOX_CAP_TEX_PRESENT cap to notify
|
---|
532 | * that the TexPresent mechanism is available and enabled */
|
---|
533 | uint32_t u32Caps;
|
---|
534 |
|
---|
535 | uint32_t NotifyEventMap[(CR_MAX_GUEST_MONITORS + 31)/32];
|
---|
536 | uint32_t cDisableEvent;
|
---|
537 | PFNCRSERVERNOTIFYEVENT pfnNotifyEventCB;
|
---|
538 |
|
---|
539 | SPUDispatchTable TmpCtxDispatch;
|
---|
540 |
|
---|
541 | #ifdef VBOX_WITH_CRSERVER_DUMPER
|
---|
542 | CR_RECORDER Recorder;
|
---|
543 | CR_BLITTER RecorderBlitter;
|
---|
544 | CR_DBGPRINT_DUMPER DbgPrintDumper;
|
---|
545 | CR_HTML_DUMPER HtmlDumper;
|
---|
546 | CR_DUMPER *pDumper;
|
---|
547 | #endif
|
---|
548 |
|
---|
549 | int RcToGuest;
|
---|
550 | int RcToGuestOnce;
|
---|
551 |
|
---|
552 | /* @todo: should we use just one blitter?
|
---|
553 | * we use two currently because the drawable attribs can differ*/
|
---|
554 | CR_DISPLAY_ENTRY_MAP PresentTexturepMap;
|
---|
555 | uint32_t DisplaysInitMap[(CR_MAX_GUEST_MONITORS + 31)/32];
|
---|
556 | CR_DISPLAY aDispplays[CR_MAX_GUEST_MONITORS];
|
---|
557 | } CRServer;
|
---|
558 |
|
---|
559 |
|
---|
560 | extern DECLEXPORT(void) crServerInit( int argc, char *argv[] );
|
---|
561 | extern DECLEXPORT(int) CRServerMain( int argc, char *argv[] );
|
---|
562 | extern DECLEXPORT(void) crServerServiceClients(void);
|
---|
563 | extern DECLEXPORT(void) crServerAddNewClient(void);
|
---|
564 | extern DECLEXPORT(SPU*) crServerHeadSPU(void);
|
---|
565 | extern DECLEXPORT(void) crServerSetPort(int port);
|
---|
566 |
|
---|
567 | extern DECLEXPORT(GLboolean) crVBoxServerInit(void);
|
---|
568 | extern DECLEXPORT(void) crVBoxServerTearDown(void);
|
---|
569 | extern DECLEXPORT(int32_t) crVBoxServerAddClient(uint32_t u32ClientID);
|
---|
570 | extern DECLEXPORT(void) crVBoxServerRemoveClient(uint32_t u32ClientID);
|
---|
571 | extern DECLEXPORT(int32_t) crVBoxServerClientWrite(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t cbBuffer);
|
---|
572 | extern DECLEXPORT(int32_t) crVBoxServerClientRead(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t *pcbBuffer);
|
---|
573 | extern DECLEXPORT(int32_t) crVBoxServerClientSetVersion(uint32_t u32ClientID, uint32_t vMajor, uint32_t vMinor);
|
---|
574 | extern DECLEXPORT(int32_t) crVBoxServerClientGetCaps(uint32_t u32ClientID, uint32_t *pu32Caps);
|
---|
575 | extern DECLEXPORT(int32_t) crVBoxServerClientSetPID(uint32_t u32ClientID, uint64_t pid);
|
---|
576 |
|
---|
577 | extern DECLEXPORT(int32_t) crVBoxServerSaveState(PSSMHANDLE pSSM);
|
---|
578 | extern DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version);
|
---|
579 |
|
---|
580 | extern DECLEXPORT(int32_t) crVBoxServerSetScreenCount(int sCount);
|
---|
581 | extern DECLEXPORT(int32_t) crVBoxServerUnmapScreen(int sIndex);
|
---|
582 | extern DECLEXPORT(int32_t) crVBoxServerMapScreen(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h, uint64_t winID);
|
---|
583 | extern DECLEXPORT(void) crServerVBoxCompositionSetEnableStateGlobal(GLboolean fEnable);
|
---|
584 | extern DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, const RTRECT *pRects);
|
---|
585 |
|
---|
586 | extern DECLEXPORT(void) crVBoxServerSetPresentFBOCB(PFNCRSERVERPRESENTFBO pfnPresentFBO);
|
---|
587 |
|
---|
588 | extern DECLEXPORT(int32_t) crVBoxServerSetOffscreenRendering(GLboolean value);
|
---|
589 |
|
---|
590 | extern DECLEXPORT(int32_t) crVBoxServerOutputRedirectSet(const CROutputRedirect *pCallbacks);
|
---|
591 |
|
---|
592 | extern DECLEXPORT(int32_t) crVBoxServerSetScreenViewport(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h);
|
---|
593 |
|
---|
594 | extern DECLEXPORT(void) crServerVBoxSetNotifyEventCB(PFNCRSERVERNOTIFYEVENT pfnCb);
|
---|
595 |
|
---|
596 | #ifdef VBOX_WITH_CRHGSMI
|
---|
597 | /* We moved all CrHgsmi command processing to crserverlib to keep the logic of dealing with CrHgsmi commands in one place.
|
---|
598 | *
|
---|
599 | * For now we need the notion of CrHgdmi commands in the crserver_lib to be able to complete it asynchronously once it is really processed.
|
---|
600 | * This help avoiding the "blocked-client" issues. The client is blocked if another client is doing begin-end stuff.
|
---|
601 | * For now we eliminated polling that could occur on block, which caused a higher-priority thread (in guest) polling for the blocked command complition
|
---|
602 | * to block the lower-priority thread trying to complete the blocking command.
|
---|
603 | * And removed extra memcpy done on blocked command arrival.
|
---|
604 | *
|
---|
605 | * In the future we will extend CrHgsmi functionality to maintain texture data directly in CrHgsmi allocation to avoid extra memcpy-ing with PBO,
|
---|
606 | * implement command completion and stuff necessary for GPU scheduling to work properly for WDDM Windows guests, etc.
|
---|
607 | *
|
---|
608 | * NOTE: it is ALWAYS responsibility of the crVBoxServerCrHgsmiCmd to complete the command!
|
---|
609 | * */
|
---|
610 | extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd);
|
---|
611 | extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCtl(struct VBOXVDMACMD_CHROMIUM_CTL *pCtl, uint32_t cbCtl);
|
---|
612 | #endif
|
---|
613 |
|
---|
614 | #ifdef __cplusplus
|
---|
615 | }
|
---|
616 | #endif
|
---|
617 |
|
---|
618 | #endif
|
---|
619 |
|
---|