VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c@ 35969

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

crOpenGL: add option to force fbo usage for 3d over rdp

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.8 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#include <string.h>
8#include "cr_mem.h"
9#include "cr_environment.h"
10#include "cr_string.h"
11#include "cr_error.h"
12#include "cr_glstate.h"
13#include "server.h"
14
15#ifdef WINDOWS
16#pragma warning( disable: 4706 )
17#endif
18
19static void
20setDefaults(void)
21{
22 if (!cr_server.tcpip_port)
23 cr_server.tcpip_port = DEFAULT_SERVER_PORT;
24 cr_server.run_queue = NULL;
25 cr_server.optimizeBucket = 1;
26 cr_server.useL2 = 0;
27 cr_server.maxBarrierCount = 0;
28 cr_server.ignore_papi = 0;
29 cr_server.only_swap_once = 0;
30 cr_server.overlapBlending = 0;
31 cr_server.debug_barriers = 0;
32 cr_server.sharedDisplayLists = 0;
33 cr_server.sharedTextureObjects = 0;
34 cr_server.sharedPrograms = 0;
35 cr_server.sharedWindows = 0;
36 cr_server.useDMX = 0;
37 cr_server.vpProjectionMatrixParameter = -1;
38 cr_server.vpProjectionMatrixVariable = NULL;
39 cr_server.currentProgram = 0;
40
41 cr_server.num_overlap_intens = 0;
42 cr_server.overlap_intens = 0;
43 cr_server.SpuContext = 0;
44
45 crMatrixInit(&cr_server.viewMatrix[0]);
46 crMatrixInit(&cr_server.viewMatrix[1]);
47 crMatrixInit(&cr_server.projectionMatrix[0]);
48 crMatrixInit(&cr_server.projectionMatrix[1]);
49 cr_server.currentEye = -1;
50
51 cr_server.uniqueWindows = 0;
52
53 cr_server.idsPool.freeWindowID = 1;
54 cr_server.idsPool.freeContextID = 1;
55 cr_server.idsPool.freeClientID = 1;
56
57 cr_server.screenCount = 0;
58 cr_server.bForceOffscreenRendering = GL_FALSE;
59}
60
61void crServerSetVBoxConfiguration()
62{
63 CRMuralInfo *defaultMural;
64 char response[8096];
65
66 char **spuchain;
67 int num_spus;
68 int *spu_ids;
69 char **spu_names;
70 char *spu_dir = NULL;
71 int i;
72 /* Quadrics defaults */
73 int my_rank = 0;
74 int low_context = CR_QUADRICS_DEFAULT_LOW_CONTEXT;
75 int high_context = CR_QUADRICS_DEFAULT_HIGH_CONTEXT;
76 unsigned char key[16]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
77 char hostname[1024];
78 char **clientchain, **clientlist;
79 GLint dims[4];
80
81 defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
82 CRASSERT(defaultMural);
83
84 setDefaults();
85
86 /*
87 * Get my hostname
88 */
89 if (crGetHostname(hostname, sizeof(hostname)))
90 {
91 crError("CRServer: Couldn't get my own hostname?");
92 }
93
94 strcpy(response, "1 0 render");
95 crDebug("CRServer: my SPU chain: %s", response);
96
97 /* response will describe the SPU chain.
98 * Example "2 5 wet 6 render"
99 */
100 spuchain = crStrSplit(response, " ");
101 num_spus = crStrToInt(spuchain[0]);
102 spu_ids = (int *) crAlloc(num_spus * sizeof(*spu_ids));
103 spu_names = (char **) crAlloc((num_spus + 1) * sizeof(*spu_names));
104 for (i = 0; i < num_spus; i++)
105 {
106 spu_ids[i] = crStrToInt(spuchain[2 * i + 1]);
107 spu_names[i] = crStrdup(spuchain[2 * i + 2]);
108 crDebug("SPU %d/%d: (%d) \"%s\"", i + 1, num_spus, spu_ids[i],
109 spu_names[i]);
110 }
111 spu_names[i] = NULL;
112
113 //spu_dir = crStrdup(response);
114 crNetSetRank(0);
115 crNetSetContextRange(32, 35);
116 crNetSetNodeRange("iam0", "iamvis20");
117 crNetSetKey(key,sizeof(key));
118 crNetSetKey(key,sizeof(key));
119 cr_server.tcpip_port = 7000;
120
121 /*cr_server.optimizeBucket = crStrToInt(response);
122 cr_server.localTileSpec = crStrToInt(response);
123 cr_server.useL2 = crStrToInt(response);
124 cr_server.ignore_papi = crStrToInt(response);
125 if (crMothershipGetServerParam(conn, response, "overlap_blending"))
126 {
127 if (!crStrcmp(response, "blend"))
128 cr_server.overlapBlending = 1;
129 else if (!crStrcmp(response, "knockout"))
130 cr_server.overlapBlending = 2;
131 }
132 if (crMothershipGetServerParam(conn, response, "overlap_levels"))
133 cr_server.only_swap_once = crStrToInt(response);
134 cr_server.debug_barriers = crStrToInt(response);
135 cr_server.sharedDisplayLists = crStrToInt(response);
136 cr_server.sharedTextureObjects = crStrToInt(response);
137 cr_server.sharedPrograms = crStrToInt(response);
138 cr_server.sharedWindows = crStrToInt(response);
139 cr_server.uniqueWindows = crStrToInt(response);
140 cr_server.useDMX = crStrToInt(response);
141 if (crMothershipGetServerParam(conn, response, "vertprog_projection_param"))
142 if (crMothershipGetServerParam(conn, response, "stereo_view"))
143 if (crMothershipGetServerParam(conn, response, "view_matrix"))
144 if (crMothershipGetServerParam(conn, response, "right_view_matrix"))
145 if (crMothershipGetServerParam(conn, response, "projection_matrix"))
146 if (crMothershipGetServerParam(conn, response, "right_projection_matrix"))*/
147
148 crDebug("CRServer: my port number is %d", cr_server.tcpip_port);
149
150 /*
151 * Load the SPUs
152 */
153 cr_server.head_spu =
154 crSPULoadChain(num_spus, spu_ids, spu_names, spu_dir, &cr_server);
155
156 /* Need to do this as early as possible */
157
158 cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_POSITION_CR, 0, GL_INT, 2, &dims[0]);
159 cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, 0, GL_INT, 2, &dims[2]);
160
161 defaultMural->gX = dims[0];
162 defaultMural->gY = dims[1];
163 defaultMural->width = dims[2];
164 defaultMural->height = dims[3];
165
166 crFree(spu_ids);
167 crFreeStrings(spu_names);
168 crFreeStrings(spuchain);
169 if (spu_dir)
170 crFree(spu_dir);
171
172 cr_server.mtu = 1024 * 30;
173
174 /*
175 * Get a list of all the clients talking to me.
176 */
177 if (cr_server.vncMode) {
178 /* we're inside a vnc viewer */
179 /*if (!crMothershipSendString( conn, response, "getvncclient %s", hostname ))
180 crError( "Bad Mothership response: %s", response );*/
181 }
182 else {
183 //crMothershipGetClients(conn, response);
184 strcpy(response, "1 tcpip 1");
185 }
186
187 crDebug("CRServer: my clients: %s", response);
188
189 /*
190 * 'response' will now contain a number indicating the number of clients
191 * of this server, followed by a comma-separated list of protocol/SPU ID
192 * pairs.
193 * Example: "3 tcpip 1,gm 2,via 10"
194 */
195 clientchain = crStrSplitn(response, " ", 1);
196 cr_server.numClients = crStrToInt(clientchain[0]);
197 if (cr_server.numClients == 0)
198 {
199 crError("I have no clients! What's a poor server to do?");
200 }
201 clientlist = crStrSplit(clientchain[1], ",");
202
203 /*
204 * Connect to initial set of clients.
205 * Call crNetAcceptClient() for each client.
206 * Also, look for a client that's _not_ using the file: protocol.
207 */
208 for (i = 0; i < cr_server.numClients; i++)
209 {
210 CRClient *newClient = (CRClient *) crCalloc(sizeof(CRClient));
211#ifdef VBOX
212 sscanf(clientlist[i], "%1023s %d", cr_server.protocol, &(newClient->spu_id));
213#else
214 sscanf(clientlist[i], "%s %d", cr_server.protocol, &(newClient->spu_id));
215#endif
216 newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
217 cr_server.tcpip_port,
218 cr_server.mtu, 0);
219 newClient->currentCtx = cr_server.DummyContext;
220 crServerAddToRunQueue(newClient);
221
222 cr_server.clients[i] = newClient;
223 }
224
225 /* set default client and mural */
226 if (cr_server.numClients > 0) {
227 cr_server.curClient = cr_server.clients[0];
228 cr_server.curClient->currentMural = defaultMural;
229 cr_server.client_spu_id =cr_server.clients[0]->spu_id;
230 }
231
232 crFreeStrings(clientchain);
233 crFreeStrings(clientlist);
234
235 /* Ask the mothership for the tile info */
236 //crServerGetTileInfoFromMothership(conn, defaultMural);
237
238 if (cr_server.vncMode) {
239 /* In vnc mode, we reset the mothership configuration so that it can be
240 * used by subsequent OpenGL apps without having to spawn a new mothership
241 * on a new port.
242 */
243 crDebug("CRServer: Resetting mothership to initial state");
244 //crMothershipReset(conn);
245 }
246
247 //crMothershipDisconnect(conn);
248}
249
250void crServerSetVBoxConfigurationHGCM()
251{
252 CRMuralInfo *defaultMural;
253
254 int spu_ids[1] = {0};
255 char *spu_names[1] = {"render"};
256 char *spu_dir = NULL;
257 int i;
258 GLint dims[4];
259
260 defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
261 CRASSERT(defaultMural);
262
263 //@todo should be moved to addclient so we have a chain for each client
264
265 setDefaults();
266
267 /* Load the SPUs */
268 cr_server.head_spu = crSPULoadChain(1, spu_ids, spu_names, spu_dir, &cr_server);
269
270 if (!cr_server.head_spu)
271 return;
272
273 cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_POSITION_CR, 0, GL_INT, 2, &dims[0]);
274 cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, 0, GL_INT, 2, &dims[2]);
275
276 defaultMural->gX = dims[0];
277 defaultMural->gY = dims[1];
278 defaultMural->width = dims[2];
279 defaultMural->height = dims[3];
280
281 cr_server.mtu = 1024 * 250;
282
283 cr_server.numClients = 0;
284 strcpy(cr_server.protocol, "vboxhgcm");
285
286 for (i = 0; i < cr_server.numClients; i++)
287 {
288 CRClient *newClient = (CRClient *) crCalloc(sizeof(CRClient));
289 newClient->spu_id = 0;
290 newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
291 cr_server.tcpip_port,
292 cr_server.mtu, 0);
293 newClient->currentCtx = cr_server.DummyContext;
294 crServerAddToRunQueue(newClient);
295
296 cr_server.clients[i] = newClient;
297 }
298
299 /* set default client and mural */
300 if (cr_server.numClients > 0) {
301 cr_server.curClient = cr_server.clients[0];
302 cr_server.curClient->currentMural = defaultMural;
303 cr_server.client_spu_id =cr_server.clients[0]->spu_id;
304 }
305}
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