1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
/* $XFree86: xc/programs/Xserver/GL/glx/glxscreens.c,v 1.6 2001/03/21 16:29:36 dawes Exp $ */
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
**
*/
#ifdef HAVE_DMX_CONFIG_H
#include <dmx-config.h>
#endif
#include "dmx.h"
#include "dmxlog.h"
#undef Xmalloc
#undef Xcalloc
#undef Xrealloc
#undef Xfree
#include "glxserver.h"
#include <xf86_ansic.h>
#include <windowstr.h>
#include "glxfbconfig.h"
#ifdef PANORAMIX
#include "panoramiXsrv.h"
#endif
__GLXscreenInfo *__glXActiveScreens;
GLint __glXNumActiveScreens;
__GLXFBConfig **__glXFBConfigs;
int __glXNumFBConfigs;
static char GLXServerVendorName[] = "SGI DMX/glxProxy";
static char GLXServerVersion[64];
static char GLXServerExtensions[] =
"GLX_EXT_visual_info "
"GLX_EXT_visual_rating "
"GLX_EXT_import_context "
"GLX_SGIX_fbconfig "
"GLX_SGI_make_current_read "
"GLX_SGI_swap_control "
;
static char ExtensionsString[1024];
static void CalcServerVersionAndExtensions( void )
{
int s;
xGLXQueryVersionReq *req;
xGLXQueryVersionReply reply;
char **be_extensions;
char *ext;
char *denied_extensions;
/*
* set the server glx version to be the minimum version
* supported by all back-end servers
*/
__glXVersionMajor = 0;
__glXVersionMinor = 0;
for (s=0; s<__glXNumActiveScreens; s++) {
DMXScreenInfo *dmxScreen = &dmxScreens[s];
Display *dpy = dmxScreen->beDisplay;
/* Send the glXQueryVersion request */
LockDisplay(dpy);
GetReq(GLXQueryVersion,req);
req->reqType = dmxScreen->glxMajorOpcode;
req->glxCode = X_GLXQueryVersion;
req->majorVersion = GLX_SERVER_MAJOR_VERSION;
req->minorVersion = GLX_SERVER_MINOR_VERSION;
_XReply(dpy, (xReply*) &reply, 0, False);
UnlockDisplay(dpy);
SyncHandle();
if (s == 0) {
__glXVersionMajor = reply.majorVersion;
__glXVersionMinor = reply.minorVersion;
}
else {
if (reply.majorVersion < __glXVersionMajor) {
__glXVersionMajor = reply.majorVersion;
__glXVersionMinor = reply.minorVersion;
}
else if ( (reply.majorVersion == __glXVersionMajor) &&
(reply.minorVersion < __glXVersionMinor) ) {
__glXVersionMinor = reply.minorVersion;
}
}
}
if (GLX_SERVER_MAJOR_VERSION < __glXVersionMajor) {
__glXVersionMajor = GLX_SERVER_MAJOR_VERSION;
__glXVersionMinor = GLX_SERVER_MINOR_VERSION;
}
else if ( (GLX_SERVER_MAJOR_VERSION == __glXVersionMajor) &&
(GLX_SERVER_MINOR_VERSION < __glXVersionMinor) ) {
__glXVersionMinor = GLX_SERVER_MINOR_VERSION;
}
sprintf(GLXServerVersion, "%d.%d DMX %d back-end server(s)",
__glXVersionMajor, __glXVersionMinor, __glXNumActiveScreens );
/*
* set the ExtensionsString to the minimum extensions string
*/
ExtensionsString[0] = '\0';
/*
* read extensions strings of all back-end servers
*/
be_extensions = (char **)Xalloc( __glXNumActiveScreens * sizeof(char *) );
if (!be_extensions)
return;
for (s=0; s<__glXNumActiveScreens; s++) {
DMXScreenInfo *dmxScreen = &dmxScreens[s];
Display *dpy = dmxScreen->beDisplay;
xGLXQueryServerStringReq *req;
xGLXQueryServerStringReply reply;
int length, numbytes, slop;
/* Send the glXQueryServerString request */
LockDisplay(dpy);
GetReq(GLXQueryServerString,req);
req->reqType = dmxScreen->glxMajorOpcode;
req->glxCode = X_GLXQueryServerString;
req->screen = DefaultScreen(dpy);
req->name = GLX_EXTENSIONS;
_XReply(dpy, (xReply*) &reply, 0, False);
length = (int)reply.length;
numbytes = (int)reply.n;
slop = numbytes * __GLX_SIZE_INT8 & 3;
be_extensions[s] = (char *)Xalloc(numbytes);
if (!be_extensions[s]) {
/* Throw data on the floor */
_XEatData(dpy, length);
} else {
_XRead(dpy, (char *)be_extensions[s], numbytes);
if (slop) _XEatData(dpy,4-slop);
}
UnlockDisplay(dpy);
SyncHandle();
}
/*
* extensions string will include only extensions that our
* server supports as well as all back-end servers supports.
* extensions that are in the DMX_DENY_EXTENSIONS string will
* not be supported.
*/
denied_extensions = getenv("DMX_DENY_GLX_EXTENSIONS");
ext = strtok(GLXServerExtensions, " ");
while( ext ) {
int supported = 1;
if (denied_extensions && strstr(denied_extensions, ext)) {
supported = 0;
}
else {
for (s=0; s<__glXNumActiveScreens && supported; s++) {
if ( !strstr(be_extensions[s], ext) ) {
supported = 0;
}
}
}
if (supported) {
strcat(ExtensionsString, ext);
strcat(ExtensionsString, " ");
}
ext = strtok(NULL, " ");
}
/*
* release temporary storage
*/
for (s=0; s<__glXNumActiveScreens; s++) {
if (be_extensions[s]) Xfree(be_extensions[s]);
}
Xfree( be_extensions );
if (dmxGLXSwapGroupSupport) {
if (!denied_extensions ||
!strstr(denied_extensions, "GLX_SGIX_swap_group")) {
strcat(ExtensionsString, "GLX_SGIX_swap_group");
if (!denied_extensions ||
!strstr(denied_extensions, "GLX_SGIX_swap_barrier")) {
strcat(ExtensionsString, " GLX_SGIX_swap_barrier");
}
}
}
}
void __glXScreenInit(GLint numscreens)
{
int s;
int c;
DMXScreenInfo *dmxScreen0 = &dmxScreens[0];
__glXNumActiveScreens = numscreens;
CalcServerVersionAndExtensions();
__glXFBConfigs = NULL;
__glXNumFBConfigs = 0;
if ( (__glXVersionMajor == 1 && __glXVersionMinor >= 3) ||
(__glXVersionMajor > 1) ||
( strstr(ExtensionsString, "GLX_SGIX_fbconfig") ) ) {
/*
// Initialize FBConfig info.
// find the set of FBConfigs that are present on all back-end
// servers - only those configs will be supported
*/
__glXFBConfigs = (__GLXFBConfig **)Xalloc( dmxScreen0->numFBConfigs *
(numscreens+1) * sizeof(__GLXFBConfig *) );
__glXNumFBConfigs = 0;
for (c=0; c<dmxScreen0->numFBConfigs; c++) {
__GLXFBConfig *cfg = NULL;
if (numscreens > 1) {
for (s=1; s<numscreens; s++) {
DMXScreenInfo *dmxScreen = &dmxScreens[s];
__GLXscreenInfo *glxScreen = &__glXActiveScreens[s];
cfg = FindMatchingFBConfig( &dmxScreen0->fbconfigs[c],
dmxScreen->fbconfigs,
dmxScreen->numFBConfigs );
__glXFBConfigs[ __glXNumFBConfigs * (numscreens+1) + s + 1 ] = cfg;
if (!cfg) {
dmxLog(dmxInfo,"screen0 FBConfig 0x%x is missing on screen#%d\n", dmxScreen0->fbconfigs[c].id, s);
break;
}
else {
dmxLog(dmxInfo,"screen0 FBConfig 0x%x matched to 0x%x on screen#%d\n", dmxScreen0->fbconfigs[c].id, cfg->id, s);
}
}
}
else {
cfg = &dmxScreen0->fbconfigs[c];
}
if (cfg) {
/* filter out overlay visuals */
if (cfg->level == 0) {
__GLXFBConfig *proxy_cfg;
__glXFBConfigs[ __glXNumFBConfigs * (numscreens+1) + 1 ] =
&dmxScreen0->fbconfigs[c];
proxy_cfg = Xalloc( sizeof(__GLXFBConfig) );
memcpy( proxy_cfg, cfg, sizeof(__GLXFBConfig) );
proxy_cfg->id = FakeClientID(0);
/* visual will be associated later in __glXGetFBConfigs */
proxy_cfg->associatedVisualId = (unsigned int)-1;
__glXFBConfigs[ __glXNumFBConfigs * (numscreens+1) + 0 ] = proxy_cfg;
__glXNumFBConfigs++;
}
}
}
}
}
void __glXScreenReset(void)
{
__glXNumActiveScreens = 0;
}
char *__glXGetServerString( unsigned int name )
{
char *ret = NULL;
switch( name) {
case GLX_VENDOR:
ret = GLXServerVendorName;
break;
case GLX_VERSION:
ret = GLXServerVersion;
break;
case GLX_EXTENSIONS:
ret = ExtensionsString;
break;
default:
break;
}
return( ret );
}
__GLXFBConfig *glxLookupFBConfig( GLXFBConfigID id )
{
int i,j;
for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
if ( __glXFBConfigs[j]->id == id)
return( __glXFBConfigs[j] );
}
return(NULL);
}
__GLXFBConfig *glxLookupFBConfigByVID( VisualID vid )
{
int i,j;
for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
if ( __glXFBConfigs[j]->associatedVisualId == vid)
return( __glXFBConfigs[j] );
}
return(NULL);
}
__GLXFBConfig *glxLookupBackEndFBConfig( GLXFBConfigID id, int screen )
{
int i;
int j;
for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
if ( __glXFBConfigs[j]->id == id)
return( __glXFBConfigs[j+screen+1] );
}
return(NULL);
}
int glxIsExtensionSupported( char *ext )
{
return( strstr(ExtensionsString, ext) != NULL );
}
|