VirtualBox

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

Last change on this file since 36843 was 36843, checked in by vboxsync, 14 years ago

3D for VRDP: initial commit (xTracker 5565).

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