VirtualBox

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

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

crOpenGL: some initial support for new multimonitor code

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