VirtualBox

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

Last change on this file since 42045 was 41404, checked in by vboxsync, 13 years ago

crOpenGL: VM window scroll handling

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.7 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 "spu_dispatch_table.h"
16
17#include "state/cr_currentpointers.h"
18
19#include <iprt/types.h>
20#include <iprt/err.h>
21#include <iprt/string.h>
22
23#include <VBox/vmm/ssm.h>
24
25#ifdef VBOX_WITH_CRHGSMI
26# include <VBox/VBoxVideo.h>
27#endif
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#define CR_MAX_WINDOWS 100
34#define CR_MAX_CLIENTS 64
35
36/*@todo must match MaxGuestMonitors from SchemaDefs.h*/
37#define CR_MAX_GUEST_MONITORS 8
38
39typedef DECLCALLBACKPTR(void, PFNCRSERVERPRESENTFBO) (void *data, int32_t screenId, int32_t x, int32_t y, uint32_t w, uint32_t h);
40
41/* Callbacks for output of the rendered frames.
42 *
43 * This allows to pass rendered frames to an external component rather than draw them on screen.
44 *
45 * An external component registers the redirection callbacks using crVBoxServerOutputRedirectSet.
46 *
47 * The list of formats supported by the caller is obtained using CRORContextProperty.
48 * The actual format choosed by the service is passed as a CRORBegin parameter.
49 */
50typedef struct {
51 const void *pvContext; /* Supplied by crVBoxServerOutputRedirectSet. */
52 DECLR3CALLBACKMEMBER(void, CRORBegin, (const void *pvContext, void **ppvInstance,
53 const char *pszFormat));
54 DECLR3CALLBACKMEMBER(void, CRORGeometry, (void *pvInstance,
55 int32_t x, int32_t y, uint32_t w, uint32_t h));
56 DECLR3CALLBACKMEMBER(void, CRORVisibleRegion, (void *pvInstance,
57 uint32_t cRects, RTRECT *paRects));
58 DECLR3CALLBACKMEMBER(void, CRORFrame, (void *pvInstance,
59 void *pvData, uint32_t cbData));
60 DECLR3CALLBACKMEMBER(void, CROREnd, (void *pvInstance));
61 DECLR3CALLBACKMEMBER(int, CRORContextProperty, (const void *pvContext, uint32_t index,
62 void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut));
63} CROutputRedirect;
64
65typedef struct {
66 CRrecti imagewindow; /**< coordinates in mural space */
67 CRrectf bounds; /**< normalized coordinates in [-1,-1] x [1,1] */
68 CRrecti outputwindow; /**< coordinates in server's rendering window */
69 CRrecti clippedImagewindow; /**< imagewindow clipped to current viewport */
70 CRmatrix baseProjection; /**< pre-multiplied onto projection matrix */
71 CRrecti scissorBox; /**< passed to back-end OpenGL */
72 CRrecti viewport; /**< passed to back-end OpenGL */
73 GLuint serialNo; /**< an optimization */
74} CRExtent;
75
76struct BucketingInfo;
77
78/**
79 * Mural info
80 */
81typedef struct {
82 GLuint width, height;
83 GLint gX, gY; /*guest coordinates*/
84 GLint hX, hY; /*host coordinates, screenID related*/
85
86 int spuWindow; /*the SPU's corresponding window ID */
87
88 int screenId;
89
90 GLboolean bVisible; /*guest window is visible*/
91 GLboolean bUseFBO; /*redirect to FBO instead of real host window*/
92 GLboolean bFbDraw; /*GL_FRONT buffer is drawn to directly*/
93
94 GLint cVisibleRects; /*count of visible rects*/
95 GLint *pVisibleRects; /*visible rects left, top, right, bottom*/
96 GLboolean bReceivedRects; /*indicates if guest did any updates for visible regions*/
97
98 GLuint idFBO, idColorTex, idDepthStencilRB;
99 GLuint fboWidth, fboHeight;
100 GLuint idPBO;
101
102 void *pvOutputRedirectInstance;
103} CRMuralInfo;
104
105typedef struct {
106 char *pszDpyName;
107 GLint visualBits;
108 int32_t externalID;
109} CRCreateInfo_t;
110
111typedef struct {
112 CRContext *pContext;
113 int SpuContext;
114 CRCreateInfo_t CreateInfo;
115} CRContextInfo;
116
117/**
118 * A client is basically an upstream Cr Node (connected via mothership)
119 */
120typedef struct _crclient {
121 int spu_id; /**< id of the last SPU in the client's SPU chain */
122 CRConnection *conn; /**< network connection from the client */
123 int number; /**< a unique number for each client */
124 uint64_t pid; /*guest pid*/
125 GLint currentContextNumber;
126 CRContextInfo *currentCtxInfo;
127 GLint currentWindow;
128 CRMuralInfo *currentMural;
129 GLint windowList[CR_MAX_WINDOWS];
130 GLint contextList[CR_MAX_CONTEXTS];
131#ifdef VBOXCR_LOGFPS
132 uint64_t timeUsed;
133#endif
134} CRClient;
135
136typedef struct _crclientnode {
137 CRClient *pClient;
138 struct _crclientnode *prev, *next;
139} CRClientNode;
140
141typedef struct CRPoly_t {
142 int npoints;
143 double *points;
144 struct CRPoly_t *next;
145} CRPoly;
146
147/**
148 * There's one of these run queue entries per client
149 * The run queue is a circular, doubly-linked list of these objects.
150 */
151typedef struct RunQueue_t {
152 CRClient *client;
153 int blocked;
154 struct RunQueue_t *next;
155 struct RunQueue_t *prev;
156} RunQueue;
157
158typedef struct {
159 GLint freeWindowID;
160 GLint freeContextID;
161 GLint freeClientID;
162} CRServerFreeIDsPool_t;
163
164typedef struct {
165 int32_t x, y;
166 uint32_t w, h;
167 uint64_t winID;
168} CRScreenInfo;
169
170typedef struct {
171 int32_t x, y;
172 uint32_t w, h;
173} CRScreenViewportInfo;
174
175
176typedef struct {
177 unsigned short tcpip_port;
178
179 CRScreenInfo screen[CR_MAX_GUEST_MONITORS];
180 CRScreenViewportInfo screenVieport[CR_MAX_GUEST_MONITORS];
181 int screenCount;
182
183 int numClients;
184 CRClient *clients[CR_MAX_CLIENTS]; /**< array [numClients] */
185 CRClient *curClient;
186 CRClientNode *pCleanupClient; /*list of clients with pending clean up*/
187 CRCurrentStatePointers current;
188
189 GLboolean firstCallCreateContext;
190 GLboolean firstCallMakeCurrent;
191 GLboolean bIsInLoadingState; /* Indicates if we're in process of loading VM snapshot */
192 GLboolean bIsInSavingState; /* Indicates if we're in process of saving VM snapshot */
193 GLboolean bForceMakeCurrentOnClientSwitch;
194 CRContextInfo *currentCtxInfo;
195 GLint currentWindow;
196 GLint currentNativeWindow;
197
198 CRHashTable *muralTable; /**< hash table where all murals are stored */
199 CRHashTable *pWindowCreateInfoTable; /**< hash table with windows creation info */
200
201 int client_spu_id;
202
203 CRServerFreeIDsPool_t idsPool;
204
205 int mtu;
206 int buffer_size;
207 char protocol[1024];
208
209 SPU *head_spu;
210 SPUDispatchTable dispatch;
211
212 CRNetworkPointer return_ptr;
213 CRNetworkPointer writeback_ptr;
214
215 CRLimitsState limits; /**< GL limits for any contexts we create */
216
217 CRContextInfo MainContextInfo;
218
219 CRHashTable *contextTable; /**< hash table for rendering contexts */
220
221 CRHashTable *programTable; /**< for vertex programs */
222 GLuint currentProgram;
223
224 /** configuration options */
225 /*@{*/
226 int useL2;
227 int ignore_papi;
228 unsigned int maxBarrierCount;
229 unsigned int clearCount;
230 int optimizeBucket;
231 int only_swap_once;
232 int debug_barriers;
233 int sharedDisplayLists;
234 int sharedTextureObjects;
235 int sharedPrograms;
236 int sharedWindows;
237 int uniqueWindows;
238 int localTileSpec;
239 int useDMX;
240 int overlapBlending;
241 int vpProjectionMatrixParameter;
242 const char *vpProjectionMatrixVariable;
243 int stereoView;
244 int vncMode; /* cmd line option */
245 /*@}*/
246 /** view_matrix config */
247 /*@{*/
248 GLboolean viewOverride;
249 CRmatrix viewMatrix[2]; /**< left and right eye */
250 /*@}*/
251 /** projection_matrix config */
252 /*@{*/
253 GLboolean projectionOverride;
254 CRmatrix projectionMatrix[2]; /**< left and right eye */
255 int currentEye;
256 /*@}*/
257
258 /** for warped tiles */
259 /*@{*/
260 GLfloat alignment_matrix[16], unnormalized_alignment_matrix[16];
261 /*@}*/
262
263 /** tile overlap/blending info - this should probably be per-mural */
264 /*@{*/
265 CRPoly **overlap_geom;
266 CRPoly *overlap_knockout;
267 float *overlap_intens;
268 int num_overlap_intens;
269 int num_overlap_levels;
270 /*@}*/
271
272 CRHashTable *barriers, *semaphores;
273
274 RunQueue *run_queue;
275
276 GLuint currentSerialNo;
277
278 PFNCRSERVERPRESENTFBO pfnPresentFBO;
279 GLboolean bForceOffscreenRendering; /*Force server to render 3d data offscreen
280 *using callback above to update vbox framebuffers*/
281 GLboolean bUsePBOForReadback; /*Use PBO's for data readback*/
282
283 GLboolean bUseOutputRedirect; /* Whether the output redirect was set. */
284 CROutputRedirect outputRedirect;
285
286 GLboolean bUseMultipleContexts;
287} CRServer;
288
289
290extern DECLEXPORT(void) crServerInit( int argc, char *argv[] );
291extern DECLEXPORT(int) CRServerMain( int argc, char *argv[] );
292extern DECLEXPORT(void) crServerServiceClients(void);
293extern DECLEXPORT(void) crServerAddNewClient(void);
294extern DECLEXPORT(SPU*) crServerHeadSPU(void);
295extern DECLEXPORT(void) crServerSetPort(int port);
296
297extern DECLEXPORT(GLboolean) crVBoxServerInit(void);
298extern DECLEXPORT(void) crVBoxServerTearDown(void);
299extern DECLEXPORT(int32_t) crVBoxServerAddClient(uint32_t u32ClientID);
300extern DECLEXPORT(void) crVBoxServerRemoveClient(uint32_t u32ClientID);
301extern DECLEXPORT(int32_t) crVBoxServerClientWrite(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t cbBuffer);
302extern DECLEXPORT(int32_t) crVBoxServerClientRead(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t *pcbBuffer);
303extern DECLEXPORT(int32_t) crVBoxServerClientSetVersion(uint32_t u32ClientID, uint32_t vMajor, uint32_t vMinor);
304extern DECLEXPORT(int32_t) crVBoxServerClientSetPID(uint32_t u32ClientID, uint64_t pid);
305
306extern DECLEXPORT(int32_t) crVBoxServerSaveState(PSSMHANDLE pSSM);
307extern DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version);
308
309extern DECLEXPORT(int32_t) crVBoxServerSetScreenCount(int sCount);
310extern DECLEXPORT(int32_t) crVBoxServerUnmapScreen(int sIndex);
311extern DECLEXPORT(int32_t) crVBoxServerMapScreen(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h, uint64_t winID);
312
313extern DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, GLint *pRects);
314
315extern DECLEXPORT(void) crVBoxServerSetPresentFBOCB(PFNCRSERVERPRESENTFBO pfnPresentFBO);
316
317extern DECLEXPORT(int32_t) crVBoxServerSetOffscreenRendering(GLboolean value);
318
319extern DECLEXPORT(int32_t) crVBoxServerOutputRedirectSet(const CROutputRedirect *pCallbacks);
320
321extern DECLEXPORT(int32_t) crVBoxServerSetScreenViewport(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h);
322
323#ifdef VBOX_WITH_CRHGSMI
324/* We moved all CrHgsmi command processing to crserverlib to keep the logic of dealing with CrHgsmi commands in one place.
325 *
326 * 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.
327 * This help avoiding the "blocked-client" issues. The client is blocked if another client is doing begin-end stuff.
328 * For now we eliminated polling that could occur on block, which caused a higher-priority thread (in guest) polling for the blocked command complition
329 * to block the lower-priority thread trying to complete the blocking command.
330 * And removed extra memcpy done on blocked command arrival.
331 *
332 * In the future we will extend CrHgsmi functionality to maintain texture data directly in CrHgsmi allocation to avoid extra memcpy-ing with PBO,
333 * implement command completion and stuff necessary for GPU scheduling to work properly for WDDM Windows guests, etc.
334 *
335 * NOTE: it is ALWAYS responsibility of the crVBoxServerCrHgsmiCmd to complete the command!
336 * */
337extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd);
338extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCtl(struct VBOXVDMACMD_CHROMIUM_CTL *pCtl, uint32_t cbCtl);
339#endif
340
341#ifdef __cplusplus
342}
343#endif
344
345#endif
346
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