2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
31 #include "glxserver.h"
33 #include <GL/glxtokens.h>
34 #include <g_disptab.h>
35 #include <pixmapstr.h>
36 #include <windowstr.h>
40 #include "glxvendor.h"
42 extern int glxIsExtensionSupported(char *ext
);
44 int __glXSwapGetFBConfigsSGIX(__GLXclientState
* cl
, GLbyte
* pc
);
46 /************************************************************************/
49 ** Byteswapping versions of GLX commands. In most cases they just swap
50 ** the incoming arguments and then call the unswapped routine. For commands
51 ** that have replies, a separate swapping routine for the reply is provided;
52 ** it is called at the end of the unswapped routine.
56 __glXSwapCreateContext(__GLXclientState
* cl
, GLbyte
* pc
)
58 xGLXCreateContextReq
*req
= (xGLXCreateContextReq
*) pc
;
60 __GLX_DECLARE_SWAP_VARIABLES
;
62 __GLX_SWAP_SHORT(&req
->length
);
63 __GLX_SWAP_INT(&req
->context
);
64 __GLX_SWAP_INT(&req
->visual
);
65 __GLX_SWAP_INT(&req
->screen
);
66 __GLX_SWAP_INT(&req
->shareList
);
68 return __glXCreateContext(cl
, pc
);
72 __glXSwapCreateNewContext(__GLXclientState
* cl
, GLbyte
* pc
)
74 xGLXCreateNewContextReq
*req
= (xGLXCreateNewContextReq
*) pc
;
76 __GLX_DECLARE_SWAP_VARIABLES
;
78 __GLX_SWAP_SHORT(&req
->length
);
79 __GLX_SWAP_INT(&req
->context
);
80 __GLX_SWAP_INT(&req
->fbconfig
);
81 __GLX_SWAP_INT(&req
->screen
);
82 __GLX_SWAP_INT(&req
->shareList
);
84 return __glXCreateNewContext(cl
, pc
);
88 __glXSwapCreateContextWithConfigSGIX(__GLXclientState
* cl
, GLbyte
* pc
)
90 xGLXCreateContextWithConfigSGIXReq
*req
=
91 (xGLXCreateContextWithConfigSGIXReq
*) pc
;
92 __GLX_DECLARE_SWAP_VARIABLES
;
94 __GLX_SWAP_SHORT(&req
->length
);
95 __GLX_SWAP_INT(&req
->context
);
96 __GLX_SWAP_INT(&req
->fbconfig
);
97 __GLX_SWAP_INT(&req
->screen
);
98 __GLX_SWAP_INT(&req
->shareList
);
100 return __glXCreateContextWithConfigSGIX(cl
, pc
);
104 __glXSwapQueryMaxSwapBarriersSGIX(__GLXclientState
* cl
, GLbyte
* pc
)
106 xGLXQueryMaxSwapBarriersSGIXReq
*req
=
107 (xGLXQueryMaxSwapBarriersSGIXReq
*) pc
;
108 __GLX_DECLARE_SWAP_VARIABLES
;
110 __GLX_SWAP_SHORT(&req
->length
);
111 __GLX_SWAP_INT(&req
->screen
);
113 return __glXQueryMaxSwapBarriersSGIX(cl
, pc
);
117 __glXSwapBindSwapBarrierSGIX(__GLXclientState
* cl
, GLbyte
* pc
)
119 xGLXBindSwapBarrierSGIXReq
*req
= (xGLXBindSwapBarrierSGIXReq
*) pc
;
121 __GLX_DECLARE_SWAP_VARIABLES
;
123 __GLX_SWAP_SHORT(&req
->length
);
124 __GLX_SWAP_INT(&req
->drawable
);
125 __GLX_SWAP_INT(&req
->barrier
);
127 return __glXBindSwapBarrierSGIX(cl
, pc
);
131 __glXSwapJoinSwapGroupSGIX(__GLXclientState
* cl
, GLbyte
* pc
)
133 xGLXJoinSwapGroupSGIXReq
*req
= (xGLXJoinSwapGroupSGIXReq
*) pc
;
135 __GLX_DECLARE_SWAP_VARIABLES
;
137 __GLX_SWAP_SHORT(&req
->length
);
138 __GLX_SWAP_INT(&req
->drawable
);
139 __GLX_SWAP_INT(&req
->member
);
141 return __glXJoinSwapGroupSGIX(cl
, pc
);
145 __glXSwapDestroyContext(__GLXclientState
* cl
, GLbyte
* pc
)
147 xGLXDestroyContextReq
*req
= (xGLXDestroyContextReq
*) pc
;
149 __GLX_DECLARE_SWAP_VARIABLES
;
151 __GLX_SWAP_SHORT(&req
->length
);
152 __GLX_SWAP_INT(&req
->context
);
154 return __glXDestroyContext(cl
, pc
);
158 __glXSwapMakeCurrent(__GLXclientState
* cl
, GLbyte
* pc
)
160 xGLXMakeCurrentReq
*req
= (xGLXMakeCurrentReq
*) pc
;
162 __GLX_DECLARE_SWAP_VARIABLES
;
164 __GLX_SWAP_SHORT(&req
->length
);
165 __GLX_SWAP_INT(&req
->drawable
);
166 __GLX_SWAP_INT(&req
->context
);
167 __GLX_SWAP_INT(&req
->oldContextTag
);
169 return __glXMakeCurrent(cl
, pc
);
173 __glXSwapMakeContextCurrent(__GLXclientState
* cl
, GLbyte
* pc
)
175 xGLXMakeContextCurrentReq
*req
= (xGLXMakeContextCurrentReq
*) pc
;
177 __GLX_DECLARE_SWAP_VARIABLES
;
179 __GLX_SWAP_SHORT(&req
->length
);
180 __GLX_SWAP_INT(&req
->drawable
);
181 __GLX_SWAP_INT(&req
->readdrawable
);
182 __GLX_SWAP_INT(&req
->context
);
183 __GLX_SWAP_INT(&req
->oldContextTag
);
185 return __glXMakeContextCurrent(cl
, pc
);
189 __glXSwapMakeCurrentReadSGI(__GLXclientState
* cl
, GLbyte
* pc
)
191 xGLXMakeCurrentReadSGIReq
*req
= (xGLXMakeCurrentReadSGIReq
*) pc
;
193 __GLX_DECLARE_SWAP_VARIABLES
;
195 __GLX_SWAP_SHORT(&req
->length
);
196 __GLX_SWAP_INT(&req
->drawable
);
197 __GLX_SWAP_INT(&req
->readable
);
198 __GLX_SWAP_INT(&req
->context
);
199 __GLX_SWAP_INT(&req
->oldContextTag
);
201 return __glXMakeCurrentReadSGI(cl
, pc
);
205 __glXSwapIsDirect(__GLXclientState
* cl
, GLbyte
* pc
)
207 xGLXIsDirectReq
*req
= (xGLXIsDirectReq
*) pc
;
209 __GLX_DECLARE_SWAP_VARIABLES
;
211 __GLX_SWAP_SHORT(&req
->length
);
212 __GLX_SWAP_INT(&req
->context
);
214 return __glXIsDirect(cl
, pc
);
218 __glXSwapQueryVersion(__GLXclientState
* cl
, GLbyte
* pc
)
220 xGLXQueryVersionReq
*req
= (xGLXQueryVersionReq
*) pc
;
222 __GLX_DECLARE_SWAP_VARIABLES
;
224 __GLX_SWAP_SHORT(&req
->length
);
225 __GLX_SWAP_INT(&req
->majorVersion
);
226 __GLX_SWAP_INT(&req
->minorVersion
);
228 return __glXQueryVersion(cl
, pc
);
232 __glXSwapWaitGL(__GLXclientState
* cl
, GLbyte
* pc
)
234 xGLXWaitGLReq
*req
= (xGLXWaitGLReq
*) pc
;
236 __GLX_DECLARE_SWAP_VARIABLES
;
238 __GLX_SWAP_SHORT(&req
->length
);
239 __GLX_SWAP_INT(&req
->contextTag
);
241 return __glXWaitGL(cl
, pc
);
245 __glXSwapWaitX(__GLXclientState
* cl
, GLbyte
* pc
)
247 xGLXWaitXReq
*req
= (xGLXWaitXReq
*) pc
;
249 __GLX_DECLARE_SWAP_VARIABLES
;
251 __GLX_SWAP_SHORT(&req
->length
);
252 __GLX_SWAP_INT(&req
->contextTag
);
254 return __glXWaitX(cl
, pc
);
258 __glXSwapCopyContext(__GLXclientState
* cl
, GLbyte
* pc
)
260 xGLXCopyContextReq
*req
= (xGLXCopyContextReq
*) pc
;
262 __GLX_DECLARE_SWAP_VARIABLES
;
264 __GLX_SWAP_SHORT(&req
->length
);
265 __GLX_SWAP_INT(&req
->source
);
266 __GLX_SWAP_INT(&req
->dest
);
267 __GLX_SWAP_INT(&req
->mask
);
269 return __glXCopyContext(cl
, pc
);
273 __glXSwapGetVisualConfigs(__GLXclientState
* cl
, GLbyte
* pc
)
275 ClientPtr client
= cl
->client
;
276 xGLXGetVisualConfigsReq
*req
= (xGLXGetVisualConfigsReq
*) pc
;
277 xGLXGetVisualConfigsReply reply
;
278 __GLXscreenInfo
*pGlxScreen
;
279 __GLXvisualConfig
*pGlxVisual
;
280 CARD32 buf
[__GLX_TOTAL_CONFIG
];
284 __GLX_DECLARE_SWAP_VARIABLES
;
285 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
287 __GLX_SWAP_INT(&req
->screen
);
288 screen
= req
->screen
;
289 if (screen
>= screenInfo
.numScreens
) {
290 /* The client library must send a valid screen number. */
291 client
->errorValue
= screen
;
294 pGlxScreen
= &__glXActiveScreens
[screen
];
296 reply
= (xGLXGetVisualConfigsReply
) {
298 .sequenceNumber
= client
->sequence
,
299 .length
= (pGlxScreen
->numGLXVisuals
* __GLX_SIZE_CARD32
*
300 __GLX_TOTAL_CONFIG
) >> 2,
301 .numVisuals
= pGlxScreen
->numGLXVisuals
,
302 .numProps
= __GLX_TOTAL_CONFIG
305 __GLX_SWAP_SHORT(&reply
.sequenceNumber
);
306 __GLX_SWAP_INT(&reply
.length
);
307 __GLX_SWAP_INT(&reply
.numVisuals
);
308 __GLX_SWAP_INT(&reply
.numProps
);
309 WriteToClient(client
, sz_xGLXGetVisualConfigsReply
, &reply
);
311 for (i
= 0; i
< pGlxScreen
->numVisuals
; i
++) {
312 pGlxVisual
= &pGlxScreen
->pGlxVisual
[i
];
313 if (!pGlxScreen
->isGLXvis
[i
] || pGlxVisual
->vid
== 0) {
314 /* not a usable visual */
318 buf
[p
++] = pGlxVisual
->vid
;
319 buf
[p
++] = pGlxVisual
->class;
320 buf
[p
++] = pGlxVisual
->rgba
;
322 buf
[p
++] = pGlxVisual
->redSize
;
323 buf
[p
++] = pGlxVisual
->greenSize
;
324 buf
[p
++] = pGlxVisual
->blueSize
;
325 buf
[p
++] = pGlxVisual
->alphaSize
;
326 buf
[p
++] = pGlxVisual
->accumRedSize
;
327 buf
[p
++] = pGlxVisual
->accumGreenSize
;
328 buf
[p
++] = pGlxVisual
->accumBlueSize
;
329 buf
[p
++] = pGlxVisual
->accumAlphaSize
;
331 buf
[p
++] = pGlxVisual
->doubleBuffer
;
332 buf
[p
++] = pGlxVisual
->stereo
;
334 buf
[p
++] = pGlxVisual
->bufferSize
;
335 buf
[p
++] = pGlxVisual
->depthSize
;
336 buf
[p
++] = pGlxVisual
->stencilSize
;
337 buf
[p
++] = pGlxVisual
->auxBuffers
;
338 buf
[p
++] = pGlxVisual
->level
;
340 ** Add token/value pairs for extensions.
342 buf
[p
++] = GLX_VISUAL_CAVEAT_EXT
;
343 buf
[p
++] = pGlxVisual
->visualRating
;
344 buf
[p
++] = GLX_TRANSPARENT_TYPE_EXT
;
345 buf
[p
++] = pGlxVisual
->transparentPixel
;
346 buf
[p
++] = GLX_TRANSPARENT_RED_VALUE_EXT
;
347 buf
[p
++] = pGlxVisual
->transparentRed
;
348 buf
[p
++] = GLX_TRANSPARENT_GREEN_VALUE_EXT
;
349 buf
[p
++] = pGlxVisual
->transparentGreen
;
350 buf
[p
++] = GLX_TRANSPARENT_BLUE_VALUE_EXT
;
351 buf
[p
++] = pGlxVisual
->transparentBlue
;
352 buf
[p
++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT
;
353 buf
[p
++] = pGlxVisual
->transparentAlpha
;
354 buf
[p
++] = GLX_TRANSPARENT_INDEX_VALUE_EXT
;
355 buf
[p
++] = pGlxVisual
->transparentIndex
;
357 __GLX_SWAP_INT_ARRAY(buf
, __GLX_TOTAL_CONFIG
);
358 WriteToClient(client
, __GLX_SIZE_CARD32
* __GLX_TOTAL_CONFIG
, buf
);
364 __glXSwapCreateGLXPixmap(__GLXclientState
* cl
, GLbyte
* pc
)
366 xGLXCreateGLXPixmapReq
*req
= (xGLXCreateGLXPixmapReq
*) pc
;
368 __GLX_DECLARE_SWAP_VARIABLES
;
370 __GLX_SWAP_SHORT(&req
->length
);
371 __GLX_SWAP_INT(&req
->screen
);
372 __GLX_SWAP_INT(&req
->visual
);
373 __GLX_SWAP_INT(&req
->pixmap
);
374 __GLX_SWAP_INT(&req
->glxpixmap
);
376 return __glXCreateGLXPixmap(cl
, pc
);
380 __glXSwapCreatePixmap(__GLXclientState
* cl
, GLbyte
* pc
)
382 xGLXCreatePixmapReq
*req
= (xGLXCreatePixmapReq
*) pc
;
384 __GLX_DECLARE_SWAP_VARIABLES
;
386 __GLX_SWAP_SHORT(&req
->length
);
387 __GLX_SWAP_INT(&req
->screen
);
388 __GLX_SWAP_INT(&req
->fbconfig
);
389 __GLX_SWAP_INT(&req
->pixmap
);
390 __GLX_SWAP_INT(&req
->glxpixmap
);
391 __GLX_SWAP_INT(&req
->numAttribs
);
393 return __glXCreatePixmap(cl
, pc
);
397 __glXSwapDestroyGLXPixmap(__GLXclientState
* cl
, GLbyte
* pc
)
399 xGLXDestroyGLXPixmapReq
*req
= (xGLXDestroyGLXPixmapReq
*) pc
;
401 __GLX_DECLARE_SWAP_VARIABLES
;
403 __GLX_SWAP_SHORT(&req
->length
);
404 __GLX_SWAP_INT(&req
->glxpixmap
);
406 return __glXDestroyGLXPixmap(cl
, pc
);
410 __glXSwapSwapBuffers(__GLXclientState
* cl
, GLbyte
* pc
)
412 xGLXSwapBuffersReq
*req
= (xGLXSwapBuffersReq
*) pc
;
414 __GLX_DECLARE_SWAP_VARIABLES
;
416 __GLX_SWAP_SHORT(&req
->length
);
417 __GLX_SWAP_INT(&req
->contextTag
);
418 __GLX_SWAP_INT(&req
->drawable
);
420 return __glXSwapBuffers(cl
, pc
);
424 __glXSwapUseXFont(__GLXclientState
* cl
, GLbyte
* pc
)
426 xGLXUseXFontReq
*req
= (xGLXUseXFontReq
*) pc
;
428 __GLX_DECLARE_SWAP_VARIABLES
;
430 __GLX_SWAP_SHORT(&req
->length
);
431 __GLX_SWAP_INT(&req
->contextTag
);
432 __GLX_SWAP_INT(&req
->font
);
433 __GLX_SWAP_INT(&req
->first
);
434 __GLX_SWAP_INT(&req
->count
);
435 __GLX_SWAP_INT(&req
->listBase
);
437 return __glXUseXFont(cl
, pc
);
441 __glXSwapQueryExtensionsString(__GLXclientState
* cl
, GLbyte
* pc
)
443 xGLXQueryExtensionsStringReq
*req
= NULL
;
445 __GLX_DECLARE_SWAP_VARIABLES
;
447 __GLX_SWAP_SHORT(&req
->length
);
448 __GLX_SWAP_INT(&req
->screen
);
450 return __glXQueryExtensionsString(cl
, pc
);
454 __glXSwapQueryServerString(__GLXclientState
* cl
, GLbyte
* pc
)
456 xGLXQueryServerStringReq
*req
= (xGLXQueryServerStringReq
*) pc
;
458 __GLX_DECLARE_SWAP_VARIABLES
;
460 __GLX_SWAP_SHORT(&req
->length
);
461 __GLX_SWAP_INT(&req
->screen
);
462 __GLX_SWAP_INT(&req
->name
);
464 return __glXQueryServerString(cl
, pc
);
468 __glXSwapClientInfo(__GLXclientState
* cl
, GLbyte
* pc
)
470 xGLXClientInfoReq
*req
= (xGLXClientInfoReq
*) pc
;
472 __GLX_DECLARE_SWAP_VARIABLES
;
474 __GLX_SWAP_SHORT(&req
->length
);
475 __GLX_SWAP_INT(&req
->major
);
476 __GLX_SWAP_INT(&req
->minor
);
477 __GLX_SWAP_INT(&req
->numbytes
);
479 return __glXClientInfo(cl
, pc
);
483 __glXSwapQueryContextInfoEXT(__GLXclientState
* cl
, char *pc
)
485 xGLXQueryContextInfoEXTReq
*req
= (xGLXQueryContextInfoEXTReq
*) pc
;
487 __GLX_DECLARE_SWAP_VARIABLES
;
489 __GLX_SWAP_SHORT(&req
->length
);
490 __GLX_SWAP_INT(&req
->context
);
492 return __glXQueryContextInfoEXT(cl
, (GLbyte
*) pc
);
495 /************************************************************************/
502 __glXSwapMakeCurrentReply(ClientPtr client
, xGLXMakeCurrentReadSGIReply
* reply
)
504 __GLX_DECLARE_SWAP_VARIABLES
;
505 __GLX_SWAP_SHORT(&reply
->sequenceNumber
);
506 __GLX_SWAP_INT(&reply
->length
);
507 __GLX_SWAP_INT(&reply
->contextTag
);
508 __GLX_SWAP_INT(&reply
->writeVid
);
509 __GLX_SWAP_INT(&reply
->writeType
);
510 __GLX_SWAP_INT(&reply
->readVid
);
511 __GLX_SWAP_INT(&reply
->readType
);
512 WriteToClient(client
, sz_xGLXMakeCurrentReadSGIReply
, reply
);
516 __glXSwapIsDirectReply(ClientPtr client
, xGLXIsDirectReply
* reply
)
518 __GLX_DECLARE_SWAP_VARIABLES
;
519 __GLX_SWAP_SHORT(&reply
->sequenceNumber
);
520 __GLX_SWAP_INT(&reply
->length
);
521 WriteToClient(client
, sz_xGLXIsDirectReply
, reply
);
525 __glXSwapQueryVersionReply(ClientPtr client
, xGLXQueryVersionReply
* reply
)
527 __GLX_DECLARE_SWAP_VARIABLES
;
528 __GLX_SWAP_SHORT(&reply
->sequenceNumber
);
529 __GLX_SWAP_INT(&reply
->length
);
530 __GLX_SWAP_INT(&reply
->majorVersion
);
531 __GLX_SWAP_INT(&reply
->minorVersion
);
532 WriteToClient(client
, sz_xGLXQueryVersionReply
, reply
);
536 glxSwapQueryExtensionsStringReply(ClientPtr client
,
537 xGLXQueryExtensionsStringReply
* reply
,
540 int length
= reply
->length
;
542 __GLX_DECLARE_SWAP_VARIABLES
;
543 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
544 __GLX_SWAP_SHORT(&reply
->sequenceNumber
);
545 __GLX_SWAP_INT(&reply
->length
);
546 __GLX_SWAP_INT(&reply
->n
);
547 WriteToClient(client
, sz_xGLXQueryExtensionsStringReply
, reply
);
548 __GLX_SWAP_INT_ARRAY((int *) buf
, length
);
549 WriteToClient(client
, length
<< 2, buf
);
553 glxSwapQueryServerStringReply(ClientPtr client
,
554 xGLXQueryServerStringReply
* reply
, char *buf
)
556 int length
= reply
->length
;
558 __GLX_DECLARE_SWAP_VARIABLES
;
559 __GLX_SWAP_SHORT(&reply
->sequenceNumber
);
560 __GLX_SWAP_INT(&reply
->length
);
561 __GLX_SWAP_INT(&reply
->n
);
562 WriteToClient(client
, sz_xGLXQueryServerStringReply
, reply
);
563 /** no swap is needed for an array of chars **/
564 /* __GLX_SWAP_INT_ARRAY((int *)buf, length); */
565 WriteToClient(client
, length
<< 2, buf
);
569 __glXSwapQueryContextInfoEXTReply(ClientPtr client
,
570 xGLXQueryContextInfoEXTReply
* reply
,
573 int length
= reply
->length
;
575 __GLX_DECLARE_SWAP_VARIABLES
;
576 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
577 __GLX_SWAP_SHORT(&reply
->sequenceNumber
);
578 __GLX_SWAP_INT(&reply
->length
);
579 __GLX_SWAP_INT(&reply
->n
);
580 WriteToClient(client
, sz_xGLXQueryContextInfoEXTReply
, reply
);
581 __GLX_SWAP_INT_ARRAY((int *) buf
, length
);
582 WriteToClient(client
, length
<< 2, buf
);
586 __glXSwapQueryContextReply(ClientPtr client
,
587 xGLXQueryContextReply
* reply
, int *buf
)
589 int length
= reply
->length
;
591 __GLX_DECLARE_SWAP_VARIABLES
;
592 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
593 __GLX_SWAP_SHORT(&reply
->sequenceNumber
);
594 __GLX_SWAP_INT(&reply
->length
);
595 __GLX_SWAP_INT(&reply
->n
);
596 WriteToClient(client
, sz_xGLXQueryContextReply
, reply
);
597 __GLX_SWAP_INT_ARRAY((int *) buf
, length
);
598 WriteToClient(client
, length
<< 2, buf
);
602 __glXSwapGetDrawableAttributesReply(ClientPtr client
,
603 xGLXGetDrawableAttributesReply
* reply
,
606 __GLX_DECLARE_SWAP_VARIABLES
;
607 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
608 __GLX_SWAP_SHORT(&reply
->sequenceNumber
);
609 __GLX_SWAP_INT(&reply
->length
);
610 __GLX_SWAP_INT(&reply
->numAttribs
);
611 __GLX_SWAP_INT_ARRAY(buf
, reply
->length
);
612 WriteToClient(client
, sz_xGLXGetDrawableAttributesReply
, reply
);
613 WriteToClient(client
, reply
->length
<< 2, buf
);
617 __glXSwapQueryMaxSwapBarriersSGIXReply(ClientPtr client
,
618 xGLXQueryMaxSwapBarriersSGIXReply
*
621 __GLX_DECLARE_SWAP_VARIABLES
;
622 __GLX_SWAP_SHORT(&reply
->sequenceNumber
);
623 __GLX_SWAP_INT(&reply
->length
);
624 __GLX_SWAP_INT(&reply
->max
);
625 WriteToClient(client
, sz_xGLXQueryMaxSwapBarriersSGIXReply
, reply
);
628 /************************************************************************/
631 ** Render and Renderlarge are not in the GLX API. They are used by the GLX
632 ** client library to send batches of GL rendering commands.
636 __glXSwapRender(__GLXclientState
* cl
, GLbyte
* pc
)
640 __GLXrenderHeader
*hdr
;
641 ClientPtr client
= cl
->client
;
643 __GLX_DECLARE_SWAP_VARIABLES
;
644 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
647 ** NOTE: much of this code also appears in the nonswapping version of this
648 ** routine, __glXRender(). Any changes made here should also be
652 req
= (xGLXRenderReq
*) pc
;
653 __GLX_SWAP_SHORT(&req
->length
);
654 __GLX_SWAP_INT(&req
->contextTag
);
656 pc
+= sz_xGLXRenderReq
;
657 left
= (req
->length
<< 2) - sz_xGLXRenderReq
;
659 void (*proc
) (GLbyte
*);
663 ** Verify that the header length and the overall length agree.
664 ** Also, each command must be word aligned.
666 hdr
= (__GLXrenderHeader
*) pc
;
667 __GLX_SWAP_SHORT(&hdr
->length
);
668 __GLX_SWAP_SHORT(&hdr
->opcode
);
671 * call the command procedure to swap any arguments
673 opcode
= hdr
->opcode
;
674 if ((opcode
>= __GLX_MIN_RENDER_OPCODE
) &&
675 (opcode
<= __GLX_MAX_RENDER_OPCODE
)) {
676 proc
= __glXSwapRenderTable
[opcode
];
677 #if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
679 else if ((opcode
>= __GLX_MIN_RENDER_OPCODE_EXT
) &&
680 (opcode
<= __GLX_MAX_RENDER_OPCODE_EXT
)) {
681 int index
= opcode
- __GLX_MIN_RENDER_OPCODE_EXT
;
682 __GLXRenderSwapInfo
*info
= &__glXSwapRenderTable_EXT
[index
];
684 if (info
->swapfunc
) {
685 proc
= info
->swapfunc
;
689 if (info
->elem_size
== 4 && info
->nelems
> 0) {
690 __GLX_SWAP_INT_ARRAY((int *) (pc
+ __GLX_RENDER_HDR_SIZE
),
693 else if (info
->elem_size
== 2 && info
->nelems
> 0) {
694 __GLX_SWAP_SHORT_ARRAY((short *) (pc
+
695 __GLX_RENDER_HDR_SIZE
),
698 else if (info
->elem_size
== 8 && info
->nelems
> 0) {
699 __GLX_SWAP_DOUBLE_ARRAY((double *) (pc
+
700 __GLX_RENDER_HDR_SIZE
),
704 #endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
707 client
->errorValue
= 0;
708 return __glXBadRenderRequest
;
712 (*proc
) (pc
+ __GLX_RENDER_HDR_SIZE
);
715 * proceed to the next command
721 return __glXRender(cl
, (GLbyte
*) req
);
725 ** Execute a large rendering request (one that spans multiple X requests).
728 __glXSwapRenderLarge(__GLXclientState
* cl
, GLbyte
* pc
)
730 ClientPtr client
= cl
->client
;
731 xGLXRenderLargeReq
*req
;
732 __GLXrenderLargeHeader
*hdr
;
734 __GLX_DECLARE_SWAP_VARIABLES
;
735 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
737 req
= (xGLXRenderLargeReq
*) pc
;
738 __GLX_SWAP_SHORT(&req
->length
);
739 __GLX_SWAP_INT(&req
->contextTag
);
740 __GLX_SWAP_INT(&req
->dataBytes
);
741 __GLX_SWAP_SHORT(&req
->requestNumber
);
742 __GLX_SWAP_SHORT(&req
->requestTotal
);
744 pc
+= sz_xGLXRenderLargeReq
;
746 if (req
->requestNumber
== 1) {
747 void (*proc
) (GLbyte
*) = NULL
;
748 __GLXRenderSwapInfo
*info
= NULL
;
751 hdr
= (__GLXrenderLargeHeader
*) pc
;
752 __GLX_SWAP_INT(&hdr
->length
);
753 __GLX_SWAP_INT(&hdr
->opcode
);
756 * call the command procedure to swap any arguments
757 * Note that we are assuming that all arguments that needs to be
758 * swaped are on the first req only !
760 opcode
= hdr
->opcode
;
761 if ((opcode
>= __GLX_MIN_RENDER_OPCODE
) &&
762 (opcode
<= __GLX_MAX_RENDER_OPCODE
)) {
763 proc
= __glXSwapRenderTable
[opcode
];
764 #if __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT
766 else if ((opcode
>= __GLX_MIN_RENDER_OPCODE_EXT
) &&
767 (opcode
<= __GLX_MAX_RENDER_OPCODE_EXT
)) {
768 int index
= opcode
- __GLX_MIN_RENDER_OPCODE_EXT
;
770 info
= &__glXSwapRenderTable_EXT
[index
];
771 if (info
->swapfunc
) {
772 proc
= info
->swapfunc
;
774 #endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */
777 client
->errorValue
= 0;
778 cl
->largeCmdRequestsTotal
= 0;
779 return __glXBadLargeRequest
;
783 ** Make enough space in the buffer, then copy the entire request.
785 if (cl
->largeCmdBufSize
< hdr
->length
) {
786 if (!cl
->largeCmdBuf
) {
787 cl
->largeCmdBuf
= (GLbyte
*) malloc(hdr
->length
);
791 (GLbyte
*) realloc(cl
->largeCmdBuf
, hdr
->length
);
793 if (!cl
->largeCmdBuf
) {
794 cl
->largeCmdRequestsTotal
= 0;
797 cl
->largeCmdBufSize
= hdr
->length
;
799 memcpy(cl
->largeCmdBuf
, pc
, req
->dataBytes
);
801 cl
->largeCmdBytesSoFar
= req
->dataBytes
;
802 cl
->largeCmdBytesTotal
= hdr
->length
;
803 cl
->largeCmdRequestsSoFar
= 1;
804 cl
->largeCmdRequestsTotal
= req
->requestTotal
;
805 cl
->largeCmdRequestsSwapProc
= proc
;
806 cl
->largeCmdMaxReqDataSize
= req
->dataBytes
;
807 cl
->largeCmdRequestsSwap_info
= info
;
812 else if (req
->requestNumber
< cl
->largeCmdRequestsTotal
) {
814 * This is not the first nor last request - just copy the data
816 if (cl
->largeCmdBytesSoFar
+ req
->dataBytes
> cl
->largeCmdBytesTotal
) {
817 cl
->largeCmdRequestsTotal
= 0;
818 return __glXBadLargeRequest
;
821 memcpy(cl
->largeCmdBuf
+ cl
->largeCmdBytesSoFar
, pc
, req
->dataBytes
);
823 cl
->largeCmdBytesSoFar
+= req
->dataBytes
;
825 if (req
->dataBytes
> cl
->largeCmdMaxReqDataSize
)
826 cl
->largeCmdMaxReqDataSize
= req
->dataBytes
;
830 else if (req
->requestNumber
== cl
->largeCmdRequestsTotal
) {
832 * this is the last request
833 * copy the remainder bytes, call the procedure to swap any
834 * needed data, and then call to transfer the command to all
837 if (cl
->largeCmdBytesSoFar
+ req
->dataBytes
> cl
->largeCmdBytesTotal
) {
838 cl
->largeCmdRequestsTotal
= 0;
839 return __glXBadLargeRequest
;
842 memcpy(cl
->largeCmdBuf
+ cl
->largeCmdBytesSoFar
, pc
, req
->dataBytes
);
844 cl
->largeCmdBytesSoFar
+= req
->dataBytes
;
846 if (req
->dataBytes
> cl
->largeCmdMaxReqDataSize
)
847 cl
->largeCmdMaxReqDataSize
= req
->dataBytes
;
849 if (cl
->largeCmdRequestsSwapProc
!= NULL
) {
850 (*cl
->largeCmdRequestsSwapProc
) (cl
->largeCmdBuf
+
851 __GLX_RENDER_LARGE_HDR_SIZE
);
853 else if (cl
->largeCmdRequestsSwap_info
&&
854 cl
->largeCmdRequestsSwap_info
->nelems
> 0) {
855 if (cl
->largeCmdRequestsSwap_info
->elem_size
== 4) {
856 __GLX_SWAP_INT_ARRAY((int *) (pc
+ __GLX_RENDER_LARGE_HDR_SIZE
),
857 cl
->largeCmdRequestsSwap_info
->nelems
);
859 else if (cl
->largeCmdRequestsSwap_info
->elem_size
== 2) {
860 __GLX_SWAP_SHORT_ARRAY((short *) (pc
+
861 __GLX_RENDER_LARGE_HDR_SIZE
),
862 cl
->largeCmdRequestsSwap_info
->nelems
);
864 else if (cl
->largeCmdRequestsSwap_info
->elem_size
== 8) {
865 __GLX_SWAP_DOUBLE_ARRAY((double *) (pc
+
866 __GLX_RENDER_LARGE_HDR_SIZE
),
867 cl
->largeCmdRequestsSwap_info
->nelems
);
871 cl
->largeCmdRequestsTotal
= 0;
872 return (__glXSendLargeCommand(cl
, req
->contextTag
));
876 cl
->largeCmdRequestsTotal
= 0;
877 return __glXBadLargeRequest
;
882 /************************************************************************/
885 ** No support is provided for the vendor-private requests other than
886 ** allocating these entry points in the dispatch table.
890 __glXSwapVendorPrivate(__GLXclientState
* cl
, GLbyte
* pc
)
892 xGLXVendorPrivateReq
*req
;
895 __GLX_DECLARE_SWAP_VARIABLES
;
897 req
= (xGLXVendorPrivateReq
*) pc
;
898 vendorCode
= req
->vendorCode
;
899 __GLX_SWAP_INT(&vendorCode
);
901 switch (vendorCode
) {
903 case X_GLvop_DeleteTexturesEXT
:
904 return __glXVForwardSingleReqSwap(cl
, pc
);
907 case X_GLXvop_SwapIntervalSGI
:
908 if (glxIsExtensionSupported("SGI_swap_control")) {
909 return __glXVForwardSingleReqSwap(cl
, pc
);
917 case X_GLXvop_CreateGLXVideoSourceSGIX
:
919 case X_GLXvop_DestroyGLXVideoSourceSGIX
:
921 case X_GLXvop_CreateGLXPixmapWithConfigSGIX
:
923 case X_GLXvop_DestroyGLXPbufferSGIX
:
925 case X_GLXvop_ChangeDrawableAttributesSGIX
:
929 case X_GLXvop_JoinSwapGroupSGIX
:
930 return __glXSwapJoinSwapGroupSGIX(cl
, pc
);
933 case X_GLXvop_BindSwapBarrierSGIX
:
934 return __glXSwapBindSwapBarrierSGIX(cl
, pc
);
937 case X_GLXvop_CreateContextWithConfigSGIX
:
938 return __glXSwapCreateContextWithConfigSGIX(cl
, pc
);
943 ** unsupported private request
945 cl
->client
->errorValue
= req
->vendorCode
;
946 return __glXUnsupportedPrivateRequest
;
952 __glXSwapVendorPrivateWithReply(__GLXclientState
* cl
, GLbyte
* pc
)
954 xGLXVendorPrivateWithReplyReq
*req
;
957 __GLX_DECLARE_SWAP_VARIABLES
;
959 req
= (xGLXVendorPrivateWithReplyReq
*) pc
;
960 vendorCode
= req
->vendorCode
;
961 __GLX_SWAP_INT(&vendorCode
);
963 switch (vendorCode
) {
965 case X_GLvop_GetConvolutionFilterEXT
:
966 case X_GLvop_GetSeparableFilterEXT
:
967 case X_GLvop_GetHistogramEXT
:
968 case X_GLvop_GetMinmaxEXT
:
969 return (__glXNoSuchSingleOpcode(cl
, pc
));
972 case X_GLvop_GetConvolutionParameterfvEXT
:
973 case X_GLvop_GetConvolutionParameterivEXT
:
974 case X_GLvop_GetHistogramParameterivEXT
:
975 case X_GLvop_GetMinmaxParameterfvEXT
:
976 case X_GLvop_GetMinmaxParameterivEXT
:
977 case X_GLvop_GenTexturesEXT
:
978 return (__glXVForwardAllWithReplySwapiv(cl
, pc
));
981 case X_GLvop_AreTexturesResidentEXT
:
982 case X_GLvop_IsTextureEXT
:
983 return (__glXVForwardPipe0WithReplySwap(cl
, pc
));
987 case X_GLvop_GetDetailTexFuncSGIS
:
988 case X_GLvop_GetSharpenTexFuncSGIS
:
989 case X_GLvop_GetColorTableSGI
:
990 case X_GLvop_GetColorTableParameterfvSGI
:
991 case X_GLvop_GetColorTableParameterivSGI
:
992 case X_GLvop_GetTexFilterFuncSGIS
:
993 case X_GLvop_GetInstrumentsSGIX
:
994 case X_GLvop_InstrumentsBufferSGIX
:
995 case X_GLvop_PollInstrumentsSGIX
:
996 case X_GLvop_FlushRasterSGIX
:
997 case X_GLXvop_CreateGLXPbufferSGIX
:
998 case X_GLXvop_GetDrawableAttributesSGIX
:
999 case X_GLXvop_QueryHyperpipeNetworkSGIX
:
1000 case X_GLXvop_QueryHyperpipeConfigSGIX
:
1001 case X_GLXvop_HyperpipeConfigSGIX
:
1002 case X_GLXvop_DestroyHyperpipeConfigSGIX
:
1004 case X_GLXvop_QueryMaxSwapBarriersSGIX
:
1005 return (__glXSwapQueryMaxSwapBarriersSGIX(cl
, pc
));
1008 case X_GLXvop_GetFBConfigsSGIX
:
1009 return (__glXSwapGetFBConfigsSGIX(cl
, pc
));
1012 case X_GLXvop_MakeCurrentReadSGI
:
1013 return (__glXSwapMakeCurrentReadSGI(cl
, pc
));
1016 case X_GLXvop_QueryContextInfoEXT
:
1017 return (__glXSwapQueryContextInfoEXT(cl
, (char *) pc
));
1022 ** unsupported private request
1024 cl
->client
->errorValue
= req
->vendorCode
;
1025 return __glXUnsupportedPrivateRequest
;
1031 __glXSwapGetFBConfigs(__GLXclientState
* cl
, GLbyte
* pc
)
1033 xGLXGetFBConfigsReq
*req
= (xGLXGetFBConfigsReq
*) pc
;
1035 __GLX_DECLARE_SWAP_VARIABLES
;
1037 __GLX_SWAP_SHORT(&req
->length
);
1038 __GLX_SWAP_INT(&req
->screen
);
1040 return __glXGetFBConfigs(cl
, pc
);
1044 __glXSwapGetFBConfigsSGIX(__GLXclientState
* cl
, GLbyte
* pc
)
1046 xGLXGetFBConfigsSGIXReq
*req
= (xGLXGetFBConfigsSGIXReq
*) pc
;
1047 xGLXGetFBConfigsReq new_req
;
1049 new_req
.reqType
= req
->reqType
;
1050 new_req
.glxCode
= req
->glxCode
;
1051 new_req
.length
= req
->length
;
1052 new_req
.screen
= req
->screen
;
1054 return (__glXSwapGetFBConfigs(cl
, (GLbyte
*) &new_req
));
1058 __glXSwapCreateWindow(__GLXclientState
* cl
, GLbyte
* pc
)
1060 xGLXCreateWindowReq
*req
= (xGLXCreateWindowReq
*) pc
;
1062 __GLX_DECLARE_SWAP_VARIABLES
;
1064 __GLX_SWAP_SHORT(&req
->length
);
1065 __GLX_SWAP_INT(&req
->screen
);
1066 __GLX_SWAP_INT(&req
->fbconfig
);
1067 __GLX_SWAP_INT(&req
->window
);
1068 __GLX_SWAP_INT(&req
->glxwindow
);
1069 __GLX_SWAP_INT(&req
->numAttribs
);
1071 return (__glXCreateWindow(cl
, (GLbyte
*) pc
));
1075 __glXSwapDestroyWindow(__GLXclientState
* cl
, GLbyte
* pc
)
1077 xGLXDestroyWindowReq
*req
= (xGLXDestroyWindowReq
*) pc
;
1079 __GLX_DECLARE_SWAP_VARIABLES
;
1081 __GLX_SWAP_SHORT(&req
->length
);
1082 __GLX_SWAP_INT(&req
->glxwindow
);
1084 return (__glXDestroyWindow(cl
, (GLbyte
*) pc
));
1088 __glXSwapQueryContext(__GLXclientState
* cl
, GLbyte
* pc
)
1090 xGLXQueryContextReq
*req
= (xGLXQueryContextReq
*) pc
;
1092 __GLX_DECLARE_SWAP_VARIABLES
;
1094 __GLX_SWAP_SHORT(&req
->length
);
1095 __GLX_SWAP_INT(&req
->context
);
1097 return (__glXQueryContext(cl
, (GLbyte
*) pc
));
1102 __glXSwapCreatePbuffer(__GLXclientState
* cl
, GLbyte
* pc
)
1104 xGLXCreatePbufferReq
*req
= (xGLXCreatePbufferReq
*) pc
;
1105 int nattr
= req
->numAttribs
;
1107 __GLX_DECLARE_SWAP_VARIABLES
;
1108 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
1110 __GLX_SWAP_SHORT(&req
->length
);
1111 __GLX_SWAP_INT(&req
->screen
);
1112 __GLX_SWAP_INT(&req
->fbconfig
);
1113 __GLX_SWAP_INT(&req
->pbuffer
);
1114 __GLX_SWAP_INT(&req
->numAttribs
);
1115 __GLX_SWAP_INT_ARRAY((int *) (req
+ 1), nattr
* 2);
1117 return (__glXCreatePbuffer(cl
, pc
));
1121 __glXSwapDestroyPbuffer(__GLXclientState
* cl
, GLbyte
* pc
)
1123 xGLXDestroyPbufferReq
*req
= (xGLXDestroyPbufferReq
*) pc
;
1125 __GLX_DECLARE_SWAP_VARIABLES
;
1127 __GLX_SWAP_SHORT(&req
->length
);
1128 __GLX_SWAP_INT(&req
->pbuffer
);
1130 return (__glXDestroyPbuffer(cl
, (GLbyte
*) pc
));
1134 __glXSwapGetDrawableAttributes(__GLXclientState
* cl
, GLbyte
* pc
)
1136 xGLXGetDrawableAttributesReq
*req
= (xGLXGetDrawableAttributesReq
*) pc
;
1138 __GLX_DECLARE_SWAP_VARIABLES
;
1140 __GLX_SWAP_SHORT(&req
->length
);
1141 __GLX_SWAP_INT(&req
->drawable
);
1143 return (__glXGetDrawableAttributes(cl
, pc
));
1147 __glXSwapChangeDrawableAttributes(__GLXclientState
* cl
, GLbyte
* pc
)
1149 xGLXChangeDrawableAttributesReq
*req
=
1150 (xGLXChangeDrawableAttributesReq
*) pc
;
1151 __GLX_DECLARE_SWAP_VARIABLES
;
1152 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
1154 __GLX_SWAP_SHORT(&req
->length
);
1155 __GLX_SWAP_INT(&req
->drawable
);
1156 __GLX_SWAP_INT(&req
->numAttribs
);
1157 __GLX_SWAP_INT_ARRAY((int *) (req
+ 1), req
->numAttribs
* 2);
1159 return (__glXChangeDrawableAttributes(cl
, pc
));