1/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */ 2/* 3 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 4 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 5 * 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: 12 * 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. 17 * 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 24 * SOFTWARE. 25 * 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. 30 */ 31 32#ifdef HAVE_DMX_CONFIG_H 33#include <dmx-config.h> 34#endif 35 36#include "dmx.h" 37#include "dmxwindow.h" 38#include "dmxpixmap.h" 39#include "dmxfont.h" 40 41#include "glxserver.h" 42#include "glxext.h" 43#include "g_disptab.h" 44/* #include "g_disptab_EXT.h" */ 45#include "unpack.h" 46#include "glxutil.h" 47 48#include "GL/glxproto.h" 49 50#ifdef PANORAMIX 51#include "panoramiXsrv.h" 52#endif 53 54/* 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). 59 */ 60#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP) 61#define GetReqVendorPrivate(name, req) \ 62 WORD64ALIGN\ 63 if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\ 64 _XFlush(dpy);\ 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);\ 68 dpy->request++ 69 70#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ 71#define GetReqVendorPrivate(name, req) \ 72 WORD64ALIGN\ 73 if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\ 74 _XFlush(dpy);\ 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);\ 78 dpy->request++ 79#endif 80 81extern Display *GetBackEndDisplay( __GLXclientState *cl, int s ); 82extern int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s); 83 84static int swap_vec_element_size = 0; 85 86static void SendSwappedReply( ClientPtr client, 87 xGLXVendorPrivReply *reply, 88 char *buf, 89 int buf_size ) 90{ 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); 96 97 if ( (buf_size == 0) && (swap_vec_element_size > 0) ) { 98 /* 99 * the reply has single component - need to swap pad3 100 */ 101 if (swap_vec_element_size == 2) { 102 __GLX_SWAP_SHORT(&reply->pad3); 103 } 104 else if (swap_vec_element_size == 4) { 105 __GLX_SWAP_INT(&reply->pad3); 106 __GLX_SWAP_INT(&reply->pad4); 107 } 108 else if (swap_vec_element_size == 8) { 109 __GLX_SWAP_DOUBLE(&reply->pad3); 110 } 111 } 112 else if ( (buf_size > 0) && (swap_vec_element_size > 0) ) { 113 /* 114 * the reply has vector of elements which needs to be swapped 115 */ 116 int vsize = buf_size / swap_vec_element_size; 117 char *p = buf; 118 int i; 119 120 for (i=0; i<vsize; i++) { 121 if (swap_vec_element_size == 2) { 122 __GLX_SWAP_SHORT(p); 123 } 124 else if (swap_vec_element_size == 4) { 125 __GLX_SWAP_INT(p); 126 } 127 else if (swap_vec_element_size == 8) { 128 __GLX_SWAP_DOUBLE(p); 129 } 130 131 p += swap_vec_element_size; 132 } 133 134 __GLX_SWAP_INT(&reply->pad3); 135 __GLX_SWAP_INT(&reply->pad4); 136 __GLX_SWAP_INT(&reply->pad5); 137 __GLX_SWAP_INT(&reply->pad6); 138 139 } 140 141 WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)reply); 142 if (buf_size > 0) 143 WriteToClient(client, buf_size, (char *)buf); 144 145} 146 147int __glXVForwardSingleReq( __GLXclientState *cl, GLbyte *pc ) 148{ 149 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 150 xGLXVendorPrivateReq *be_req; 151 __GLXcontext *glxc; 152 int from_screen = 0; 153 int to_screen = 0; 154 int buf_size; 155 int s; 156 157 glxc = __glXLookupContextByTag(cl, req->contextTag); 158 if (!glxc) { 159 return 0; 160 } 161 from_screen = to_screen = glxc->pScreen->myNum; 162 163#ifdef PANORAMIX 164 if (!noPanoramiXExtension) { 165 from_screen = 0; 166 to_screen = screenInfo.numScreens - 1; 167 } 168#endif 169 170 pc += sz_xGLXVendorPrivateReq; 171 buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq; 172 173 /* 174 * just forward the request to back-end server(s) 175 */ 176 for (s=from_screen; s<=to_screen; s++) { 177 DMXScreenInfo *dmxScreen = &dmxScreens[s]; 178 Display *dpy = GetBackEndDisplay(cl,s); 179 180 LockDisplay(dpy); 181 GetReqVendorPrivate(GLXVendorPrivate,be_req); 182 be_req->reqType = dmxScreen->glxMajorOpcode; 183 be_req->glxCode = req->glxCode; 184 be_req->length = req->length; 185 be_req->vendorCode = req->vendorCode; 186 be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s); 187 if (buf_size > 0) 188 _XSend(dpy, (const char *)pc, buf_size); 189 UnlockDisplay(dpy); 190 SyncHandle(); 191 } 192 193 return Success; 194} 195 196int __glXVForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc ) 197{ 198 ClientPtr client = cl->client; 199 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 200 xGLXVendorPrivateReq *be_req; 201 xGLXVendorPrivReply reply; 202 xGLXVendorPrivReply be_reply; 203 __GLXcontext *glxc; 204 int buf_size; 205 char *be_buf = NULL; 206 int be_buf_size; 207 DMXScreenInfo *dmxScreen; 208 Display *dpy; 209 210 glxc = __glXLookupContextByTag(cl, req->contextTag); 211 if (!glxc) { 212 return __glXBadContext; 213 } 214 215 pc += sz_xGLXVendorPrivateReq; 216 buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq; 217 218 dmxScreen = &dmxScreens[glxc->pScreen->myNum]; 219 dpy = GetBackEndDisplay(cl, glxc->pScreen->myNum); 220 221 /* 222 * send the request to the first back-end server 223 */ 224 LockDisplay(dpy); 225 GetReqVendorPrivate(GLXVendorPrivate,be_req); 226 be_req->reqType = dmxScreen->glxMajorOpcode; 227 be_req->glxCode = req->glxCode; 228 be_req->length = req->length; 229 be_req->vendorCode = req->vendorCode; 230 be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag, glxc->pScreen->myNum); 231 if (buf_size > 0) 232 _XSend(dpy, (const char *)pc, buf_size); 233 234 /* 235 * get the reply from the back-end server 236 */ 237 _XReply(dpy, (xReply*) &be_reply, 0, False); 238 be_buf_size = be_reply.length << 2; 239 if (be_buf_size > 0) { 240 be_buf = (char *)malloc( be_buf_size ); 241 if (be_buf) { 242 _XRead(dpy, be_buf, be_buf_size); 243 } 244 else { 245 /* Throw data on the floor */ 246 _XEatData(dpy, be_buf_size); 247 return BadAlloc; 248 } 249 } 250 251 UnlockDisplay(dpy); 252 SyncHandle(); 253 254 /* 255 * send the reply to the client 256 */ 257 memcpy( &reply, &be_reply, sz_xGLXVendorPrivReply ); 258 reply.type = X_Reply; 259 reply.sequenceNumber = client->sequence; 260 261 if (client->swapped) { 262 SendSwappedReply( client, &reply, be_buf, be_buf_size ); 263 } 264 else { 265 WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)&reply); 266 if (be_buf_size > 0) 267 WriteToClient(client, be_buf_size, (char *)be_buf); 268 } 269 270 if (be_buf_size > 0) free(be_buf); 271 272 return Success; 273} 274 275int __glXVForwardAllWithReply( __GLXclientState *cl, GLbyte *pc ) 276{ 277 ClientPtr client = cl->client; 278 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 279 xGLXVendorPrivateReq *be_req; 280 xGLXVendorPrivReply reply; 281 xGLXVendorPrivReply be_reply; 282 __GLXcontext *glxc; 283 int buf_size; 284 char *be_buf = NULL; 285 int be_buf_size = 0; 286 int from_screen = 0; 287 int to_screen = 0; 288 int s; 289 290 DMXScreenInfo *dmxScreen; 291 Display *dpy; 292 293 glxc = __glXLookupContextByTag(cl, req->contextTag); 294 if (!glxc) { 295 return 0; 296 } 297 from_screen = to_screen = glxc->pScreen->myNum; 298 299#ifdef PANORAMIX 300 if (!noPanoramiXExtension) { 301 from_screen = 0; 302 to_screen = screenInfo.numScreens - 1; 303 } 304#endif 305 306 pc += sz_xGLXVendorPrivateReq; 307 buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq; 308 309 /* 310 * send the request to the first back-end server(s) 311 */ 312 for (s=to_screen; s>=from_screen; s--) { 313 dmxScreen = &dmxScreens[s]; 314 dpy = GetBackEndDisplay(cl,s); 315 316 LockDisplay(dpy); 317 GetReqVendorPrivate(GLXVendorPrivate,be_req); 318 be_req->reqType = dmxScreen->glxMajorOpcode; 319 be_req->glxCode = req->glxCode; 320 be_req->length = req->length; 321 be_req->vendorCode = req->vendorCode; 322 be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s); 323 if (buf_size > 0) 324 _XSend(dpy, (const char *)pc, buf_size); 325 326 /* 327 * get the reply from the back-end server 328 */ 329 _XReply(dpy, (xReply*) &be_reply, 0, False); 330 be_buf_size = be_reply.length << 2; 331 if (be_buf_size > 0) { 332 be_buf = (char *)malloc( be_buf_size ); 333 if (be_buf) { 334 _XRead(dpy, be_buf, be_buf_size); 335 } 336 else { 337 /* Throw data on the floor */ 338 _XEatData(dpy, be_buf_size); 339 return BadAlloc; 340 } 341 } 342 343 UnlockDisplay(dpy); 344 SyncHandle(); 345 346 if (s > from_screen && be_buf_size > 0) { 347 free(be_buf); 348 } 349 } 350 351 /* 352 * send the reply to the client 353 */ 354 memcpy( &reply, &be_reply, sz_xGLXVendorPrivReply ); 355 reply.type = X_Reply; 356 reply.sequenceNumber = client->sequence; 357 358 if (client->swapped) { 359 SendSwappedReply( client, &reply, be_buf, be_buf_size ); 360 } 361 else { 362 WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)&reply); 363 if (be_buf_size > 0) 364 WriteToClient(client, be_buf_size, (char *)be_buf); 365 } 366 367 if (be_buf_size > 0) free(be_buf); 368 369 return Success; 370} 371 372int __glXVForwardSingleReqSwap( __GLXclientState *cl, GLbyte *pc ) 373{ 374 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 375 __GLX_DECLARE_SWAP_VARIABLES; 376 377 __GLX_SWAP_SHORT(&req->length); 378 __GLX_SWAP_INT(&req->vendorCode); 379 __GLX_SWAP_INT(&req->contextTag); 380 381 swap_vec_element_size = 0; 382 383 return( __glXVForwardSingleReq( cl, pc ) ); 384} 385 386int __glXVForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc ) 387{ 388 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 389 __GLX_DECLARE_SWAP_VARIABLES; 390 __GLX_DECLARE_SWAP_ARRAY_VARIABLES; 391 392 __GLX_SWAP_SHORT(&req->length); 393 __GLX_SWAP_INT(&req->vendorCode); 394 __GLX_SWAP_INT(&req->contextTag); 395 396 swap_vec_element_size = 0; 397 398 /* 399 * swap extra data in request - assuming all data 400 * (if available) are arrays of 4 bytes components ! 401 */ 402 if (req->length > sz_xGLXVendorPrivateReq/4) { 403 int *data = (int *)(req+1); 404 int count = req->length - sz_xGLXVendorPrivateReq/4; 405 __GLX_SWAP_INT_ARRAY(data, count ); 406 } 407 408 return( __glXVForwardPipe0WithReply( cl, pc ) ); 409} 410 411int __glXVForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc ) 412{ 413 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 414 __GLX_DECLARE_SWAP_VARIABLES; 415 __GLX_DECLARE_SWAP_ARRAY_VARIABLES; 416 417 __GLX_SWAP_SHORT(&req->length); 418 __GLX_SWAP_INT(&req->vendorCode); 419 __GLX_SWAP_INT(&req->contextTag); 420 421 swap_vec_element_size = 2; 422 423 /* 424 * swap extra data in request - assuming all data 425 * (if available) are arrays of 4 bytes components ! 426 */ 427 if (req->length > sz_xGLXVendorPrivateReq/4) { 428 int *data = (int *)(req+1); 429 int count = req->length - sz_xGLXVendorPrivateReq/4; 430 __GLX_SWAP_INT_ARRAY(data, count ); 431 } 432 433 return( __glXVForwardPipe0WithReply( cl, pc ) ); 434} 435 436int __glXVForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc ) 437{ 438 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 439 __GLX_DECLARE_SWAP_VARIABLES; 440 __GLX_DECLARE_SWAP_ARRAY_VARIABLES; 441 442 __GLX_SWAP_SHORT(&req->length); 443 __GLX_SWAP_INT(&req->vendorCode); 444 __GLX_SWAP_INT(&req->contextTag); 445 446 swap_vec_element_size = 4; 447 448 /* 449 * swap extra data in request - assuming all data 450 * (if available) are arrays of 4 bytes components ! 451 */ 452 if (req->length > sz_xGLXVendorPrivateReq/4) { 453 int *data = (int *)(req+1); 454 int count = req->length - sz_xGLXVendorPrivateReq/4; 455 __GLX_SWAP_INT_ARRAY(data, count ); 456 } 457 458 return( __glXVForwardPipe0WithReply( cl, pc ) ); 459} 460 461int __glXVForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc ) 462{ 463 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 464 __GLX_DECLARE_SWAP_VARIABLES; 465 __GLX_DECLARE_SWAP_ARRAY_VARIABLES; 466 467 __GLX_SWAP_SHORT(&req->length); 468 __GLX_SWAP_INT(&req->vendorCode); 469 __GLX_SWAP_INT(&req->contextTag); 470 471 swap_vec_element_size = 8; 472 473 /* 474 * swap extra data in request - assuming all data 475 * (if available) are arrays of 4 bytes components ! 476 */ 477 if (req->length > sz_xGLXVendorPrivateReq/4) { 478 int *data = (int *)(req+1); 479 int count = req->length - sz_xGLXVendorPrivateReq/4; 480 __GLX_SWAP_INT_ARRAY(data, count ); 481 } 482 483 return( __glXVForwardPipe0WithReply( cl, pc ) ); 484} 485 486int __glXVForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc ) 487{ 488 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 489 __GLX_DECLARE_SWAP_VARIABLES; 490 __GLX_DECLARE_SWAP_ARRAY_VARIABLES; 491 492 __GLX_SWAP_SHORT(&req->length); 493 __GLX_SWAP_INT(&req->vendorCode); 494 __GLX_SWAP_INT(&req->contextTag); 495 496 swap_vec_element_size = 0; 497 498 /* 499 * swap extra data in request - assuming all data 500 * (if available) are arrays of 4 bytes components ! 501 */ 502 if (req->length > sz_xGLXVendorPrivateReq/4) { 503 int *data = (int *)(req+1); 504 int count = req->length - sz_xGLXVendorPrivateReq/4; 505 __GLX_SWAP_INT_ARRAY(data, count ); 506 } 507 508 return( __glXVForwardAllWithReply( cl, pc ) ); 509} 510 511int __glXVForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc ) 512{ 513 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 514 __GLX_DECLARE_SWAP_VARIABLES; 515 __GLX_DECLARE_SWAP_ARRAY_VARIABLES; 516 517 __GLX_SWAP_SHORT(&req->length); 518 __GLX_SWAP_INT(&req->vendorCode); 519 __GLX_SWAP_INT(&req->contextTag); 520 521 swap_vec_element_size = 2; 522 523 /* 524 * swap extra data in request - assuming all data 525 * (if available) are arrays of 4 bytes components ! 526 */ 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 ); 531 } 532 533 return( __glXVForwardAllWithReply( cl, pc ) ); 534} 535 536int __glXVForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc ) 537{ 538 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 539 __GLX_DECLARE_SWAP_VARIABLES; 540 __GLX_DECLARE_SWAP_ARRAY_VARIABLES; 541 542 __GLX_SWAP_SHORT(&req->length); 543 __GLX_SWAP_INT(&req->vendorCode); 544 __GLX_SWAP_INT(&req->contextTag); 545 546 swap_vec_element_size = 4; 547 548 /* 549 * swap extra data in request - assuming all data 550 * (if available) are arrays of 4 bytes components ! 551 */ 552 if (req->length > sz_xGLXVendorPrivateReq/4) { 553 int *data = (int *)(req+1); 554 int count = req->length - sz_xGLXVendorPrivateReq/4; 555 __GLX_SWAP_INT_ARRAY(data, count ); 556 } 557 558 return( __glXVForwardAllWithReply( cl, pc ) ); 559} 560 561int __glXVForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc ) 562{ 563 xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc; 564 __GLX_DECLARE_SWAP_VARIABLES; 565 __GLX_DECLARE_SWAP_ARRAY_VARIABLES; 566 567 __GLX_SWAP_SHORT(&req->length); 568 __GLX_SWAP_INT(&req->vendorCode); 569 __GLX_SWAP_INT(&req->contextTag); 570 571 swap_vec_element_size = 8; 572 573 /* 574 * swap extra data in request - assuming all data 575 * (if available) are arrays of 4 bytes components ! 576 */ 577 if (req->length > sz_xGLXVendorPrivateReq/4) { 578 int *data = (int *)(req+1); 579 int count = req->length - sz_xGLXVendorPrivateReq/4; 580 __GLX_SWAP_INT_ARRAY(data, count ); 581 } 582 583 return( __glXVForwardAllWithReply( cl, pc ) ); 584} 585 586