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 * SPDX-License-Identifier: SGI-B-2.0 9 */ 10 11 #include "packrender.h" 12 13 /* 14 ** The macros in this header convert wire protocol data types to the client 15 ** machine's native data types. The header is part of the porting layer of 16 ** the client library, and it is intended that hardware vendors will rewrite 17 ** this header to suit their own machines. 18 */ 19 20 /* 21 ** Dummy define to make the GetReqExtra macro happy. The value is not 22 ** used, but instead the code in __GLX_SINGLE_BEGIN issues its own store 23 ** to req->reqType with the proper code (our extension code). 24 */ 25 #define X_GLXSingle 0 26 27 /* Declare common variables used during a single command */ 28 #define __GLX_SINGLE_DECLARE_VARIABLES() \ 29 struct glx_context *gc = __glXGetCurrentContext(); \ 30 GLubyte *pc, *pixelHeaderPC; \ 31 GLuint compsize, cmdlen; \ 32 Display *dpy = gc->currentDpy; \ 33 xGLXSingleReq *req 34 35 #define __GLX_SINGLE_LOAD_VARIABLES() \ 36 pc = gc->pc; \ 37 /* Muffle compilers */ \ 38 pixelHeaderPC = NULL; (void)pixelHeaderPC; \ 39 compsize = 0; (void)compsize; \ 40 cmdlen = 0; (void)cmdlen 41 42 /* Start a single command */ 43 #define __GLX_SINGLE_BEGIN(opcode,bytes) \ 44 if (dpy) { \ 45 (void) __glXFlushRenderBuffer(gc, pc); \ 46 LockDisplay(dpy); \ 47 GetReqExtra(GLXSingle,bytes,req); \ 48 req->reqType = gc->majorOpcode; \ 49 req->glxCode = opcode; \ 50 req->contextTag = gc->currentContextTag; \ 51 pc = ((GLubyte *)(req) + sz_xGLXSingleReq) 52 53 /* End a single command */ 54 #define __GLX_SINGLE_END() \ 55 UnlockDisplay(dpy); \ 56 SyncHandle(); \ 57 } 58 59 /* Store data to sending for a single command */ 60 #define __GLX_SINGLE_PUT_CHAR(offset,a) \ 61 *((INT8 *) (pc + offset)) = a 62 63 #define __GLX_SINGLE_PUT_SHORT(offset,a) \ 64 *((INT16 *) (pc + offset)) = a 65 66 #define __GLX_SINGLE_PUT_LONG(offset,a) \ 67 *((INT32 *) (pc + offset)) = a 68 69 #define __GLX_SINGLE_PUT_FLOAT(offset,a) \ 70 *((FLOAT32 *) (pc + offset)) = a 71 72 /* Read support macros */ 73 #define __GLX_SINGLE_READ_XREPLY() \ 74 (void) _XReply(dpy, (xReply*) &reply, 0, False) 75 76 #define __GLX_SINGLE_GET_RETVAL(a,cast) \ 77 a = (cast) reply.retval 78 79 #define __GLX_SINGLE_GET_SIZE(a) \ 80 a = (GLint) reply.size 81 82 #define __GLX_SINGLE_GET_CHAR(p) \ 83 memcpy((p), &reply.pad3, 1); 84 85 #define __GLX_SINGLE_GET_SHORT(p) \ 86 memcpy((p), &reply.pad3, 2); 87 88 #define __GLX_SINGLE_GET_LONG(p) \ 89 memcpy((p), &reply.pad3, 4); 90 91 #define __GLX_SINGLE_GET_FLOAT(p) \ 92 memcpy((p), &reply.pad3, 4); 93 94 #define __GLX_SINGLE_GET_DOUBLE(p) \ 95 memcpy((p), &reply.pad3, 8); 96 97 /* Get an array of typed data */ 98 #define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \ 99 { \ 100 GLint slop = alen*__GLX_SIZE_INT8 & 3; \ 101 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ 102 if (slop) _XEatData(dpy,4-slop); \ 103 } 104 105 #define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \ 106 { \ 107 GLint slop = alen*__GLX_SIZE_INT8 & 3; \ 108 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \ 109 if (slop) _XEatData(dpy,4-slop); \ 110 } 111 112 113 #define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \ 114 { \ 115 GLint slop = (alen*__GLX_SIZE_INT16) & 3; \ 116 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16); \ 117 if (slop) _XEatData(dpy,4-slop); \ 118 } 119 120 #define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \ 121 _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32); 122 123 #define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \ 124 _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32); 125 126 #define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \ 127 _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64); 128 129 #endif /* !__GLX_packsingle_h__ */ 130