VirtualBox

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

最後變更 在這個檔案從34382是 33992,由 vboxsync 提交於 14 年 前

Grrr

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 9.7 KB
 
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#ifdef VBOX
211 sscanf(clientlist[i], "%1023s %d", cr_server.protocol, &(newClient->spu_id));
212#else
213 sscanf(clientlist[i], "%s %d", cr_server.protocol, &(newClient->spu_id));
214#endif
215 newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
216 cr_server.tcpip_port,
217 cr_server.mtu, 0);
218 newClient->currentCtx = cr_server.DummyContext;
219 crServerAddToRunQueue(newClient);
220
221 cr_server.clients[i] = newClient;
222 }
223
224 /* set default client and mural */
225 if (cr_server.numClients > 0) {
226 cr_server.curClient = cr_server.clients[0];
227 cr_server.curClient->currentMural = defaultMural;
228 cr_server.client_spu_id =cr_server.clients[0]->spu_id;
229 }
230
231 crFreeStrings(clientchain);
232 crFreeStrings(clientlist);
233
234 /* Ask the mothership for the tile info */
235 //crServerGetTileInfoFromMothership(conn, defaultMural);
236
237 if (cr_server.vncMode) {
238 /* In vnc mode, we reset the mothership configuration so that it can be
239 * used by subsequent OpenGL apps without having to spawn a new mothership
240 * on a new port.
241 */
242 crDebug("CRServer: Resetting mothership to initial state");
243 //crMothershipReset(conn);
244 }
245
246 //crMothershipDisconnect(conn);
247}
248
249void crServerSetVBoxConfigurationHGCM()
250{
251 CRMuralInfo *defaultMural;
252
253 int spu_ids[1] = {0};
254 char *spu_names[1] = {"render"};
255 char *spu_dir = NULL;
256 int i;
257 GLint dims[4];
258
259 defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
260 CRASSERT(defaultMural);
261
262 //@todo should be moved to addclient so we have a chain for each client
263
264 setDefaults();
265
266 /* Load the SPUs */
267 cr_server.head_spu = crSPULoadChain(1, spu_ids, spu_names, spu_dir, &cr_server);
268
269 if (!cr_server.head_spu)
270 return;
271
272 cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_POSITION_CR, 0, GL_INT, 2, &dims[0]);
273 cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, 0, GL_INT, 2, &dims[2]);
274
275 defaultMural->gX = dims[0];
276 defaultMural->gY = dims[1];
277 defaultMural->width = dims[2];
278 defaultMural->height = dims[3];
279
280 cr_server.mtu = 1024 * 250;
281
282 cr_server.numClients = 0;
283 strcpy(cr_server.protocol, "vboxhgcm");
284
285 for (i = 0; i < cr_server.numClients; i++)
286 {
287 CRClient *newClient = (CRClient *) crCalloc(sizeof(CRClient));
288 newClient->spu_id = 0;
289 newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
290 cr_server.tcpip_port,
291 cr_server.mtu, 0);
292 newClient->currentCtx = cr_server.DummyContext;
293 crServerAddToRunQueue(newClient);
294
295 cr_server.clients[i] = newClient;
296 }
297
298 /* set default client and mural */
299 if (cr_server.numClients > 0) {
300 cr_server.curClient = cr_server.clients[0];
301 cr_server.curClient->currentMural = defaultMural;
302 cr_server.client_spu_id =cr_server.clients[0]->spu_id;
303 }
304}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette