VirtualBox

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

Last change on this file since 33281 was 27889, checked in by vboxsync, 15 years ago

crOpenGL: more code for multiscreen support

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