VirtualBox

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

最後變更 在這個檔案從44196是 43945,由 vboxsync 提交於 12 年 前

OpenGL: warnings and a bugfix

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

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