1 #ifndef __GLX_packsingle_h__ 2 #define __GLX_packsingle_h__ 3 4 /* 5 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 6 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a 9 * copy of this software and associated documentation files (the "Software"), 10 * to deal in the Software without restriction, including without limitation 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 * and/or sell copies of the Software, and to permit persons to whom the 13 * Software is furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice including the dates of first publication and 16 * either this permission notice or a reference to 17 * http://oss.sgi.com/projects/FreeB/ 18 * shall be included in all copies or substantial portions of the Software. 19 * 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 25 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 * SOFTWARE. 27 * 28 * Except as contained in this notice, the name of Silicon Graphics, Inc. 29 * shall not be used in advertising or otherwise to promote the sale, use or 30 * other dealings in this Software without prior written authorization from 31 * Silicon Graphics, Inc. 32 */ 33 34 #include "packrender.h" 35 36 /* 37 ** The macros in this header convert wire protocol data types to the client 38 ** machine's native data types. The header is part of the porting layer of 39 ** the client library, and it is intended that hardware vendors will rewrite 40 ** this header to suit their own machines. 41 */ 42 43 /* 44 ** Dummy define to make the GetReqExtra macro happy. The value is not 45 ** used, but instead the code in __GLX_SINGLE_BEGIN issues its own store 46 ** to req->reqType with the proper code (our extension code). 47 */ 48 #define X_GLXSingle 0 49 50 /* Declare common variables used during a single command */ 51 #define __GLX_SINGLE_DECLARE_VARIABLES() \ 52 struct glx_context *gc = __glXGetCurrentContext(); \ 53 GLubyte *pc, *pixelHeaderPC; \ 54 GLuint compsize, cmdlen; \ 55 Display *dpy = gc->currentDpy; \ 56 xGLXSingleReq *req 57 58 #define __GLX_SINGLE_LOAD_VARIABLES() \ 59 pc = gc->pc; \ 60 /* Muffle compilers */ \ 61 pixelHeaderPC = 0; (void)pixelHeaderPC; \ 62 compsize = 0; (void)compsize; \ 63 cmdlen = 0; (void)cmdlen 64 65 /* Start a single command */ 66 #define __GLX_SINGLE_BEGIN(opcode,bytes) \ 67 if (dpy) { \ 68 (void) __glXFlushRenderBuffer(gc, pc); \ 69 LockDisplay(dpy); \ 70 GetReqExtra(GLXSingle,bytes,req); \ 71 req->reqType = gc->majorOpcode; \ 72 req->glxCode = opcode; \ 73 req->contextTag = gc->currentContextTag; \ 74 pc = ((GLubyte *)(req) + sz_xGLXSingleReq) 75 76 /* End a single command */ 77 #define __GLX_SINGLE_END() \ 78 UnlockDisplay(dpy); \ 79 SyncHandle(); \ 80 } 81 82 /* Store data to sending for a single command */ 83 #define __GLX_SINGLE_PUT_CHAR(offset,a) \ 84 *((INT8 *) (pc + offset)) = a 85 86 #define __GLX_SINGLE_PUT_SHORT(offset,a) \ 87 *((INT16 *) (pc + offset)) = a 88 89 #define __GLX_SINGLE_PUT_LONG(offset,a) \ 90 *((INT32 *) (pc + offset)) = a 91 92 #define __GLX_SINGLE_PUT_FLOAT(offset,a) \ 93 *((FLOAT32 *) (pc + offset)) = a 94 95 /* Read support macros */ 96 #define __GLX_SINGLE_READ_XREPLY() \ 97 (void) _XReply(dpy, (xReply*) &reply, 0, False) 98 99 #define __GLX_SINGLE_GET_RETVAL(a,cast) \ 100 a = (cast) reply.retval 101 102 #define __GLX_SINGLE_GET_SIZE(a) \ 103 a = (GLint) reply.size 104 105 #define __GLX_SINGLE_GET_CHAR(p) \ 106 memcpy((p), &reply.pad3, 1); 107 108 #define __GLX_SINGLE_GET_SHORT(p) \ 109 memcpy((p), &reply.pad3, 2); 110 111 #define __GLX_SINGLE_GET_LONG(p) \ 112 memcpy((p), &reply.pad3, 4); 113 114 #define __GLX_SINGLE_GET_FLOAT(p) \ 115 memcpy((p), &reply.pad3, 4); 116 117 #define __GLX_SINGLE_GET_DOUBLE(p) \ 118 memcpy((p), &reply.pad3, 8); 119 120 /* Get an array of typed data */ 121 #define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \ 122 { \ 123 GLint slop = alen*__GLX_SIZE_INT8 & 3; \ 124 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ 125 if (slop) _XEatData(dpy,4-slop); \ 126 } 127 128 #define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \ 129 { \ 130 GLint slop = alen*__GLX_SIZE_INT8 & 3; \ 131 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ 132 if (slop) _XEatData(dpy,4-slop); \ 133 } 134 135 136 #define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \ 137 { \ 138 GLint slop = (alen*__GLX_SIZE_INT16) & 3; \ 139 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16); \ 140 if (slop) _XEatData(dpy,4-slop); \ 141 } 142 143 #define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \ 144 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32); 145 146 #define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \ 147 _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32); 148 149 #define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \ 150 _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64); 151 152 #endif /* !__GLX_packsingle_h__ */ 153