1 /* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
3 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
4 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice including the dates of first publication and
14 * either this permission notice or a reference to
15 * http://oss.sgi.com/projects/FreeB/
16 * shall be included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * Except as contained in this notice, the name of Silicon Graphics, Inc.
27 * shall not be used in advertising or otherwise to promote the sale, use or
28 * other dealings in this Software without prior written authorization from
29 * Silicon Graphics, Inc.
32 #ifdef HAVE_DMX_CONFIG_H
33 #include <dmx-config.h>
37 #include "dmxwindow.h"
38 #include "dmxpixmap.h"
41 #include "glxserver.h"
43 #include "g_disptab.h"
44 /* #include "g_disptab_EXT.h" */
48 #include "GL/glxproto.h"
51 #include "panoramiXsrv.h"
55 * GetReqVendorPrivate - this is the equivalent of GetReq macro
56 * from Xlibint.h but it does not set the reqType field (the opcode).
57 * this is because the GL single opcodes has different naming convension
58 * the other X opcodes (ie. X_GLsop_GetFloatv).
60 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
61 #define GetReqVendorPrivate(name, req) \
63 if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
65 req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
66 req->length = (SIZEOF(x##name##Req))>>2;\
67 dpy->bufptr += SIZEOF(x##name##Req);\
70 #else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
71 #define GetReqVendorPrivate(name, req) \
73 if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
75 req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
76 req->length = (SIZEOF(x/**/name/**/Req))>>2;\
77 dpy->bufptr += SIZEOF(x/**/name/**/Req);\
81 extern Display
*GetBackEndDisplay(__GLXclientState
* cl
, int s
);
82 extern int GetCurrentBackEndTag(__GLXclientState
* cl
, GLXContextTag tag
,
85 static int swap_vec_element_size
= 0;
88 SendSwappedReply(ClientPtr client
,
89 xGLXVendorPrivReply
* reply
, char *buf
, int buf_size
)
91 __GLX_DECLARE_SWAP_VARIABLES
;
92 __GLX_SWAP_SHORT(&reply
->sequenceNumber
);
93 __GLX_SWAP_INT(&reply
->length
);
94 __GLX_SWAP_INT(&reply
->retval
);
95 __GLX_SWAP_INT(&reply
->size
);
97 if ((buf_size
== 0) && (swap_vec_element_size
> 0)) {
99 * the reply has single component - need to swap pad3
101 if (swap_vec_element_size
== 2) {
102 __GLX_SWAP_SHORT(&reply
->pad3
);
104 else if (swap_vec_element_size
== 4) {
105 __GLX_SWAP_INT(&reply
->pad3
);
106 __GLX_SWAP_INT(&reply
->pad4
);
108 else if (swap_vec_element_size
== 8) {
109 __GLX_SWAP_DOUBLE(&reply
->pad3
);
112 else if ((buf_size
> 0) && (swap_vec_element_size
> 0)) {
114 * the reply has vector of elements which needs to be swapped
116 int vsize
= buf_size
/ swap_vec_element_size
;
120 for (i
= 0; i
< vsize
; i
++) {
121 if (swap_vec_element_size
== 2) {
124 else if (swap_vec_element_size
== 4) {
127 else if (swap_vec_element_size
== 8) {
128 __GLX_SWAP_DOUBLE(p
);
131 p
+= swap_vec_element_size
;
134 __GLX_SWAP_INT(&reply
->pad3
);
135 __GLX_SWAP_INT(&reply
->pad4
);
136 __GLX_SWAP_INT(&reply
->pad5
);
137 __GLX_SWAP_INT(&reply
->pad6
);
141 WriteToClient(client
, sizeof(xGLXVendorPrivReply
), reply
);
143 WriteToClient(client
, buf_size
, buf
);
148 __glXVForwardSingleReq(__GLXclientState
* cl
, GLbyte
* pc
)
150 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
151 xGLXVendorPrivateReq
*be_req
;
158 glxc
= __glXLookupContextByTag(cl
, req
->contextTag
);
162 from_screen
= to_screen
= glxc
->pScreen
->myNum
;
165 if (!noPanoramiXExtension
) {
167 to_screen
= screenInfo
.numScreens
- 1;
171 pc
+= sz_xGLXVendorPrivateReq
;
172 buf_size
= (req
->length
<< 2) - sz_xGLXVendorPrivateReq
;
175 * just forward the request to back-end server(s)
177 for (s
= from_screen
; s
<= to_screen
; s
++) {
178 DMXScreenInfo
*dmxScreen
= &dmxScreens
[s
];
179 Display
*dpy
= GetBackEndDisplay(cl
, s
);
182 GetReqVendorPrivate(GLXVendorPrivate
, be_req
);
183 be_req
->reqType
= dmxScreen
->glxMajorOpcode
;
184 be_req
->glxCode
= req
->glxCode
;
185 be_req
->length
= req
->length
;
186 be_req
->vendorCode
= req
->vendorCode
;
187 be_req
->contextTag
= GetCurrentBackEndTag(cl
, req
->contextTag
, s
);
189 _XSend(dpy
, (const char *) pc
, buf_size
);
198 __glXVForwardPipe0WithReply(__GLXclientState
* cl
, GLbyte
* pc
)
200 ClientPtr client
= cl
->client
;
201 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
202 xGLXVendorPrivateReq
*be_req
;
203 xGLXVendorPrivReply reply
;
204 xGLXVendorPrivReply be_reply
;
209 DMXScreenInfo
*dmxScreen
;
212 glxc
= __glXLookupContextByTag(cl
, req
->contextTag
);
214 return __glXBadContext
;
217 pc
+= sz_xGLXVendorPrivateReq
;
218 buf_size
= (req
->length
<< 2) - sz_xGLXVendorPrivateReq
;
220 dmxScreen
= &dmxScreens
[glxc
->pScreen
->myNum
];
221 dpy
= GetBackEndDisplay(cl
, glxc
->pScreen
->myNum
);
224 * send the request to the first back-end server
227 GetReqVendorPrivate(GLXVendorPrivate
, be_req
);
228 be_req
->reqType
= dmxScreen
->glxMajorOpcode
;
229 be_req
->glxCode
= req
->glxCode
;
230 be_req
->length
= req
->length
;
231 be_req
->vendorCode
= req
->vendorCode
;
233 GetCurrentBackEndTag(cl
, req
->contextTag
, glxc
->pScreen
->myNum
);
235 _XSend(dpy
, (const char *) pc
, buf_size
);
238 * get the reply from the back-end server
240 _XReply(dpy
, (xReply
*) &be_reply
, 0, False
);
241 be_buf_size
= be_reply
.length
<< 2;
242 if (be_buf_size
> 0) {
243 be_buf
= (char *) malloc(be_buf_size
);
245 _XRead(dpy
, be_buf
, be_buf_size
);
248 /* Throw data on the floor */
249 _XEatDataWords(dpy
, be_reply
.length
);
258 * send the reply to the client
260 memcpy(&reply
, &be_reply
, sz_xGLXVendorPrivReply
);
261 reply
.type
= X_Reply
;
262 reply
.sequenceNumber
= client
->sequence
;
264 if (client
->swapped
) {
265 SendSwappedReply(client
, &reply
, be_buf
, be_buf_size
);
268 WriteToClient(client
, sizeof(xGLXVendorPrivReply
), &reply
);
270 WriteToClient(client
, be_buf_size
, be_buf
);
280 __glXVForwardAllWithReply(__GLXclientState
* cl
, GLbyte
* pc
)
282 ClientPtr client
= cl
->client
;
283 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
284 xGLXVendorPrivateReq
*be_req
;
285 xGLXVendorPrivReply reply
;
286 xGLXVendorPrivReply be_reply
;
295 DMXScreenInfo
*dmxScreen
;
298 glxc
= __glXLookupContextByTag(cl
, req
->contextTag
);
302 from_screen
= to_screen
= glxc
->pScreen
->myNum
;
305 if (!noPanoramiXExtension
) {
307 to_screen
= screenInfo
.numScreens
- 1;
311 pc
+= sz_xGLXVendorPrivateReq
;
312 buf_size
= (req
->length
<< 2) - sz_xGLXVendorPrivateReq
;
315 * send the request to the first back-end server(s)
317 for (s
= to_screen
; s
>= from_screen
; s
--) {
318 dmxScreen
= &dmxScreens
[s
];
319 dpy
= GetBackEndDisplay(cl
, s
);
322 GetReqVendorPrivate(GLXVendorPrivate
, be_req
);
323 be_req
->reqType
= dmxScreen
->glxMajorOpcode
;
324 be_req
->glxCode
= req
->glxCode
;
325 be_req
->length
= req
->length
;
326 be_req
->vendorCode
= req
->vendorCode
;
327 be_req
->contextTag
= GetCurrentBackEndTag(cl
, req
->contextTag
, s
);
329 _XSend(dpy
, (const char *) pc
, buf_size
);
332 * get the reply from the back-end server
334 _XReply(dpy
, (xReply
*) &be_reply
, 0, False
);
335 if (s
== from_screen
) {
336 /* Save data from last reply to send on to client */
337 be_buf_size
= be_reply
.length
<< 2;
338 if (be_buf_size
> 0) {
339 be_buf
= malloc(be_buf_size
);
341 _XRead(dpy
, be_buf
, be_buf_size
);
344 /* Throw data on the floor */
345 _XEatDataWords(dpy
, be_reply
.length
);
351 /* Just discard data from all replies before the last one */
352 if (be_reply
.length
> 0)
353 _XEatDataWords(dpy
, be_reply
.length
);
361 * send the reply to the client
363 memcpy(&reply
, &be_reply
, sz_xGLXVendorPrivReply
);
364 reply
.type
= X_Reply
;
365 reply
.sequenceNumber
= client
->sequence
;
367 if (client
->swapped
) {
368 SendSwappedReply(client
, &reply
, be_buf
, be_buf_size
);
371 WriteToClient(client
, sizeof(xGLXVendorPrivReply
), &reply
);
373 WriteToClient(client
, be_buf_size
, be_buf
);
383 __glXVForwardSingleReqSwap(__GLXclientState
* cl
, GLbyte
* pc
)
385 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
387 __GLX_DECLARE_SWAP_VARIABLES
;
389 __GLX_SWAP_SHORT(&req
->length
);
390 __GLX_SWAP_INT(&req
->vendorCode
);
391 __GLX_SWAP_INT(&req
->contextTag
);
393 swap_vec_element_size
= 0;
395 return (__glXVForwardSingleReq(cl
, pc
));
399 __glXVForwardPipe0WithReplySwap(__GLXclientState
* cl
, GLbyte
* pc
)
401 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
403 __GLX_DECLARE_SWAP_VARIABLES
;
404 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
406 __GLX_SWAP_SHORT(&req
->length
);
407 __GLX_SWAP_INT(&req
->vendorCode
);
408 __GLX_SWAP_INT(&req
->contextTag
);
410 swap_vec_element_size
= 0;
413 * swap extra data in request - assuming all data
414 * (if available) are arrays of 4 bytes components !
416 if (req
->length
> sz_xGLXVendorPrivateReq
/ 4) {
417 int *data
= (int *) (req
+ 1);
418 int count
= req
->length
- sz_xGLXVendorPrivateReq
/ 4;
420 __GLX_SWAP_INT_ARRAY(data
, count
);
423 return (__glXVForwardPipe0WithReply(cl
, pc
));
427 __glXVForwardPipe0WithReplySwapsv(__GLXclientState
* cl
, GLbyte
* pc
)
429 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
431 __GLX_DECLARE_SWAP_VARIABLES
;
432 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
434 __GLX_SWAP_SHORT(&req
->length
);
435 __GLX_SWAP_INT(&req
->vendorCode
);
436 __GLX_SWAP_INT(&req
->contextTag
);
438 swap_vec_element_size
= 2;
441 * swap extra data in request - assuming all data
442 * (if available) are arrays of 4 bytes components !
444 if (req
->length
> sz_xGLXVendorPrivateReq
/ 4) {
445 int *data
= (int *) (req
+ 1);
446 int count
= req
->length
- sz_xGLXVendorPrivateReq
/ 4;
448 __GLX_SWAP_INT_ARRAY(data
, count
);
451 return (__glXVForwardPipe0WithReply(cl
, pc
));
455 __glXVForwardPipe0WithReplySwapiv(__GLXclientState
* cl
, GLbyte
* pc
)
457 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
459 __GLX_DECLARE_SWAP_VARIABLES
;
460 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
462 __GLX_SWAP_SHORT(&req
->length
);
463 __GLX_SWAP_INT(&req
->vendorCode
);
464 __GLX_SWAP_INT(&req
->contextTag
);
466 swap_vec_element_size
= 4;
469 * swap extra data in request - assuming all data
470 * (if available) are arrays of 4 bytes components !
472 if (req
->length
> sz_xGLXVendorPrivateReq
/ 4) {
473 int *data
= (int *) (req
+ 1);
474 int count
= req
->length
- sz_xGLXVendorPrivateReq
/ 4;
476 __GLX_SWAP_INT_ARRAY(data
, count
);
479 return (__glXVForwardPipe0WithReply(cl
, pc
));
483 __glXVForwardPipe0WithReplySwapdv(__GLXclientState
* cl
, GLbyte
* pc
)
485 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
487 __GLX_DECLARE_SWAP_VARIABLES
;
488 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
490 __GLX_SWAP_SHORT(&req
->length
);
491 __GLX_SWAP_INT(&req
->vendorCode
);
492 __GLX_SWAP_INT(&req
->contextTag
);
494 swap_vec_element_size
= 8;
497 * swap extra data in request - assuming all data
498 * (if available) are arrays of 4 bytes components !
500 if (req
->length
> sz_xGLXVendorPrivateReq
/ 4) {
501 int *data
= (int *) (req
+ 1);
502 int count
= req
->length
- sz_xGLXVendorPrivateReq
/ 4;
504 __GLX_SWAP_INT_ARRAY(data
, count
);
507 return (__glXVForwardPipe0WithReply(cl
, pc
));
511 __glXVForwardAllWithReplySwap(__GLXclientState
* cl
, GLbyte
* pc
)
513 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
515 __GLX_DECLARE_SWAP_VARIABLES
;
516 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
518 __GLX_SWAP_SHORT(&req
->length
);
519 __GLX_SWAP_INT(&req
->vendorCode
);
520 __GLX_SWAP_INT(&req
->contextTag
);
522 swap_vec_element_size
= 0;
525 * swap extra data in request - assuming all data
526 * (if available) are arrays of 4 bytes components !
528 if (req
->length
> sz_xGLXVendorPrivateReq
/ 4) {
529 int *data
= (int *) (req
+ 1);
530 int count
= req
->length
- sz_xGLXVendorPrivateReq
/ 4;
532 __GLX_SWAP_INT_ARRAY(data
, count
);
535 return (__glXVForwardAllWithReply(cl
, pc
));
539 __glXVForwardAllWithReplySwapsv(__GLXclientState
* cl
, GLbyte
* pc
)
541 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
543 __GLX_DECLARE_SWAP_VARIABLES
;
544 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
546 __GLX_SWAP_SHORT(&req
->length
);
547 __GLX_SWAP_INT(&req
->vendorCode
);
548 __GLX_SWAP_INT(&req
->contextTag
);
550 swap_vec_element_size
= 2;
553 * swap extra data in request - assuming all data
554 * (if available) are arrays of 4 bytes components !
556 if (req
->length
> sz_xGLXVendorPrivateReq
/ 4) {
557 int *data
= (int *) (req
+ 1);
558 int count
= req
->length
- sz_xGLXVendorPrivateReq
/ 4;
560 __GLX_SWAP_INT_ARRAY(data
, count
);
563 return (__glXVForwardAllWithReply(cl
, pc
));
567 __glXVForwardAllWithReplySwapiv(__GLXclientState
* cl
, GLbyte
* pc
)
569 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
571 __GLX_DECLARE_SWAP_VARIABLES
;
572 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
574 __GLX_SWAP_SHORT(&req
->length
);
575 __GLX_SWAP_INT(&req
->vendorCode
);
576 __GLX_SWAP_INT(&req
->contextTag
);
578 swap_vec_element_size
= 4;
581 * swap extra data in request - assuming all data
582 * (if available) are arrays of 4 bytes components !
584 if (req
->length
> sz_xGLXVendorPrivateReq
/ 4) {
585 int *data
= (int *) (req
+ 1);
586 int count
= req
->length
- sz_xGLXVendorPrivateReq
/ 4;
588 __GLX_SWAP_INT_ARRAY(data
, count
);
591 return (__glXVForwardAllWithReply(cl
, pc
));
595 __glXVForwardAllWithReplySwapdv(__GLXclientState
* cl
, GLbyte
* pc
)
597 xGLXVendorPrivateReq
*req
= (xGLXVendorPrivateReq
*) pc
;
599 __GLX_DECLARE_SWAP_VARIABLES
;
600 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
602 __GLX_SWAP_SHORT(&req
->length
);
603 __GLX_SWAP_INT(&req
->vendorCode
);
604 __GLX_SWAP_INT(&req
->contextTag
);
606 swap_vec_element_size
= 8;
609 * swap extra data in request - assuming all data
610 * (if available) are arrays of 4 bytes components !
612 if (req
->length
> sz_xGLXVendorPrivateReq
/ 4) {
613 int *data
= (int *) (req
+ 1);
614 int count
= req
->length
- sz_xGLXVendorPrivateReq
/ 4;
616 __GLX_SWAP_INT_ARRAY(data
, count
);
619 return (__glXVForwardAllWithReply(cl
, pc
));