VirtualBox

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

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

crOpenGL: backwards compatibility for 3D saved state v 28

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.3 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
93 GLint cVisibleRects; /*count of visible rects*/
94 GLint *pVisibleRects; /*visible rects left, top, right, bottom*/
95 GLboolean bReceivedRects; /*indicates if guest did any updates for visible regions*/
96
97 GLuint idFBO, idColorTex, idDepthStencilRB;
98 GLuint fboWidth, fboHeight;
99 GLuint idPBO;
100
101 void *pvOutputRedirectInstance;
102} CRMuralInfo;
103
104typedef struct {
105 char *pszDpyName;
106 GLint visualBits;
107 int32_t internalID;
108} CRCreateInfo_t;
109
110typedef struct {
111 CRContext *pContext;
112 int SpuContext;
113 CRCreateInfo_t CreateInfo;
114} CRContextInfo;
115
116/**
117 * A client is basically an upstream Cr Node (connected via mothership)
118 */
119typedef struct _crclient {
120 int spu_id; /**< id of the last SPU in the client's SPU chain */
121 CRConnection *conn; /**< network connection from the client */
122 int number; /**< a unique number for each client */
123 uint64_t pid; /*guest pid*/
124 GLint currentContextNumber;
125 CRContextInfo *currentCtxInfo;
126 GLint currentWindow;
127 CRMuralInfo *currentMural;
128 GLint windowList[CR_MAX_WINDOWS];
129 GLint contextList[CR_MAX_CONTEXTS];
130#ifdef VBOXCR_LOGFPS
131 uint64_t timeUsed;
132#endif
133} CRClient;
134
135typedef struct _crclientnode {
136 CRClient *pClient;
137 struct _crclientnode *prev, *next;
138} CRClientNode;
139
140typedef struct CRPoly_t {
141 int npoints;
142 double *points;
143 struct CRPoly_t *next;
144} CRPoly;
145
146/**
147 * There's one of these run queue entries per client
148 * The run queue is a circular, doubly-linked list of these objects.
149 */
150typedef struct RunQueue_t {
151 CRClient *client;
152 int blocked;
153 struct RunQueue_t *next;
154 struct RunQueue_t *prev;
155} RunQueue;
156
157typedef struct {
158 GLint freeWindowID;
159 GLint freeContextID;
160 GLint freeClientID;
161} CRServerFreeIDsPool_t;
162
163typedef struct {
164 int32_t x, y;
165 uint32_t w, h;
166 uint64_t winID;
167} CRScreenInfo;
168
169typedef struct {
170 unsigned short tcpip_port;
171
172 CRScreenInfo screen[CR_MAX_GUEST_MONITORS];
173 int screenCount;
174
175 int numClients;
176 CRClient *clients[CR_MAX_CLIENTS]; /**< array [numClients] */
177 CRClient *curClient;
178 CRClientNode *pCleanupClient; /*list of clients with pending clean up*/
179 CRCurrentStatePointers current;
180
181 GLboolean firstCallCreateContext;
182 GLboolean firstCallMakeCurrent;
183 GLboolean bIsInLoadingState; /* Indicates if we're in process of loading VM snapshot */
184 GLboolean bIsInSavingState; /* Indicates if we're in process of saving VM snapshot */
185 CRContextInfo *currentCtxInfo;
186 GLint currentWindow;
187 GLint currentNativeWindow;
188
189 CRHashTable *muralTable; /**< hash table where all murals are stored */
190 CRHashTable *pWindowCreateInfoTable; /**< hash table with windows creation info */
191
192 int client_spu_id;
193
194 CRServerFreeIDsPool_t idsPool;
195
196 int mtu;
197 int buffer_size;
198 char protocol[1024];
199
200 SPU *head_spu;
201 SPUDispatchTable dispatch;
202
203 CRNetworkPointer return_ptr;
204 CRNetworkPointer writeback_ptr;
205
206 CRLimitsState limits; /**< GL limits for any contexts we create */
207
208 CRContextInfo MainContextInfo;
209
210 CRHashTable *contextTable; /**< hash table for rendering contexts */
211
212 CRHashTable *programTable; /**< for vertex programs */
213 GLuint currentProgram;
214
215 /** configuration options */
216 /*@{*/
217 int useL2;
218 int ignore_papi;
219 unsigned int maxBarrierCount;
220 unsigned int clearCount;
221 int optimizeBucket;
222 int only_swap_once;
223 int debug_barriers;
224 int sharedDisplayLists;
225 int sharedTextureObjects;
226 int sharedPrograms;
227 int sharedWindows;
228 int uniqueWindows;
229 int localTileSpec;
230 int useDMX;
231 int overlapBlending;
232 int vpProjectionMatrixParameter;
233 const char *vpProjectionMatrixVariable;
234 int stereoView;
235 int vncMode; /* cmd line option */
236 /*@}*/
237 /** view_matrix config */
238 /*@{*/
239 GLboolean viewOverride;
240 CRmatrix viewMatrix[2]; /**< left and right eye */
241 /*@}*/
242 /** projection_matrix config */
243 /*@{*/
244 GLboolean projectionOverride;
245 CRmatrix projectionMatrix[2]; /**< left and right eye */
246 int currentEye;
247 /*@}*/
248
249 /** for warped tiles */
250 /*@{*/
251 GLfloat alignment_matrix[16], unnormalized_alignment_matrix[16];
252 /*@}*/
253
254 /** tile overlap/blending info - this should probably be per-mural */
255 /*@{*/
256 CRPoly **overlap_geom;
257 CRPoly *overlap_knockout;
258 float *overlap_intens;
259 int num_overlap_intens;
260 int num_overlap_levels;
261 /*@}*/
262
263 CRHashTable *barriers, *semaphores;
264
265 RunQueue *run_queue;
266
267 GLuint currentSerialNo;
268
269 PFNCRSERVERPRESENTFBO pfnPresentFBO;
270 GLboolean bForceOffscreenRendering; /*Force server to render 3d data offscreen
271 *using callback above to update vbox framebuffers*/
272 GLboolean bUsePBOForReadback; /*Use PBO's for data readback*/
273
274 GLboolean bUseOutputRedirect; /* Whether the output redirect was set. */
275 CROutputRedirect outputRedirect;
276
277 GLboolean bUseMultipleContexts;
278} CRServer;
279
280
281extern DECLEXPORT(void) crServerInit( int argc, char *argv[] );
282extern DECLEXPORT(int) CRServerMain( int argc, char *argv[] );
283extern DECLEXPORT(void) crServerServiceClients(void);
284extern DECLEXPORT(void) crServerAddNewClient(void);
285extern DECLEXPORT(SPU*) crServerHeadSPU(void);
286extern DECLEXPORT(void) crServerSetPort(int port);
287
288extern DECLEXPORT(GLboolean) crVBoxServerInit(void);
289extern DECLEXPORT(void) crVBoxServerTearDown(void);
290extern DECLEXPORT(int32_t) crVBoxServerAddClient(uint32_t u32ClientID);
291extern DECLEXPORT(void) crVBoxServerRemoveClient(uint32_t u32ClientID);
292extern DECLEXPORT(int32_t) crVBoxServerClientWrite(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t cbBuffer);
293extern DECLEXPORT(int32_t) crVBoxServerClientRead(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t *pcbBuffer);
294extern DECLEXPORT(int32_t) crVBoxServerClientSetVersion(uint32_t u32ClientID, uint32_t vMajor, uint32_t vMinor);
295extern DECLEXPORT(int32_t) crVBoxServerClientSetPID(uint32_t u32ClientID, uint64_t pid);
296
297extern DECLEXPORT(int32_t) crVBoxServerSaveState(PSSMHANDLE pSSM);
298extern DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version);
299
300extern DECLEXPORT(int32_t) crVBoxServerSetScreenCount(int sCount);
301extern DECLEXPORT(int32_t) crVBoxServerUnmapScreen(int sIndex);
302extern DECLEXPORT(int32_t) crVBoxServerMapScreen(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h, uint64_t winID);
303
304extern DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, GLint *pRects);
305
306extern DECLEXPORT(void) crVBoxServerSetPresentFBOCB(PFNCRSERVERPRESENTFBO pfnPresentFBO);
307
308extern DECLEXPORT(int32_t) crVBoxServerSetOffscreenRendering(GLboolean value);
309
310extern DECLEXPORT(int32_t) crVBoxServerOutputRedirectSet(const CROutputRedirect *pCallbacks);
311
312#ifdef VBOX_WITH_CRHGSMI
313/* We moved all CrHgsmi command processing to crserverlib to keep the logic of dealing with CrHgsmi commands in one place.
314 *
315 * 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.
316 * This help avoiding the "blocked-client" issues. The client is blocked if another client is doing begin-end stuff.
317 * For now we eliminated polling that could occur on block, which caused a higher-priority thread (in guest) polling for the blocked command complition
318 * to block the lower-priority thread trying to complete the blocking command.
319 * And removed extra memcpy done on blocked command arrival.
320 *
321 * In the future we will extend CrHgsmi functionality to maintain texture data directly in CrHgsmi allocation to avoid extra memcpy-ing with PBO,
322 * implement command completion and stuff necessary for GPU scheduling to work properly for WDDM Windows guests, etc.
323 *
324 * NOTE: it is ALWAYS responsibility of the crVBoxServerCrHgsmiCmd to complete the command!
325 * */
326extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd);
327extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCtl(struct VBOXVDMACMD_CHROMIUM_CTL *pCtl, uint32_t cbCtl);
328#endif
329
330#ifdef __cplusplus
331}
332#endif
333
334#endif
335
Note: See TracBrowser for help on using the repository browser.

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