1
/* $XFree86: xc/programs/Xserver/GL/glx/g_single.c,v 1.4 2001/03/21 16:29:35 dawes Exp $ */
2
/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
4
** License Applicability. Except to the extent portions of this file are
5
** made subject to an alternative license as permitted in the SGI Free
6
** Software License B, Version 1.1 (the "License"), the contents of this
7
** file are subject only to the provisions of the License. You may not use
8
** this file except in compliance with the License. You may obtain a copy
9
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
10
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
12
** http://oss.sgi.com/projects/FreeB
14
** Note that, as provided in the License, the Software is distributed on an
15
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
16
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
17
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
18
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
20
** Original Code. The Original Code is: OpenGL Sample Implementation,
21
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
22
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
23
** Copyright in any portions created by third parties is as indicated
24
** elsewhere herein. All Rights Reserved.
26
** Additional Notice Provisions: This software was created using the
27
** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
28
** not been independently verified as being compliant with the OpenGL(R)
29
** version 1.2.1 Specification.
32
#ifdef HAVE_DMX_CONFIG_H
33
#include <dmx-config.h>
37
#include "dmxwindow.h"
38
#include "dmxpixmap.h"
47
#include "glxserver.h"
49
#include "g_disptab.h"
50
/* #include "g_disptab_EXT.h" */
54
#include "GL/glxproto.h"
57
#include "panoramiXsrv.h"
61
* GetReqVendorPrivate - this is the equivalent of GetReq macro
62
* from Xlibint.h but it does not set the reqType field (the opcode).
63
* this is because the GL single opcodes has different naming convension
64
* the other X opcodes (ie. X_GLsop_GetFloatv).
66
#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
67
#define GetReqVendorPrivate(name, req) \
69
if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
71
req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
72
req->length = (SIZEOF(x##name##Req))>>2;\
73
dpy->bufptr += SIZEOF(x##name##Req);\
76
#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
77
#define GetReqVendorPrivate(name, req) \
79
if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
81
req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
82
req->length = (SIZEOF(x/**/name/**/Req))>>2;\
83
dpy->bufptr += SIZEOF(x/**/name/**/Req);\
87
extern Display *GetBackEndDisplay( __GLXclientState *cl, int s );
88
extern int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s);
90
static int swap_vec_element_size = 0;
92
static void SendSwappedReply( ClientPtr client,
93
xGLXVendorPrivReply *reply,
97
__GLX_DECLARE_SWAP_VARIABLES;
98
__GLX_SWAP_SHORT(&reply->sequenceNumber);
99
__GLX_SWAP_INT(&reply->length);
100
__GLX_SWAP_INT(&reply->retval);
101
__GLX_SWAP_INT(&reply->size);
103
if ( (buf_size == 0) && (swap_vec_element_size > 0) ) {
105
* the reply has single component - need to swap pad3
107
if (swap_vec_element_size == 2) {
108
__GLX_SWAP_SHORT(&reply->pad3);
110
else if (swap_vec_element_size == 4) {
111
__GLX_SWAP_INT(&reply->pad3);
112
__GLX_SWAP_INT(&reply->pad4);
114
else if (swap_vec_element_size == 8) {
115
__GLX_SWAP_DOUBLE(&reply->pad3);
118
else if ( (buf_size > 0) && (swap_vec_element_size > 0) ) {
120
* the reply has vector of elements which needs to be swapped
122
int vsize = buf_size / swap_vec_element_size;
126
for (i=0; i<vsize; i++) {
127
if (swap_vec_element_size == 2) {
130
else if (swap_vec_element_size == 4) {
133
else if (swap_vec_element_size == 8) {
134
__GLX_SWAP_DOUBLE(p);
137
p += swap_vec_element_size;
140
__GLX_SWAP_INT(&reply->pad3);
141
__GLX_SWAP_INT(&reply->pad4);
142
__GLX_SWAP_INT(&reply->pad5);
143
__GLX_SWAP_INT(&reply->pad6);
147
WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)reply);
149
WriteToClient(client, buf_size, (char *)buf);
153
int __glXVForwardSingleReq( __GLXclientState *cl, GLbyte *pc )
155
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
156
xGLXVendorPrivateReq *be_req;
163
glxc = __glXLookupContextByTag(cl, req->contextTag);
167
from_screen = to_screen = glxc->pScreen->myNum;
170
if (!noPanoramiXExtension) {
172
to_screen = screenInfo.numScreens - 1;
176
pc += sz_xGLXVendorPrivateReq;
177
buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
180
* just forward the request to back-end server(s)
182
for (s=from_screen; s<=to_screen; s++) {
183
DMXScreenInfo *dmxScreen = &dmxScreens[s];
184
Display *dpy = GetBackEndDisplay(cl,s);
187
GetReqVendorPrivate(GLXVendorPrivate,be_req);
188
be_req->reqType = dmxScreen->glxMajorOpcode;
189
be_req->glxCode = req->glxCode;
190
be_req->length = req->length;
191
be_req->vendorCode = req->vendorCode;
192
be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
194
_XSend(dpy, (const char *)pc, buf_size);
202
int __glXVForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc )
204
ClientPtr client = cl->client;
205
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
206
xGLXVendorPrivateReq *be_req;
207
xGLXVendorPrivReply reply;
208
xGLXVendorPrivReply be_reply;
213
DMXScreenInfo *dmxScreen;
216
glxc = __glXLookupContextByTag(cl, req->contextTag);
218
return __glXBadContext;
221
pc += sz_xGLXVendorPrivateReq;
222
buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
224
dmxScreen = &dmxScreens[glxc->pScreen->myNum];
225
dpy = GetBackEndDisplay(cl, glxc->pScreen->myNum);
228
* send the request to the first back-end server
231
GetReqVendorPrivate(GLXVendorPrivate,be_req);
232
be_req->reqType = dmxScreen->glxMajorOpcode;
233
be_req->glxCode = req->glxCode;
234
be_req->length = req->length;
235
be_req->vendorCode = req->vendorCode;
236
be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag, glxc->pScreen->myNum);
238
_XSend(dpy, (const char *)pc, buf_size);
241
* get the reply from the back-end server
243
_XReply(dpy, (xReply*) &be_reply, 0, False);
244
be_buf_size = be_reply.length << 2;
245
if (be_buf_size > 0) {
246
be_buf = (char *)Xalloc( be_buf_size );
248
_XRead(dpy, be_buf, be_buf_size);
251
/* Throw data on the floor */
252
_XEatData(dpy, be_buf_size);
261
* send the reply to the client
263
memcpy( &reply, &be_reply, sz_xGLXVendorPrivReply );
264
reply.type = X_Reply;
265
reply.sequenceNumber = client->sequence;
267
if (client->swapped) {
268
SendSwappedReply( client, &reply, be_buf, be_buf_size );
271
WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)&reply);
273
WriteToClient(client, be_buf_size, (char *)be_buf);
276
if (be_buf_size > 0) Xfree(be_buf);
281
int __glXVForwardAllWithReply( __GLXclientState *cl, GLbyte *pc )
283
ClientPtr client = cl->client;
284
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
285
xGLXVendorPrivateReq *be_req;
286
xGLXVendorPrivReply reply;
287
xGLXVendorPrivReply be_reply;
296
DMXScreenInfo *dmxScreen;
299
glxc = __glXLookupContextByTag(cl, req->contextTag);
303
from_screen = to_screen = glxc->pScreen->myNum;
306
if (!noPanoramiXExtension) {
308
to_screen = screenInfo.numScreens - 1;
312
pc += sz_xGLXVendorPrivateReq;
313
buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
316
* send the request to the first back-end server(s)
318
for (s=to_screen; s>=from_screen; s--) {
319
dmxScreen = &dmxScreens[s];
320
dpy = GetBackEndDisplay(cl,s);
323
GetReqVendorPrivate(GLXVendorPrivate,be_req);
324
be_req->reqType = dmxScreen->glxMajorOpcode;
325
be_req->glxCode = req->glxCode;
326
be_req->length = req->length;
327
be_req->vendorCode = req->vendorCode;
328
be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
330
_XSend(dpy, (const char *)pc, buf_size);
333
* get the reply from the back-end server
335
_XReply(dpy, (xReply*) &be_reply, 0, False);
336
be_buf_size = be_reply.length << 2;
337
if (be_buf_size > 0) {
338
be_buf = (char *)Xalloc( be_buf_size );
340
_XRead(dpy, be_buf, be_buf_size);
343
/* Throw data on the floor */
344
_XEatData(dpy, be_buf_size);
352
if (s > from_screen && be_buf_size > 0) {
358
* send the reply to the client
360
memcpy( &reply, &be_reply, sz_xGLXVendorPrivReply );
361
reply.type = X_Reply;
362
reply.sequenceNumber = client->sequence;
364
if (client->swapped) {
365
SendSwappedReply( client, &reply, be_buf, be_buf_size );
368
WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)&reply);
370
WriteToClient(client, be_buf_size, (char *)be_buf);
373
if (be_buf_size > 0) Xfree(be_buf);
378
int __glXVForwardSingleReqSwap( __GLXclientState *cl, GLbyte *pc )
380
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
381
__GLX_DECLARE_SWAP_VARIABLES;
383
__GLX_SWAP_SHORT(&req->length);
384
__GLX_SWAP_INT(&req->vendorCode);
385
__GLX_SWAP_INT(&req->contextTag);
387
swap_vec_element_size = 0;
389
return( __glXVForwardSingleReq( cl, pc ) );
392
int __glXVForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc )
394
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
395
__GLX_DECLARE_SWAP_VARIABLES;
397
__GLX_SWAP_SHORT(&req->length);
398
__GLX_SWAP_INT(&req->vendorCode);
399
__GLX_SWAP_INT(&req->contextTag);
401
swap_vec_element_size = 0;
404
* swap extra data in request - assuming all data
405
* (if available) are arrays of 4 bytes components !
407
if (req->length > sz_xGLXVendorPrivateReq/4) {
408
int *data = (int *)(req+1);
409
int count = req->length - sz_xGLXVendorPrivateReq/4;
410
__GLX_SWAP_INT_ARRAY(data, count );
413
return( __glXVForwardPipe0WithReply( cl, pc ) );
416
int __glXVForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
418
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
419
__GLX_DECLARE_SWAP_VARIABLES;
421
__GLX_SWAP_SHORT(&req->length);
422
__GLX_SWAP_INT(&req->vendorCode);
423
__GLX_SWAP_INT(&req->contextTag);
425
swap_vec_element_size = 2;
428
* swap extra data in request - assuming all data
429
* (if available) are arrays of 4 bytes components !
431
if (req->length > sz_xGLXVendorPrivateReq/4) {
432
int *data = (int *)(req+1);
433
int count = req->length - sz_xGLXVendorPrivateReq/4;
434
__GLX_SWAP_INT_ARRAY(data, count );
437
return( __glXVForwardPipe0WithReply( cl, pc ) );
440
int __glXVForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
442
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
443
__GLX_DECLARE_SWAP_VARIABLES;
445
__GLX_SWAP_SHORT(&req->length);
446
__GLX_SWAP_INT(&req->vendorCode);
447
__GLX_SWAP_INT(&req->contextTag);
449
swap_vec_element_size = 4;
452
* swap extra data in request - assuming all data
453
* (if available) are arrays of 4 bytes components !
455
if (req->length > sz_xGLXVendorPrivateReq/4) {
456
int *data = (int *)(req+1);
457
int count = req->length - sz_xGLXVendorPrivateReq/4;
458
__GLX_SWAP_INT_ARRAY(data, count );
461
return( __glXVForwardPipe0WithReply( cl, pc ) );
464
int __glXVForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
466
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
467
__GLX_DECLARE_SWAP_VARIABLES;
469
__GLX_SWAP_SHORT(&req->length);
470
__GLX_SWAP_INT(&req->vendorCode);
471
__GLX_SWAP_INT(&req->contextTag);
473
swap_vec_element_size = 8;
476
* swap extra data in request - assuming all data
477
* (if available) are arrays of 4 bytes components !
479
if (req->length > sz_xGLXVendorPrivateReq/4) {
480
int *data = (int *)(req+1);
481
int count = req->length - sz_xGLXVendorPrivateReq/4;
482
__GLX_SWAP_INT_ARRAY(data, count );
485
return( __glXVForwardPipe0WithReply( cl, pc ) );
488
int __glXVForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc )
490
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
491
__GLX_DECLARE_SWAP_VARIABLES;
493
__GLX_SWAP_SHORT(&req->length);
494
__GLX_SWAP_INT(&req->vendorCode);
495
__GLX_SWAP_INT(&req->contextTag);
497
swap_vec_element_size = 0;
500
* swap extra data in request - assuming all data
501
* (if available) are arrays of 4 bytes components !
503
if (req->length > sz_xGLXVendorPrivateReq/4) {
504
int *data = (int *)(req+1);
505
int count = req->length - sz_xGLXVendorPrivateReq/4;
506
__GLX_SWAP_INT_ARRAY(data, count );
509
return( __glXVForwardAllWithReply( cl, pc ) );
512
int __glXVForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
514
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
515
__GLX_DECLARE_SWAP_VARIABLES;
517
__GLX_SWAP_SHORT(&req->length);
518
__GLX_SWAP_INT(&req->vendorCode);
519
__GLX_SWAP_INT(&req->contextTag);
521
swap_vec_element_size = 2;
524
* swap extra data in request - assuming all data
525
* (if available) are arrays of 4 bytes components !
527
if (req->length > sz_xGLXVendorPrivateReq/4) {
528
int *data = (int *)(req+1);
529
int count = req->length - sz_xGLXVendorPrivateReq/4;
530
__GLX_SWAP_INT_ARRAY(data, count );
533
return( __glXVForwardAllWithReply( cl, pc ) );
536
int __glXVForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
538
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
539
__GLX_DECLARE_SWAP_VARIABLES;
541
__GLX_SWAP_SHORT(&req->length);
542
__GLX_SWAP_INT(&req->vendorCode);
543
__GLX_SWAP_INT(&req->contextTag);
545
swap_vec_element_size = 4;
548
* swap extra data in request - assuming all data
549
* (if available) are arrays of 4 bytes components !
551
if (req->length > sz_xGLXVendorPrivateReq/4) {
552
int *data = (int *)(req+1);
553
int count = req->length - sz_xGLXVendorPrivateReq/4;
554
__GLX_SWAP_INT_ARRAY(data, count );
557
return( __glXVForwardAllWithReply( cl, pc ) );
560
int __glXVForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
562
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
563
__GLX_DECLARE_SWAP_VARIABLES;
565
__GLX_SWAP_SHORT(&req->length);
566
__GLX_SWAP_INT(&req->vendorCode);
567
__GLX_SWAP_INT(&req->contextTag);
569
swap_vec_element_size = 8;
572
* swap extra data in request - assuming all data
573
* (if available) are arrays of 4 bytes components !
575
if (req->length > sz_xGLXVendorPrivateReq/4) {
576
int *data = (int *)(req+1);
577
int count = req->length - sz_xGLXVendorPrivateReq/4;
578
__GLX_SWAP_INT_ARRAY(data, count );
581
return( __glXVForwardAllWithReply( cl, pc ) );