blob: 99a170d5cd5683f1287ff114fad72c6f8c6ed2a8 [file] [log] [blame]
Adam Jacksoncb3610e2004-10-25 21:09:16 +00001#ifndef __GLX_packsingle_h__
2#define __GLX_packsingle_h__
3
4/*
Adam Jacksondc8058c2008-09-19 17:16:53 -04005 * 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 Jacksoncb3610e2004-10-25 21:09:16 +000033
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ófcfe7f202008-10-13 14:31:49 +020051#define __GLX_SINGLE_DECLARE_VARIABLES() \
Kristian Høgsbergc356f582010-07-28 11:16:00 -040052 struct glx_context *gc = __glXGetCurrentContext(); \
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +020053 GLubyte *pc, *pixelHeaderPC; \
54 GLuint compsize, cmdlen; \
55 Display *dpy = gc->currentDpy; \
56 xGLXSingleReq *req
Adam Jacksoncb3610e2004-10-25 21:09:16 +000057
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +020058#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 Jacksoncb3610e2004-10-25 21:09:16 +000064
65/* Start a single command */
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +020066#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 Jacksoncb3610e2004-10-25 21:09:16 +000075
76/* End a single command */
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +020077#define __GLX_SINGLE_END() \
78 UnlockDisplay(dpy); \
79 SyncHandle(); \
80 }
Adam Jacksoncb3610e2004-10-25 21:09:16 +000081
82/* Store data to sending for a single command */
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +020083#define __GLX_SINGLE_PUT_CHAR(offset,a) \
84 *((INT8 *) (pc + offset)) = a
Adam Jacksoncb3610e2004-10-25 21:09:16 +000085
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +020086#define __GLX_SINGLE_PUT_SHORT(offset,a) \
87 *((INT16 *) (pc + offset)) = a
Adam Jacksoncb3610e2004-10-25 21:09:16 +000088
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +020089#define __GLX_SINGLE_PUT_LONG(offset,a) \
90 *((INT32 *) (pc + offset)) = a
Adam Jacksoncb3610e2004-10-25 21:09:16 +000091
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +020092#define __GLX_SINGLE_PUT_FLOAT(offset,a) \
93 *((FLOAT32 *) (pc + offset)) = a
Adam Jacksoncb3610e2004-10-25 21:09:16 +000094
Adam Jacksoncb3610e2004-10-25 21:09:16 +000095/* Read support macros */
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +020096#define __GLX_SINGLE_READ_XREPLY() \
97 (void) _XReply(dpy, (xReply*) &reply, 0, False)
Adam Jacksoncb3610e2004-10-25 21:09:16 +000098
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +020099#define __GLX_SINGLE_GET_RETVAL(a,cast) \
100 a = (cast) reply.retval
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000101
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +0200102#define __GLX_SINGLE_GET_SIZE(a) \
103 a = (GLint) reply.size
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000104
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +0200105#define __GLX_SINGLE_GET_CHAR(p) \
Matt Turner5ed32992015-06-23 18:41:38 -0700106 memcpy((p), &reply.pad3, 1);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000107
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +0200108#define __GLX_SINGLE_GET_SHORT(p) \
Matt Turner5ed32992015-06-23 18:41:38 -0700109 memcpy((p), &reply.pad3, 2);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000110
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +0200111#define __GLX_SINGLE_GET_LONG(p) \
Matt Turner5ed32992015-06-23 18:41:38 -0700112 memcpy((p), &reply.pad3, 4);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000113
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +0200114#define __GLX_SINGLE_GET_FLOAT(p) \
Matt Turner5ed32992015-06-23 18:41:38 -0700115 memcpy((p), &reply.pad3, 4);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000116
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +0200117#define __GLX_SINGLE_GET_DOUBLE(p) \
Matt Turner5ed32992015-06-23 18:41:38 -0700118 memcpy((p), &reply.pad3, 8);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000119
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000120/* Get an array of typed data */
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +0200121#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 Jacksoncb3610e2004-10-25 21:09:16 +0000127
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +0200128#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 Jacksoncb3610e2004-10-25 21:09:16 +0000134
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000135
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +0200136#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 Jacksoncb3610e2004-10-25 21:09:16 +0000145
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +0200146#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
147 _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000148
RALOVICH, Kristófcfe7f202008-10-13 14:31:49 +0200149#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
150 _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000151
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000152#endif /* !__GLX_packsingle_h__ */