glxcmdsswap.c revision 6747b715
1/*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
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:
11 *
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.
16 *
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
23 * SOFTWARE.
24 *
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.
29 */
30
31#ifdef HAVE_DIX_CONFIG_H
32#include <dix-config.h>
33#endif
34
35#include <string.h>
36#include "glxserver.h"
37#include "glxutil.h"
38#include <GL/glxtokens.h>
39#include <unpack.h>
40#include "g_disptab.h"
41#include <pixmapstr.h>
42#include <windowstr.h>
43#include "glxext.h"
44#include "glapitable.h"
45#include "glapi.h"
46#include "glthread.h"
47#include "dispatch.h"
48#include "indirect_dispatch.h"
49#include "indirect_table.h"
50#include "indirect_util.h"
51
52
53/************************************************************************/
54
55/*
56** Byteswapping versions of GLX commands.  In most cases they just swap
57** the incoming arguments and then call the unswapped routine.  For commands
58** that have replies, a separate swapping routine for the reply is provided;
59** it is called at the end of the unswapped routine.
60*/
61
62int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc)
63{
64    xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
65    __GLX_DECLARE_SWAP_VARIABLES;
66
67    __GLX_SWAP_SHORT(&req->length);
68    __GLX_SWAP_INT(&req->context);
69    __GLX_SWAP_INT(&req->visual);
70    __GLX_SWAP_INT(&req->screen);
71    __GLX_SWAP_INT(&req->shareList);
72
73    return __glXDisp_CreateContext(cl, pc);
74}
75
76int __glXDispSwap_CreateNewContext(__GLXclientState *cl, GLbyte *pc)
77{
78    xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
79    __GLX_DECLARE_SWAP_VARIABLES;
80
81    __GLX_SWAP_SHORT(&req->length);
82    __GLX_SWAP_INT(&req->context);
83    __GLX_SWAP_INT(&req->fbconfig);
84    __GLX_SWAP_INT(&req->screen);
85    __GLX_SWAP_INT(&req->renderType);
86    __GLX_SWAP_INT(&req->shareList);
87
88    return __glXDisp_CreateNewContext(cl, pc);
89}
90
91int __glXDispSwap_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
92{
93    xGLXCreateContextWithConfigSGIXReq *req =
94	(xGLXCreateContextWithConfigSGIXReq *) pc;
95    __GLX_DECLARE_SWAP_VARIABLES;
96
97    __GLX_SWAP_SHORT(&req->length);
98    __GLX_SWAP_INT(&req->context);
99    __GLX_SWAP_INT(&req->fbconfig);
100    __GLX_SWAP_INT(&req->screen);
101    __GLX_SWAP_INT(&req->renderType);
102    __GLX_SWAP_INT(&req->shareList);
103
104    return __glXDisp_CreateContextWithConfigSGIX(cl, pc);
105}
106
107int __glXDispSwap_DestroyContext(__GLXclientState *cl, GLbyte *pc)
108{
109    xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
110    __GLX_DECLARE_SWAP_VARIABLES;
111
112    __GLX_SWAP_SHORT(&req->length);
113    __GLX_SWAP_INT(&req->context);
114
115    return __glXDisp_DestroyContext(cl, pc);
116}
117
118int __glXDispSwap_MakeCurrent(__GLXclientState *cl, GLbyte *pc)
119{
120    xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
121    __GLX_DECLARE_SWAP_VARIABLES;
122
123    __GLX_SWAP_SHORT(&req->length);
124    __GLX_SWAP_INT(&req->drawable);
125    __GLX_SWAP_INT(&req->context);
126    __GLX_SWAP_INT(&req->oldContextTag);
127
128    return __glXDisp_MakeCurrent(cl, pc);
129}
130
131int __glXDispSwap_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
132{
133    xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
134    __GLX_DECLARE_SWAP_VARIABLES;
135
136    __GLX_SWAP_SHORT(&req->length);
137    __GLX_SWAP_INT(&req->drawable);
138    __GLX_SWAP_INT(&req->readdrawable);
139    __GLX_SWAP_INT(&req->context);
140    __GLX_SWAP_INT(&req->oldContextTag);
141
142    return __glXDisp_MakeContextCurrent(cl, pc);
143}
144
145int __glXDispSwap_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
146{
147    xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
148    __GLX_DECLARE_SWAP_VARIABLES;
149
150    __GLX_SWAP_SHORT(&req->length);
151    __GLX_SWAP_INT(&req->drawable);
152    __GLX_SWAP_INT(&req->readable);
153    __GLX_SWAP_INT(&req->context);
154    __GLX_SWAP_INT(&req->oldContextTag);
155
156    return __glXDisp_MakeCurrentReadSGI(cl, pc);
157}
158
159int __glXDispSwap_IsDirect(__GLXclientState *cl, GLbyte *pc)
160{
161    xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
162    __GLX_DECLARE_SWAP_VARIABLES;
163
164    __GLX_SWAP_SHORT(&req->length);
165    __GLX_SWAP_INT(&req->context);
166
167    return __glXDisp_IsDirect(cl, pc);
168}
169
170int __glXDispSwap_QueryVersion(__GLXclientState *cl, GLbyte *pc)
171{
172    xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc;
173    __GLX_DECLARE_SWAP_VARIABLES;
174
175    __GLX_SWAP_SHORT(&req->length);
176    __GLX_SWAP_INT(&req->majorVersion);
177    __GLX_SWAP_INT(&req->minorVersion);
178
179    return __glXDisp_QueryVersion(cl, pc);
180}
181
182int __glXDispSwap_WaitGL(__GLXclientState *cl, GLbyte *pc)
183{
184    xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc;
185    __GLX_DECLARE_SWAP_VARIABLES;
186
187    __GLX_SWAP_SHORT(&req->length);
188    __GLX_SWAP_INT(&req->contextTag);
189
190    return __glXDisp_WaitGL(cl, pc);
191}
192
193int __glXDispSwap_WaitX(__GLXclientState *cl, GLbyte *pc)
194{
195    xGLXWaitXReq *req = (xGLXWaitXReq *) pc;
196    __GLX_DECLARE_SWAP_VARIABLES;
197
198    __GLX_SWAP_SHORT(&req->length);
199    __GLX_SWAP_INT(&req->contextTag);
200
201    return __glXDisp_WaitX(cl, pc);
202}
203
204int __glXDispSwap_CopyContext(__GLXclientState *cl, GLbyte *pc)
205{
206    xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
207    __GLX_DECLARE_SWAP_VARIABLES;
208
209    __GLX_SWAP_SHORT(&req->length);
210    __GLX_SWAP_INT(&req->source);
211    __GLX_SWAP_INT(&req->dest);
212    __GLX_SWAP_INT(&req->mask);
213
214    return __glXDisp_CopyContext(cl, pc);
215}
216
217int __glXDispSwap_GetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
218{
219    xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
220    __GLX_DECLARE_SWAP_VARIABLES;
221
222    __GLX_SWAP_INT(&req->screen);
223    return __glXDisp_GetVisualConfigs(cl, pc);
224}
225
226int __glXDispSwap_GetFBConfigs(__GLXclientState *cl, GLbyte *pc)
227{
228    xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
229    __GLX_DECLARE_SWAP_VARIABLES;
230
231    __GLX_SWAP_INT(&req->screen);
232    return __glXDisp_GetFBConfigs(cl, pc);
233}
234
235int __glXDispSwap_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
236{
237    xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc;
238    __GLX_DECLARE_SWAP_VARIABLES;
239
240    __GLX_SWAP_INT(&req->screen);
241    return __glXDisp_GetFBConfigsSGIX(cl, pc);
242}
243
244int __glXDispSwap_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
245{
246    xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
247    __GLX_DECLARE_SWAP_VARIABLES;
248
249    __GLX_SWAP_SHORT(&req->length);
250    __GLX_SWAP_INT(&req->screen);
251    __GLX_SWAP_INT(&req->visual);
252    __GLX_SWAP_INT(&req->pixmap);
253    __GLX_SWAP_INT(&req->glxpixmap);
254
255    return __glXDisp_CreateGLXPixmap(cl, pc);
256}
257
258int __glXDispSwap_CreatePixmap(__GLXclientState *cl, GLbyte *pc)
259{
260    xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
261    CARD32 *attribs;
262    __GLX_DECLARE_SWAP_VARIABLES;
263    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
264
265    __GLX_SWAP_SHORT(&req->length);
266    __GLX_SWAP_INT(&req->screen);
267    __GLX_SWAP_INT(&req->fbconfig);
268    __GLX_SWAP_INT(&req->pixmap);
269    __GLX_SWAP_INT(&req->glxpixmap);
270    __GLX_SWAP_INT(&req->numAttribs);
271    attribs = (CARD32*)(req + 1);
272    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs);
273
274    return __glXDisp_CreatePixmap(cl, pc);
275}
276
277int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
278{
279    xGLXCreateGLXPixmapWithConfigSGIXReq *req =
280	(xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
281    __GLX_DECLARE_SWAP_VARIABLES;
282
283    __GLX_SWAP_SHORT(&req->length);
284    __GLX_SWAP_INT(&req->screen);
285    __GLX_SWAP_INT(&req->fbconfig);
286    __GLX_SWAP_INT(&req->pixmap);
287    __GLX_SWAP_INT(&req->glxpixmap);
288
289    return __glXDisp_CreateGLXPixmapWithConfigSGIX(cl, pc);
290}
291
292int __glXDispSwap_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
293{
294    xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
295    __GLX_DECLARE_SWAP_VARIABLES;
296
297    __GLX_SWAP_SHORT(&req->length);
298    __GLX_SWAP_INT(&req->glxpixmap);
299
300    return __glXDisp_DestroyGLXPixmap(cl, pc);
301}
302
303int __glXDispSwap_DestroyPixmap(__GLXclientState *cl, GLbyte *pc)
304{
305    xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
306    __GLX_DECLARE_SWAP_VARIABLES;
307
308    __GLX_SWAP_SHORT(&req->length);
309    __GLX_SWAP_INT(&req->glxpixmap);
310
311    return __glXDisp_DestroyGLXPixmap(cl, pc);
312}
313
314int __glXDispSwap_QueryContext(__GLXclientState *cl, GLbyte *pc)
315{
316    xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc;
317    __GLX_DECLARE_SWAP_VARIABLES;
318
319    __GLX_SWAP_INT(&req->context);
320
321    return __glXDisp_QueryContext(cl, pc);
322}
323
324int __glXDispSwap_CreatePbuffer(__GLXclientState *cl, GLbyte *pc)
325{
326    xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc;
327    __GLX_DECLARE_SWAP_VARIABLES;
328    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
329    CARD32 *attribs;
330
331    __GLX_SWAP_INT(&req->screen);
332    __GLX_SWAP_INT(&req->fbconfig);
333    __GLX_SWAP_INT(&req->pbuffer);
334    __GLX_SWAP_INT(&req->numAttribs);
335    attribs = (CARD32*)(req + 1);
336    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs);
337
338    return __glXDisp_CreatePbuffer(cl, pc);
339}
340
341int __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
342{
343    xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc;
344    __GLX_DECLARE_SWAP_VARIABLES;
345
346    __GLX_SWAP_INT(&req->screen);
347    __GLX_SWAP_INT(&req->fbconfig);
348    __GLX_SWAP_INT(&req->pbuffer);
349    __GLX_SWAP_INT(&req->width);
350    __GLX_SWAP_INT(&req->height);
351
352    return __glXDisp_CreateGLXPbufferSGIX(cl, pc);
353}
354
355int __glXDispSwap_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
356{
357    xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
358    __GLX_DECLARE_SWAP_VARIABLES;
359
360    __GLX_SWAP_INT(&req->pbuffer);
361
362    return __glXDisp_DestroyPbuffer(cl, pc);
363}
364
365int __glXDispSwap_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
366{
367    xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc;
368    __GLX_DECLARE_SWAP_VARIABLES;
369
370    __GLX_SWAP_INT(&req->pbuffer);
371
372    return __glXDisp_DestroyGLXPbufferSGIX(cl, pc);
373}
374
375int __glXDispSwap_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
376{
377    xGLXChangeDrawableAttributesReq *req =
378	(xGLXChangeDrawableAttributesReq *) pc;
379    __GLX_DECLARE_SWAP_VARIABLES;
380    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
381    CARD32 *attribs;
382
383    __GLX_SWAP_INT(&req->drawable);
384    __GLX_SWAP_INT(&req->numAttribs);
385    attribs = (CARD32*)(req + 1);
386    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs);
387
388    return __glXDisp_ChangeDrawableAttributes(cl, pc);
389}
390
391int __glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState *cl,
392					       GLbyte *pc)
393{
394    xGLXChangeDrawableAttributesSGIXReq *req =
395	(xGLXChangeDrawableAttributesSGIXReq *) pc;
396    __GLX_DECLARE_SWAP_VARIABLES;
397    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
398    CARD32 *attribs;
399
400    __GLX_SWAP_INT(&req->drawable);
401    __GLX_SWAP_INT(&req->numAttribs);
402    attribs = (CARD32*)(req + 1);
403    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs);
404
405    return __glXDisp_ChangeDrawableAttributesSGIX(cl, pc);
406}
407
408int __glXDispSwap_CreateWindow(__GLXclientState *cl, GLbyte *pc)
409{
410    xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc;
411    __GLX_DECLARE_SWAP_VARIABLES;
412    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
413    CARD32 *attribs;
414
415    __GLX_SWAP_INT(&req->screen);
416    __GLX_SWAP_INT(&req->fbconfig);
417    __GLX_SWAP_INT(&req->window);
418    __GLX_SWAP_INT(&req->glxwindow);
419    __GLX_SWAP_INT(&req->numAttribs);
420    attribs = (CARD32*)(req + 1);
421    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs);
422
423    return __glXDisp_CreateWindow(cl, pc);
424}
425
426int __glXDispSwap_DestroyWindow(__GLXclientState *cl, GLbyte *pc)
427{
428    xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
429    __GLX_DECLARE_SWAP_VARIABLES;
430
431    __GLX_SWAP_INT(&req->glxwindow);
432
433    return __glXDisp_DestroyWindow(cl, pc);
434}
435
436int __glXDispSwap_SwapBuffers(__GLXclientState *cl, GLbyte *pc)
437{
438    xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
439    __GLX_DECLARE_SWAP_VARIABLES;
440
441    __GLX_SWAP_SHORT(&req->length);
442    __GLX_SWAP_INT(&req->contextTag);
443    __GLX_SWAP_INT(&req->drawable);
444
445    return __glXDisp_SwapBuffers(cl, pc);
446}
447
448int __glXDispSwap_UseXFont(__GLXclientState *cl, GLbyte *pc)
449{
450    xGLXUseXFontReq *req = (xGLXUseXFontReq *) pc;
451    __GLX_DECLARE_SWAP_VARIABLES;
452
453    __GLX_SWAP_SHORT(&req->length);
454    __GLX_SWAP_INT(&req->contextTag);
455    __GLX_SWAP_INT(&req->font);
456    __GLX_SWAP_INT(&req->first);
457    __GLX_SWAP_INT(&req->count);
458    __GLX_SWAP_INT(&req->listBase);
459
460    return __glXDisp_UseXFont(cl, pc);
461}
462
463
464int __glXDispSwap_QueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
465{
466    xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *)pc;
467    __GLX_DECLARE_SWAP_VARIABLES;
468
469    __GLX_SWAP_SHORT(&req->length);
470    __GLX_SWAP_INT(&req->screen);
471
472    return __glXDisp_QueryExtensionsString(cl, pc);
473}
474
475int __glXDispSwap_QueryServerString(__GLXclientState *cl, GLbyte *pc)
476{
477    xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *)pc;
478    __GLX_DECLARE_SWAP_VARIABLES;
479
480    __GLX_SWAP_SHORT(&req->length);
481    __GLX_SWAP_INT(&req->screen);
482    __GLX_SWAP_INT(&req->name);
483
484    return __glXDisp_QueryServerString(cl, pc);
485}
486
487int __glXDispSwap_ClientInfo(__GLXclientState *cl, GLbyte *pc)
488{
489    xGLXClientInfoReq *req = (xGLXClientInfoReq *)pc;
490    __GLX_DECLARE_SWAP_VARIABLES;
491
492    __GLX_SWAP_SHORT(&req->length);
493    __GLX_SWAP_INT(&req->major);
494    __GLX_SWAP_INT(&req->minor);
495    __GLX_SWAP_INT(&req->numbytes);
496
497    return __glXDisp_ClientInfo(cl, pc);
498}
499
500int __glXDispSwap_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
501{
502    xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc;
503    __GLX_DECLARE_SWAP_VARIABLES;
504
505    __GLX_SWAP_SHORT(&req->length);
506    __GLX_SWAP_INT(&req->context);
507
508    return __glXDisp_QueryContextInfoEXT(cl, pc);
509}
510
511int __glXDispSwap_BindTexImageEXT(__GLXclientState *cl, GLbyte *pc)
512{
513    xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
514    GLXDrawable		 *drawId;
515    int			 *buffer;
516
517    __GLX_DECLARE_SWAP_VARIABLES;
518
519    pc += __GLX_VENDPRIV_HDR_SIZE;
520
521    drawId = ((GLXDrawable *) (pc));
522    buffer = ((int *)	      (pc + 4));
523
524    __GLX_SWAP_SHORT(&req->length);
525    __GLX_SWAP_INT(&req->contextTag);
526    __GLX_SWAP_INT(drawId);
527    __GLX_SWAP_INT(buffer);
528
529    return __glXDisp_BindTexImageEXT(cl, (GLbyte *)pc);
530}
531
532int __glXDispSwap_ReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc)
533{
534    xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
535    GLXDrawable		 *drawId;
536    int			 *buffer;
537
538    __GLX_DECLARE_SWAP_VARIABLES;
539
540    pc += __GLX_VENDPRIV_HDR_SIZE;
541
542    drawId = ((GLXDrawable *) (pc));
543    buffer = ((int *)	      (pc + 4));
544
545    __GLX_SWAP_SHORT(&req->length);
546    __GLX_SWAP_INT(&req->contextTag);
547    __GLX_SWAP_INT(drawId);
548    __GLX_SWAP_INT(buffer);
549
550    return __glXDisp_ReleaseTexImageEXT(cl, (GLbyte *)pc);
551}
552
553int __glXDispSwap_CopySubBufferMESA(__GLXclientState *cl, GLbyte *pc)
554{
555    xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
556    GLXDrawable		 *drawId;
557    int			 *buffer;
558
559    __GLX_DECLARE_SWAP_VARIABLES;
560
561    (void) drawId;
562    (void) buffer;
563
564    pc += __GLX_VENDPRIV_HDR_SIZE;
565
566    __GLX_SWAP_SHORT(&req->length);
567    __GLX_SWAP_INT(&req->contextTag);
568    __GLX_SWAP_INT(pc);
569    __GLX_SWAP_INT(pc + 4);
570    __GLX_SWAP_INT(pc + 8);
571    __GLX_SWAP_INT(pc + 12);
572    __GLX_SWAP_INT(pc + 16);
573
574    return __glXDisp_CopySubBufferMESA(cl, pc);
575
576}
577
578int __glXDispSwap_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
579{
580    xGLXVendorPrivateWithReplyReq *req = (xGLXVendorPrivateWithReplyReq *)pc;
581    CARD32 *data;
582
583    __GLX_DECLARE_SWAP_VARIABLES;
584
585    data = (CARD32 *) (req + 1);
586    __GLX_SWAP_SHORT(&req->length);
587    __GLX_SWAP_INT(&req->contextTag);
588    __GLX_SWAP_INT(data);
589
590    return __glXDisp_GetDrawableAttributesSGIX(cl, pc);
591}
592
593int __glXDispSwap_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
594{
595    xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc;
596
597    __GLX_DECLARE_SWAP_VARIABLES;
598
599    __GLX_SWAP_SHORT(&req->length);
600    __GLX_SWAP_INT(&req->drawable);
601
602    return __glXDisp_GetDrawableAttributes(cl, pc);
603}
604
605
606/************************************************************************/
607
608/*
609** Swap replies.
610*/
611
612void __glXSwapMakeCurrentReply(ClientPtr client, xGLXMakeCurrentReply *reply)
613{
614    __GLX_DECLARE_SWAP_VARIABLES;
615    __GLX_SWAP_SHORT(&reply->sequenceNumber);
616    __GLX_SWAP_INT(&reply->length);
617    __GLX_SWAP_INT(&reply->contextTag);
618    WriteToClient(client, sz_xGLXMakeCurrentReply, (char *)reply);
619}
620
621void __glXSwapIsDirectReply(ClientPtr client, xGLXIsDirectReply *reply)
622{
623    __GLX_DECLARE_SWAP_VARIABLES;
624    __GLX_SWAP_SHORT(&reply->sequenceNumber);
625    __GLX_SWAP_INT(&reply->length);
626    WriteToClient(client, sz_xGLXIsDirectReply, (char *)reply);
627}
628
629void __glXSwapQueryVersionReply(ClientPtr client, xGLXQueryVersionReply *reply)
630{
631    __GLX_DECLARE_SWAP_VARIABLES;
632    __GLX_SWAP_SHORT(&reply->sequenceNumber);
633    __GLX_SWAP_INT(&reply->length);
634    __GLX_SWAP_INT(&reply->majorVersion);
635    __GLX_SWAP_INT(&reply->minorVersion);
636    WriteToClient(client, sz_xGLXQueryVersionReply, (char *)reply);
637}
638
639void glxSwapQueryExtensionsStringReply(ClientPtr client,
640				       xGLXQueryExtensionsStringReply *reply, char *buf)
641{
642    int length = reply->length;
643    __GLX_DECLARE_SWAP_VARIABLES;
644    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
645    __GLX_SWAP_SHORT(&reply->sequenceNumber);
646    __GLX_SWAP_INT(&reply->length);
647    __GLX_SWAP_INT(&reply->n);
648    WriteToClient(client, sz_xGLXQueryExtensionsStringReply, (char *)reply);
649    __GLX_SWAP_INT_ARRAY((int *)buf, length);
650    WriteToClient(client, length << 2, buf);
651}
652
653void glxSwapQueryServerStringReply(ClientPtr client,
654				   xGLXQueryServerStringReply *reply, char *buf)
655{
656    int length = reply->length;
657    __GLX_DECLARE_SWAP_VARIABLES;
658    __GLX_SWAP_SHORT(&reply->sequenceNumber);
659    __GLX_SWAP_INT(&reply->length);
660    __GLX_SWAP_INT(&reply->n);
661    WriteToClient(client, sz_xGLXQueryServerStringReply, (char *)reply);
662    /** no swap is needed for an array of chars **/
663    /* __GLX_SWAP_INT_ARRAY((int *)buf, length); */
664    WriteToClient(client, length << 2, buf);
665}
666
667void __glXSwapQueryContextInfoEXTReply(ClientPtr client, xGLXQueryContextInfoEXTReply *reply, int *buf)
668{
669    int length = reply->length;
670    __GLX_DECLARE_SWAP_VARIABLES;
671    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
672    __GLX_SWAP_SHORT(&reply->sequenceNumber);
673    __GLX_SWAP_INT(&reply->length);
674    __GLX_SWAP_INT(&reply->n);
675    WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)reply);
676    __GLX_SWAP_INT_ARRAY((int *)buf, length);
677    WriteToClient(client, length << 2, (char *)buf);
678}
679
680void __glXSwapGetDrawableAttributesReply(ClientPtr client,
681					 xGLXGetDrawableAttributesReply *reply, CARD32 *buf)
682{
683    int length = reply->length;
684    __GLX_DECLARE_SWAP_VARIABLES;
685    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
686    __GLX_SWAP_SHORT(&reply->sequenceNumber);
687    __GLX_SWAP_INT(&reply->length);
688    __GLX_SWAP_INT(&reply->numAttribs);
689    WriteToClient(client, sz_xGLXGetDrawableAttributesReply, (char *)reply);
690    __GLX_SWAP_INT_ARRAY((int *)buf, length);
691    WriteToClient(client, length << 2, (char *)buf);
692}
693
694/************************************************************************/
695
696/*
697** Render and Renderlarge are not in the GLX API.  They are used by the GLX
698** client library to send batches of GL rendering commands.
699*/
700
701int __glXDispSwap_Render(__GLXclientState *cl, GLbyte *pc)
702{
703    return __glXDisp_Render(cl, pc);
704}
705
706/*
707** Execute a large rendering request (one that spans multiple X requests).
708*/
709int __glXDispSwap_RenderLarge(__GLXclientState *cl, GLbyte *pc)
710{
711    return __glXDisp_RenderLarge(cl, pc);
712}
713
714/************************************************************************/
715
716/*
717** No support is provided for the vendor-private requests other than
718** allocating these entry points in the dispatch table.
719*/
720
721int __glXDispSwap_VendorPrivate(__GLXclientState *cl, GLbyte *pc)
722{
723    xGLXVendorPrivateReq *req;
724    GLint vendorcode;
725    __GLXdispatchVendorPrivProcPtr proc;
726
727    __GLX_DECLARE_SWAP_VARIABLES;
728
729    req = (xGLXVendorPrivateReq *) pc;
730    __GLX_SWAP_SHORT(&req->length);
731    __GLX_SWAP_INT(&req->vendorCode);
732
733    vendorcode = req->vendorCode;
734
735    proc = (__GLXdispatchVendorPrivProcPtr)
736      __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info,
737				     vendorcode, 1);
738    if (proc != NULL) {
739	(*proc)(cl, (GLbyte*)req);
740	return Success;
741    }
742
743    cl->client->errorValue = req->vendorCode;
744    return __glXError(GLXUnsupportedPrivateRequest);
745}
746
747
748int __glXDispSwap_VendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
749{
750    xGLXVendorPrivateWithReplyReq *req;
751    GLint vendorcode;
752    __GLXdispatchVendorPrivProcPtr proc;
753
754    __GLX_DECLARE_SWAP_VARIABLES;
755
756    req = (xGLXVendorPrivateWithReplyReq *) pc;
757    __GLX_SWAP_SHORT(&req->length);
758    __GLX_SWAP_INT(&req->vendorCode);
759
760    vendorcode = req->vendorCode;
761
762    proc = (__GLXdispatchVendorPrivProcPtr)
763      __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info,
764				     vendorcode, 1);
765    if (proc != NULL) {
766	return (*proc)(cl, (GLbyte*)req);
767    }
768
769    cl->client->errorValue = req->vendorCode;
770    return __glXError(GLXUnsupportedPrivateRequest);
771}
772