VirtualBox

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

Last change on this file since 20371 was 15532, checked in by vboxsync, 16 years ago

crOpenGL: export to OSE

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