VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h@ 78190

Last change on this file since 78190 was 78190, checked in by vboxsync, 6 years ago

Merge first stage of the Chromium cleanup from the branch:

  • r129818 (Remove VBOX_WITH_CR_DISPLAY_LISTS and accompanying code as it was disabled since r108676 and was never brought back (see ​bugref:3456 and ​bugref:8485))
  • r129819 (HostServices/SharedOpenGL: Remove unused main entry point from upstream server process based implementation)
  • r129820 (HostServices/SharedOpenGL: Started eliminating all backends other than HGCM. They are not used and probably wouldn't work anymore anyway)
  • r129821 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crTimer* API as it is not used anywhere)
  • r129822 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill most from cr_process.h apart from two used methods)
  • r129823 (HostServices/SharedOpenGL,GuestHost/OpenGLAdditions/common/crOpenGL: Kill crList* API as it is unused)
  • r129824 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crHullInteriorBox API as it is unused)
  • r129825 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill crWarpPoint API as it is unused)
  • r129826 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill CrSa* API as it is unused and not even compiled in)
  • r129827 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Kill cr_bbox.h as it is unused)
  • r129828 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove a few crParseUrl() two uses)
  • r129829 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove last crParseURL() use)
  • r129830 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove crParseURL())
  • r129831 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove VBOX_WITH_COCOA_QT and related code when not set as it is the default for years now and we don't support anything else anymore)
  • r129832 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_logo.h)
  • r129833 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused crut_api.h and crut_clientapi.h)
  • r129834 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_dmx.h)
  • r129835 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused cr_perf.h)
  • r129836 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove cr_rand.h and friends as it is not actively used anywhere)
  • r129837 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of all the swapped versions in the packer SPU, we never change endianess from guest to host and don't need it)
  • r129838 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129839 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129840 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused pack_pica.c)
  • r129841 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove more swapper versions in the packer related code)
  • r129842 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_endianess.h and friends)
  • r129843 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused lowercase.py)
  • r129844 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_calllists.h and friends)
  • r129845 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of completely unused idpool.c, not even compiled in)
  • r129846 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused cr_debugopcodes.h and friends)
  • r129847 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the cr_mem.h API inline and get rid of the implementation in the util library)
  • r129848 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of SPUOptions and related code as it is of no use for us)
  • r129849 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of cr_environment.h and friends and convert usage to RTEnv* APIs)
  • r129850 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of unused renderspu_agl.c)
  • r129851 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Remove unused code in cr_htable.h)
  • r129853 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Introduce a state paremeter for the unpacker workers instead of reyling on global variables, work in progress)
  • r129854 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Let the caller of crUnpack set up the initial state. This allows to get rid of the global return_ptr and writeback_ptr as they get supplied in the unpacker state by the server)
  • r129855 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the cr_lastDispatch and cr_unpackDispatch as they are of no use now)
  • r129856 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Get rid of the global cr_unpackData and cr_unpackDataEnd symbols by indtroducing another hack to make it possible for certail server dispatch callbacks to access the data buffer)
  • r129857 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: build fix for release builds)
  • r129858 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Make the pointer to the unpacker state non const (is required for the access verification))
  • r129859 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: First iteration of the buffer size validation to prevent out of bound read access + added todos for places where additional checks are needed)
  • r129860 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129861 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129871 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129872 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Stop as soon as the unpacker encountered an error)
  • r129876 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129880 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Working on remaining verification todos)
  • r129882 (HostServices/SharedOpenGL,GuestHost/OpenGL,Additions/common/crOpenGL: Fixed some offsets in unpack_texture.c, 3DMark03 renders correctly again)
  • r130013 (HostServices/SharedOpenGL: Convert files to C++ so we can use C99 featuers on Windows with cl.exe)
  • r130014 (HostServices/SharedOpenGL,GuestHost/OpenGL: WIndows build fixes)
  • r130015 (HostServices/SharedOpenGL,GuestHost/OpenGL: More Windows build fixes)
  • r130036 (Config.kmk: Fix linker error on Windows by temporarily disabling the use of VBoxGuestR3DllMinW2K)
  • r130094 (src/VBox/GuestHost/OpenGL: Revert inlining the allocation/free functions in R3 completely as it doesn't work on Windows if memory is allocated and freed across different DLLs which don't share a common CRT, causes crashes in RtlValidtaeHeap())
  • r130095 (src/VBox/GuestHost/OpenGL,src/VBox/Additions/common/crOpenGL/pack: Don't use floating point specifiers in packspu_GetString() to avoid R6002 errors (couldn't fully understand why they occur suddenly after the rework but this gets rid of it))
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 20.6 KB
Line 
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 "cr_htable.h"
18#include "cr_unpack.h"
19#include "spu_dispatch_table.h"
20#include "cr_dump.h"
21
22#include "state/cr_currentpointers.h"
23
24#include <iprt/types.h>
25#include <iprt/err.h>
26#include <iprt/string.h>
27#include <iprt/list.h>
28#include <iprt/thread.h>
29#include <iprt/critsect.h>
30#include <iprt/semaphore.h>
31#include <iprt/memcache.h>
32
33#include <VBox/vmm/ssm.h>
34
35#include <VBoxVideo.h>
36#include <VBoxVideoVBE.h>
37#include <VBoxVideo3D.h>
38#include <VBoxVideoHost3D.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#define CR_MAX_WINDOWS 100
45#define CR_MAX_CLIENTS 64
46
47/** @todo must match MaxGuestMonitors from SchemaDefs.h*/
48#define CR_MAX_GUEST_MONITORS VBOX_VIDEO_MAX_SCREENS
49
50typedef DECLCALLBACKPTR(void, PFNCRSERVERPRESENTFBO) (void *data, int32_t screenId, int32_t x, int32_t y, uint32_t w, uint32_t h);
51
52/* Callbacks for output of the rendered frames.
53 *
54 * This allows to pass rendered frames to an external component rather than draw them on screen.
55 *
56 * An external component registers the redirection callbacks using crVBoxServerOutputRedirectSet.
57 *
58 * The list of formats supported by the caller is obtained using CRORContextProperty.
59 * The actual format choosed by the service is passed as a CRORBegin parameter.
60 */
61typedef struct {
62 const void *pvContext; /* Supplied by crVBoxServerOutputRedirectSet. */
63 DECLR3CALLBACKMEMBER(void, CRORBegin, (const void *pvContext, void **ppvInstance,
64 const char *pszFormat));
65 DECLR3CALLBACKMEMBER(void, CRORGeometry, (void *pvInstance,
66 int32_t x, int32_t y, uint32_t w, uint32_t h));
67 DECLR3CALLBACKMEMBER(void, CRORVisibleRegion, (void *pvInstance,
68 uint32_t cRects, const RTRECT *paRects));
69 DECLR3CALLBACKMEMBER(void, CRORFrame, (void *pvInstance,
70 void *pvData, uint32_t cbData));
71 DECLR3CALLBACKMEMBER(void, CROREnd, (void *pvInstance));
72 DECLR3CALLBACKMEMBER(int, CRORContextProperty, (const void *pvContext, uint32_t index,
73 void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut));
74} CROutputRedirect;
75
76typedef struct {
77 CRrecti imagewindow; /**< coordinates in mural space */
78 CRrectf bounds; /**< normalized coordinates in [-1,-1] x [1,1] */
79 CRrecti outputwindow; /**< coordinates in server's rendering window */
80 CRrecti clippedImagewindow; /**< imagewindow clipped to current viewport */
81 CRmatrix baseProjection; /**< pre-multiplied onto projection matrix */
82 CRrecti scissorBox; /**< passed to back-end OpenGL */
83 CRrecti viewport; /**< passed to back-end OpenGL */
84 GLuint serialNo; /**< an optimization */
85} CRExtent;
86
87struct BucketingInfo;
88
89typedef struct {
90 char *pszDpyName;
91 GLint visualBits;
92 int32_t externalID;
93} CRCreateInfo_t;
94
95typedef struct {
96 char *pszDpyName;
97 int32_t externalID;
98 GLint requestedVisualBits;
99 GLint realVisualBits;
100} CRCreateInfoEx_t;
101
102/* VRAM->RAM worker thread */
103
104typedef enum
105{
106 CR_SERVER_RPW_STATE_UNINITIALIZED = 0,
107 CR_SERVER_RPW_STATE_INITIALIZING,
108 CR_SERVER_RPW_STATE_INITIALIZED,
109 CR_SERVER_RPW_STATE_UNINITIALIZING,
110} CR_SERVER_RPW_STATE;
111
112/* worker control command */
113typedef enum
114{
115 CR_SERVER_RPW_CTL_TYPE_UNDEFINED = 0,
116 CR_SERVER_RPW_CTL_TYPE_WAIT_COMPLETE,
117 CR_SERVER_RPW_CTL_TYPE_TERM
118} CR_SERVER_RPW_CTL_TYPE;
119
120struct CR_SERVER_RPW_ENTRY;
121
122typedef struct CR_SERVER_RPW_CTL {
123 CR_SERVER_RPW_CTL_TYPE enmType;
124 int rc;
125 RTSEMEVENT hCompleteEvent;
126 /* valid for *_WAIT_COMPLETE and *_CANCEL */
127 struct CR_SERVER_RPW_ENTRY *pEntry;
128} CR_SERVER_RPW_CTL;
129
130
131struct CR_SERVER_RPW_ENTRY;
132
133typedef DECLCALLBACKPTR(void, PFNCR_SERVER_RPW_DATA) (const struct CR_SERVER_RPW_ENTRY* pEntry, void *pvEntryTexData);
134
135typedef DECLCALLBACKPTR(void, PFNCRSERVERNOTIFYEVENT) (int32_t screenId, uint32_t uEvent, void* pvData, uint32_t cbData);
136
137typedef struct CR_SERVER_RPW_ENTRY
138{
139 RTRECTSIZE Size;
140 /* We have to use 4 textures here.
141 *
142 * 1. iDrawTex - the texture clients can draw to and then submit it for contents acquisition via crServerRpwEntrySubmit
143 * 2. iSubmittedTex - the texture submitted to the worker for processing and, whose processing has not start yet,
144 * i.e. it is being in the queue and can be safely removed/replaced [from] there
145 * 3. iWorkerTex - the texture being prepared & passed by the worker to the GPU (stage 1 of a worker contents acquisition process)
146 * 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)
147 *
148 * - There can be valid distinct iGpuTex, iWorkerTex, iSubmittedTex and iDrawTex present simultaneously.
149 * - Either or both of iSubmittedTex and iFreeTex are always valid
150 *
151 * Detail:
152 *
153 * - iSubmittedTex and iFreeTex modifications are performed under CR_SERVER_RPW::CritSect lock.
154 *
155 * - 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
156 * - iSubmittedTex and iFreeTex can be modified by both client and worker, so lock is always required
157 *
158 * - iDrawTex can be accessed by client code only
159 * - iWorkerTex and iGpuTex can be accessed by worker code only
160 * - iSubmittedTex and iFreeTex can be accessed under CR_SERVER_RPW::CritSect lock only
161 * - either or both of iSubmittedTex and iFreeTex are always valid (see below for more explanation),
162 * this is why client can easily determine the new iDrawTex value on Submit, i.e. :
163 *
164 * (if initial iSubmittedTex was valid)
165 * ---------------
166 * | ^
167 * > |
168 * Submit-> iDrawTex -> iSubmittedTex
169 * ^
170 * | (if initial iSubmittedTex was NOT valid)
171 * iFreeTex
172 *
173 * - The worker can invalidate the iSubmittedTex (i.e. do iSubmittedTex -> iWorkerTex) only after it is done
174 * with the last iWorkerTex -> iGpuTex transformation freeing the previously used iGpuTex to iFreeTex.
175 *
176 * - A simplified worker iXxxTex transformation logic is:
177 * 1. iFreeTex is initially valid
178 * 2. iSubmittedTex -> iWorkerTex;
179 * 3. submit iWorkerTex acquire request to the GPU
180 * 4. complete current iGpuTex
181 * 5. iGpuTex -> iFreeTex
182 * 6. iWorkerTex -> iGpuTex
183 * 7. goto 1
184 *
185 * */
186 int8_t iTexDraw;
187 int8_t iTexSubmitted;
188 int8_t iTexWorker;
189 int8_t iTexGpu;
190 int8_t iCurPBO;
191 GLuint aidWorkerTexs[4];
192 GLuint aidPBOs[2];
193 RTLISTNODE WorkEntry;
194 RTLISTNODE WorkerWorkEntry;
195 RTLISTNODE GpuSubmittedEntry;
196 PFNCR_SERVER_RPW_DATA pfnData;
197} CR_SERVER_RPW_ENTRY;
198
199typedef struct CR_SERVER_RPW {
200 RTLISTNODE WorkList;
201 RTCRITSECT CritSect;
202 RTSEMEVENT hSubmitEvent;
203 /* only one outstanding command is supported,
204 * and ctl requests must be cynchronized, hold it right here */
205 CR_SERVER_RPW_CTL Ctl;
206 int ctxId;
207 GLint ctxVisBits;
208 RTTHREAD hThread;
209} CR_SERVER_RPW;
210/* */
211
212/* FRAMEBUFFER */
213typedef struct CR_FRAMEBUFFER *HCR_FRAMEBUFFER;
214typedef struct CR_FRAMEBUFFER_ENTRY *HCR_FRAMEBUFFER_ENTRY;
215/* */
216
217typedef struct CR_FBDATA
218{
219 HCR_FRAMEBUFFER hFb;
220 HCR_FRAMEBUFFER_ENTRY hFbEntry;
221 CR_TEXDATA* apTexDatas[2];
222} CR_FBDATA;
223/**
224 * Mural info
225 */
226typedef struct {
227 GLuint width, height;
228 GLint gX, gY; /*guest coordinates*/
229 GLint hX, hY; /*host coordinates, screenID related*/
230
231 int spuWindow; /*the SPU's corresponding window ID */
232
233 int screenId;
234
235 GLboolean bVisible; /*guest window is visible*/
236 GLubyte u8Unused; /*redirect to FBO instead of real host window*/
237 GLboolean bFbDraw; /*GL_FRONT buffer is drawn to directly*/
238 GLboolean fIsDummyRefference;
239
240 GLint cVisibleRects; /*count of visible rects*/
241 GLint *pVisibleRects; /*visible rects left, top, right, bottom*/
242 GLboolean bReceivedRects; /*indicates if guest did any updates for visible regions*/
243
244 GLuint cBuffers;
245 GLuint iBbBuffer;
246 GLuint aidFBOs[2];
247 GLuint aidColorTexs[2];
248
249 void *pvReserved;
250
251 CRCreateInfoEx_t CreateInfo;
252
253 /* to avoid saved state breakage we need to keep RT_OFFSETOF(CRMuralInfo, CreateInfo) intact
254 * this is why we place some FBO stuff to the tail
255 * @todo: once we need to increment a saved state version, we could refactor this structure */
256 GLint iCurDrawBuffer;
257 GLint iCurReadBuffer;
258
259 GLuint idDepthStencilRB;
260 GLuint fboWidth, fboHeight;
261
262 GLboolean fHasParentWindow;
263
264 GLboolean fRedirected;
265 GLboolean fForcePresentState;
266 GLboolean fOrPresentOnReenable;
267
268 GLboolean fIsVisible;
269
270 CR_TEXDATA aTexs[2];
271 uint32_t cUsedFBDatas;
272 CR_FBDATA *apUsedFBDatas[CR_MAX_GUEST_MONITORS];
273 CR_FBDATA aFBDatas[CR_MAX_GUEST_MONITORS];
274
275 /* bitfield representing contexts the mural has been ever current with
276 * we just reuse CR_STATE_SHAREDOBJ_USAGE_XXX API here for simplicity */
277 CRbitvalue ctxUsage[CR_MAX_BITARRAY];
278} CRMuralInfo;
279
280typedef struct {
281 CRContext *pContext;
282 int SpuContext;
283 CRCreateInfoEx_t CreateInfo;
284 CRMuralInfo * currentMural;
285} CRContextInfo;
286
287/**
288 * A client is basically an upstream Cr Node (connected via mothership)
289 */
290typedef struct _crclient {
291 int spu_id; /**< id of the last SPU in the client's SPU chain */
292 CRConnection *conn; /**< network connection from the client */
293 int number; /**< a unique number for each client */
294 uint64_t pid; /*guest pid*/
295 GLint currentContextNumber;
296 CRContextInfo *currentCtxInfo;
297 GLint currentWindow;
298 CRMuralInfo *currentMural;
299 GLint windowList[CR_MAX_WINDOWS];
300 GLint contextList[CR_MAX_CONTEXTS];
301#ifdef VBOXCR_LOGFPS
302 uint64_t timeUsed;
303#endif
304} CRClient;
305
306typedef struct _crclientnode {
307 CRClient *pClient;
308 struct _crclientnode *prev, *next;
309} CRClientNode;
310
311typedef struct CRPoly_t {
312 int npoints;
313 double *points;
314 struct CRPoly_t *next;
315} CRPoly;
316
317/**
318 * There's one of these run queue entries per client
319 * The run queue is a circular, doubly-linked list of these objects.
320 */
321typedef struct RunQueue_t {
322 CRClient *client;
323 int blocked;
324 struct RunQueue_t *next;
325 struct RunQueue_t *prev;
326} RunQueue;
327
328typedef struct {
329 GLint freeWindowID;
330 GLint freeContextID;
331 GLint freeClientID;
332} CRServerFreeIDsPool_t;
333
334typedef struct {
335 int32_t x, y;
336 uint32_t w, h;
337 uint64_t winID;
338} CRScreenInfo;
339
340typedef struct {
341 RTRECT Rect;
342} CRScreenViewportInfo;
343
344/* BFB (BlitFramebuffer Blitter) flags
345 * so far only CR_SERVER_BFB_ON_ALWAIS is supported and is alwais used if any flag is set */
346#define CR_SERVER_BFB_DISABLED 0
347#define CR_SERVER_BFB_ON_INVERTED_BLIT 1
348#define CR_SERVER_BFB_ON_STRAIGHT_BLIT 2
349#define CR_SERVER_BFB_ON_ALWAIS (CR_SERVER_BFB_ON_INVERTED_BLIT | CR_SERVER_BFB_ON_STRAIGHT_BLIT)
350
351typedef struct {
352 unsigned short tcpip_port;
353
354 CRScreenInfo screen[CR_MAX_GUEST_MONITORS];
355 CRScreenViewportInfo screenVieport[CR_MAX_GUEST_MONITORS];
356 int screenCount;
357
358 GLboolean fCrCmdEnabled;
359
360 GLboolean fProcessingPendedCommands;
361
362 int numClients;
363 CRClient *clients[CR_MAX_CLIENTS]; /**< array [numClients] */
364 CRClient *curClient;
365 CRClientNode *pCleanupClient; /*list of clients with pending clean up*/
366 CRHTABLE clientTable;
367 CRCurrentStatePointers current;
368
369 GLboolean firstCallCreateContext;
370 GLboolean firstCallMakeCurrent;
371 GLboolean bIsInLoadingState; /* Indicates if we're in process of loading VM snapshot */
372 GLboolean bIsInSavingState; /* Indicates if we're in process of saving VM snapshot */
373 GLboolean bForceMakeCurrentOnClientSwitch;
374 CRContextInfo *currentCtxInfo;
375 GLint currentWindow;
376 GLint currentNativeWindow;
377 CRMuralInfo *currentMural;
378
379 CRHashTable *muralTable; /**< hash table where all murals are stored */
380
381 int client_spu_id;
382
383 int mtu;
384 int buffer_size;
385 char protocol[1024];
386
387 SPU *head_spu;
388 SPUDispatchTable dispatch;
389
390 CRNetworkPointer return_ptr;
391 CRNetworkPointer writeback_ptr;
392 /*
393 * The current active unpacker state, this hack is required for the server dispatch routines
394 * (see crServerDispatchReadPixels for example) as it needs to read data from the buffer
395 * but it is not possible to supply the state as a parameter unfortunately.
396 */
397 PCrUnpackerState pUnpackerState;
398
399 CRLimitsState limits; /**< GL limits for any contexts we create */
400
401 CRContextInfo MainContextInfo;
402
403 CRHashTable *contextTable; /**< hash table for rendering contexts */
404
405 CRHashTable *programTable; /**< for vertex programs */
406 GLuint currentProgram;
407
408 /* visBits -> dummy mural association */
409 CRHashTable *dummyMuralTable;
410
411 GLboolean fRootVrOn;
412 VBOXVR_LIST RootVr;
413 /* we need to translate Root Vr to each window coords, this one cpecifies the current translation point
414 * note that since window attributes modifications is performed in HGCM thread only and thus is serialized,
415 * we deal with the global RootVr data directly */
416 RTPOINT RootVrCurPoint;
417
418 /* blitter so far used for working around host drivers BlitFramebuffer bugs
419 * by implementing */
420 uint32_t fBlitterMode;
421 CR_BLITTER Blitter;
422
423 CR_SERVER_RPW RpwWorker;
424
425 VBOXCRCMDCTL_HGCMDISABLE_DATA DisableData;
426
427 RTSEMEVENT hCalloutCompletionEvent;
428 VBOXCRCMDCTL *pCurrentCalloutCtl;
429 VBOXCRCLIENT_INFO ClientInfo;
430
431 /** configuration options */
432 /*@{*/
433 int useL2;
434 int ignore_papi;
435 unsigned int maxBarrierCount;
436 unsigned int clearCount;
437 int optimizeBucket;
438 int only_swap_once;
439 int debug_barriers;
440 int sharedDisplayLists;
441 int sharedTextureObjects;
442 int sharedPrograms;
443 int sharedWindows;
444 int uniqueWindows;
445 int localTileSpec;
446 int useDMX;
447 int overlapBlending;
448 int vpProjectionMatrixParameter;
449 const char *vpProjectionMatrixVariable;
450 int stereoView;
451 int vncMode; /* cmd line option */
452 /*@}*/
453 /** view_matrix config */
454 /*@{*/
455 GLboolean viewOverride;
456 CRmatrix viewMatrix[2]; /**< left and right eye */
457 /*@}*/
458 /** projection_matrix config */
459 /*@{*/
460 GLboolean projectionOverride;
461 CRmatrix projectionMatrix[2]; /**< left and right eye */
462 int currentEye;
463 /*@}*/
464
465 /** for warped tiles */
466 /*@{*/
467 GLfloat alignment_matrix[16], unnormalized_alignment_matrix[16];
468 /*@}*/
469
470 /** tile overlap/blending info - this should probably be per-mural */
471 /*@{*/
472 CRPoly **overlap_geom;
473 CRPoly *overlap_knockout;
474 float *overlap_intens;
475 int num_overlap_intens;
476 int num_overlap_levels;
477 /*@}*/
478
479 CRHashTable *barriers, *semaphores;
480
481 RunQueue *run_queue;
482
483 GLuint currentSerialNo;
484
485 GLuint fVisualBitsDefault;
486 GLboolean bUsePBOForReadback; /*Use PBO's for data readback*/
487
488 CROutputRedirect outputRedirect;
489
490 GLboolean bUseMultipleContexts;
491
492 GLboolean bWindowsInitiallyHidden;
493
494 /* OR-ed CR_VBOX_CAP_XXX cap values
495 * describing VBox Chromium functionality caps visible to guest
496 * Currently can have only CR_VBOX_CAP_TEX_PRESENT cap to notify
497 * that the TexPresent mechanism is available and enabled */
498 uint32_t u32Caps;
499
500 PFNCRSERVERNOTIFYEVENT pfnNotifyEventCB;
501
502 SPUDispatchTable TmpCtxDispatch;
503
504 VBOXCRCMD_SVRENABLE_INFO CrCmdClientInfo;
505
506#ifdef VBOX_WITH_CRSERVER_DUMPER
507 CR_RECORDER Recorder;
508 CR_BLITTER RecorderBlitter;
509 CR_DBGPRINT_DUMPER DbgPrintDumper;
510 CR_HTML_DUMPER HtmlDumper;
511 CR_DUMPER *pDumper;
512#endif
513
514 int RcToGuest;
515 int RcToGuestOnce;
516} CRServer;
517
518
519extern DECLEXPORT(void) crServerInit( int argc, char *argv[] );
520extern DECLEXPORT(int) CRServerMain( int argc, char *argv[] );
521extern DECLEXPORT(void) crServerServiceClients(void);
522extern DECLEXPORT(void) crServerAddNewClient(void);
523extern DECLEXPORT(SPU*) crServerHeadSPU(void);
524extern DECLEXPORT(void) crServerSetPort(int port);
525
526extern DECLEXPORT(GLboolean) crVBoxServerInit(void);
527extern DECLEXPORT(void) crVBoxServerTearDown(void);
528extern DECLEXPORT(int32_t) crVBoxServerAddClient(uint32_t u32ClientID);
529extern DECLEXPORT(void) crVBoxServerRemoveClient(uint32_t u32ClientID);
530extern DECLEXPORT(int32_t) crVBoxServerClientWrite(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t cbBuffer);
531extern DECLEXPORT(int32_t) crVBoxServerClientRead(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t *pcbBuffer);
532extern DECLEXPORT(int32_t) crVBoxServerClientSetVersion(uint32_t u32ClientID, uint32_t vMajor, uint32_t vMinor);
533extern DECLEXPORT(int32_t) crVBoxServerClientGetCapsLegacy(uint32_t u32ClientID, uint32_t *pu32Caps);
534extern DECLEXPORT(int32_t) crVBoxServerClientGetCapsNew(uint32_t u32ClientID, CR_CAPS_INFO *pInfo);
535extern DECLEXPORT(int32_t) crVBoxServerClientSetPID(uint32_t u32ClientID, uint64_t pid);
536
537extern DECLEXPORT(int32_t) crVBoxServerSaveState(PSSMHANDLE pSSM);
538extern DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version);
539
540typedef struct
541{
542 CR_BLITTER_IMG Img;
543 uint32_t u32Screen;
544 uint32_t fDataAllocated;
545} CR_SCREENSHOT;
546
547extern DECLEXPORT(int) crServerVBoxWindowsShow(bool fShow);
548extern DECLEXPORT(int) crServerVBoxScreenshotGet(uint32_t u32Screen, uint32_t width, uint32_t height, uint32_t pitch, void *pvBuffer, CR_SCREENSHOT *pScreenshot);
549extern DECLEXPORT(void) crServerVBoxScreenshotRelease(CR_SCREENSHOT *pScreenshot);
550
551extern DECLEXPORT(void) crServerVBoxCompositionSetEnableStateGlobal(GLboolean fEnable);
552extern DECLEXPORT(int32_t) crVBoxServerSetScreenCount(int sCount);
553extern DECLEXPORT(int32_t) crVBoxServerUnmapScreen(int sIndex);
554extern DECLEXPORT(int32_t) crVBoxServerMapScreen(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h, uint64_t winID);
555extern DECLEXPORT(void) crServerVBoxCompositionSetEnableStateGlobal(GLboolean fEnable);
556struct VBVAINFOSCREEN;
557extern DECLEXPORT(int) crVBoxServerNotifyResize(const struct VBVAINFOSCREEN *pScreen, void *pvVRAM);
558extern DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, const RTRECT *pRects);
559
560extern DECLEXPORT(int32_t) crVBoxServerSetOffscreenRendering(GLboolean value);
561
562extern DECLEXPORT(int32_t) crVBoxServerOutputRedirectSet(const CROutputRedirect *pCallbacks);
563
564extern DECLEXPORT(int32_t) crVBoxServerSetScreenViewport(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h);
565
566extern DECLEXPORT(void) crServerVBoxSetNotifyEventCB(PFNCRSERVERNOTIFYEVENT pfnCb);
567
568extern DECLEXPORT(void) crVBoxServerCalloutEnable(VBOXCRCMDCTL *pCtl);
569extern DECLEXPORT(void) crVBoxServerCalloutDisable(void);
570extern DECLEXPORT(void) crServerSetUnscaledHiDPI(bool fEnable);
571
572#ifdef VBOX_WITH_CRHGSMI
573/* We moved all CrHgsmi command processing to crserverlib to keep the logic of dealing with CrHgsmi commands in one place.
574 *
575 * 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.
576 * This help avoiding the "blocked-client" issues. The client is blocked if another client is doing begin-end stuff.
577 * For now we eliminated polling that could occur on block, which caused a higher-priority thread (in guest) polling for the blocked command complition
578 * to block the lower-priority thread trying to complete the blocking command.
579 * And removed extra memcpy done on blocked command arrival.
580 *
581 * In the future we will extend CrHgsmi functionality to maintain texture data directly in CrHgsmi allocation to avoid extra memcpy-ing with PBO,
582 * implement command completion and stuff necessary for GPU scheduling to work properly for WDDM Windows guests, etc.
583 *
584 * NOTE: it is ALWAYS responsibility of the crVBoxServerCrHgsmiCmd to complete the command!
585 * */
586extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd);
587extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCtl(struct VBOXVDMACMD_CHROMIUM_CTL *pCtl, uint32_t cbCtl);
588
589#endif
590
591extern DECLEXPORT(int32_t) crVBoxServerHgcmEnable(VBOXCRCMDCTL_HGCMENABLE_DATA *pData);
592extern DECLEXPORT(int32_t) crVBoxServerHgcmDisable(VBOXCRCMDCTL_HGCMDISABLE_DATA *pData);
593
594extern int crVBoxServerHostCtl(VBOXCRCMDCTL *pCtl, uint32_t cbCtl);
595
596#ifdef __cplusplus
597}
598#endif
599
600#endif
601
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette