Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 1 | #ifndef __GLX_packsingle_h__ |
| 2 | #define __GLX_packsingle_h__ |
| 3 | |
| 4 | /* |
Adam Jackson | dc8058c | 2008-09-19 17:16:53 -0400 | [diff] [blame] | 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 | */ |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 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 */ |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 51 | #define __GLX_SINGLE_DECLARE_VARIABLES() \ |
Kristian Høgsberg | c356f58 | 2010-07-28 11:16:00 -0400 | [diff] [blame] | 52 | struct glx_context *gc = __glXGetCurrentContext(); \ |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 53 | GLubyte *pc, *pixelHeaderPC; \ |
| 54 | GLuint compsize, cmdlen; \ |
| 55 | Display *dpy = gc->currentDpy; \ |
| 56 | xGLXSingleReq *req |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 57 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 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 |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 64 | |
| 65 | /* Start a single command */ |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 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) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 75 | |
| 76 | /* End a single command */ |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 77 | #define __GLX_SINGLE_END() \ |
| 78 | UnlockDisplay(dpy); \ |
| 79 | SyncHandle(); \ |
| 80 | } |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 81 | |
| 82 | /* Store data to sending for a single command */ |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 83 | #define __GLX_SINGLE_PUT_CHAR(offset,a) \ |
| 84 | *((INT8 *) (pc + offset)) = a |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 85 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 86 | #define __GLX_SINGLE_PUT_SHORT(offset,a) \ |
| 87 | *((INT16 *) (pc + offset)) = a |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 88 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 89 | #define __GLX_SINGLE_PUT_LONG(offset,a) \ |
| 90 | *((INT32 *) (pc + offset)) = a |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 91 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 92 | #define __GLX_SINGLE_PUT_FLOAT(offset,a) \ |
| 93 | *((FLOAT32 *) (pc + offset)) = a |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 94 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 95 | /* Read support macros */ |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 96 | #define __GLX_SINGLE_READ_XREPLY() \ |
| 97 | (void) _XReply(dpy, (xReply*) &reply, 0, False) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 98 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 99 | #define __GLX_SINGLE_GET_RETVAL(a,cast) \ |
| 100 | a = (cast) reply.retval |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 101 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 102 | #define __GLX_SINGLE_GET_SIZE(a) \ |
| 103 | a = (GLint) reply.size |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 104 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 105 | #define __GLX_SINGLE_GET_CHAR(p) \ |
Matt Turner | 5ed3299 | 2015-06-23 18:41:38 -0700 | [diff] [blame] | 106 | memcpy((p), &reply.pad3, 1); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 107 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 108 | #define __GLX_SINGLE_GET_SHORT(p) \ |
Matt Turner | 5ed3299 | 2015-06-23 18:41:38 -0700 | [diff] [blame] | 109 | memcpy((p), &reply.pad3, 2); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 110 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 111 | #define __GLX_SINGLE_GET_LONG(p) \ |
Matt Turner | 5ed3299 | 2015-06-23 18:41:38 -0700 | [diff] [blame] | 112 | memcpy((p), &reply.pad3, 4); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 113 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 114 | #define __GLX_SINGLE_GET_FLOAT(p) \ |
Matt Turner | 5ed3299 | 2015-06-23 18:41:38 -0700 | [diff] [blame] | 115 | memcpy((p), &reply.pad3, 4); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 116 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 117 | #define __GLX_SINGLE_GET_DOUBLE(p) \ |
Matt Turner | 5ed3299 | 2015-06-23 18:41:38 -0700 | [diff] [blame] | 118 | memcpy((p), &reply.pad3, 8); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 119 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 120 | /* Get an array of typed data */ |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 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 | } |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 127 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 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 | } |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 134 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 135 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 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); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 145 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 146 | #define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \ |
| 147 | _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 148 | |
RALOVICH, Kristóf | cfe7f20 | 2008-10-13 14:31:49 +0200 | [diff] [blame] | 149 | #define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \ |
| 150 | _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 151 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 152 | #endif /* !__GLX_packsingle_h__ */ |