VirtualBox

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

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

crOpenGL: bump 3d saved state version

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