1 | #ifdef HAVE_DIX_CONFIG_H
|
---|
2 | #include <dix-config.h>
|
---|
3 | #endif
|
---|
4 |
|
---|
5 | #ifndef __GLX_unpack_h__
|
---|
6 | #define __GLX_unpack_h__
|
---|
7 |
|
---|
8 | /*
|
---|
9 | ** License Applicability. Except to the extent portions of this file are
|
---|
10 | ** made subject to an alternative license as permitted in the SGI Free
|
---|
11 | ** Software License B, Version 1.1 (the "License"), the contents of this
|
---|
12 | ** file are subject only to the provisions of the License. You may not use
|
---|
13 | ** this file except in compliance with the License. You may obtain a copy
|
---|
14 | ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
---|
15 | ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
---|
16 | **
|
---|
17 | ** http://oss.sgi.com/projects/FreeB
|
---|
18 | **
|
---|
19 | ** Note that, as provided in the License, the Software is distributed on an
|
---|
20 | ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
---|
21 | ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
---|
22 | ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
---|
23 | ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
---|
24 | **
|
---|
25 | ** Original Code. The Original Code is: OpenGL Sample Implementation,
|
---|
26 | ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
---|
27 | ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
---|
28 | ** Copyright in any portions created by third parties is as indicated
|
---|
29 | ** elsewhere herein. All Rights Reserved.
|
---|
30 | **
|
---|
31 | ** Additional Notice Provisions: The application programming interfaces
|
---|
32 | ** established by SGI in conjunction with the Original Code are The
|
---|
33 | ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
---|
34 | ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
---|
35 | ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
---|
36 | ** Window System(R) (Version 1.3), released October 19, 1998. This software
|
---|
37 | ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
---|
38 | ** published by SGI, but has not been independently verified as being
|
---|
39 | ** compliant with the OpenGL(R) version 1.2.1 Specification.
|
---|
40 | **
|
---|
41 | */
|
---|
42 |
|
---|
43 | #define __GLX_PAD(s) (((s)+3) & (GLuint)~3)
|
---|
44 |
|
---|
45 | /*
|
---|
46 | ** Fetch the context-id out of a SingleReq request pointed to by pc.
|
---|
47 | */
|
---|
48 | #define __GLX_GET_SINGLE_CONTEXT_TAG(pc) (((xGLXSingleReq*)pc)->contextTag)
|
---|
49 | #define __GLX_GET_VENDPRIV_CONTEXT_TAG(pc) (((xGLXVendorPrivateReq*)pc)->contextTag)
|
---|
50 |
|
---|
51 | /*
|
---|
52 | ** Fetch a double from potentially unaligned memory.
|
---|
53 | */
|
---|
54 | #ifdef __GLX_ALIGN64
|
---|
55 | #define __GLX_MEM_COPY(dst,src,n) if (src && dst) memcpy(dst,src,n)
|
---|
56 | #define __GLX_GET_DOUBLE(dst,src) __GLX_MEM_COPY(&dst,src,8)
|
---|
57 | #else
|
---|
58 | #define __GLX_GET_DOUBLE(dst,src) (dst) = *((GLdouble*)(src))
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | extern void __glXMemInit(void);
|
---|
62 |
|
---|
63 | extern xGLXSingleReply __glXReply;
|
---|
64 |
|
---|
65 | #define __GLX_BEGIN_REPLY(size) \
|
---|
66 | __glXReply.length = __GLX_PAD(size) >> 2; \
|
---|
67 | __glXReply.type = X_Reply; \
|
---|
68 | __glXReply.sequenceNumber = client->sequence;
|
---|
69 |
|
---|
70 | #define __GLX_SEND_HEADER() \
|
---|
71 | WriteToClient( client, sz_xGLXSingleReply, (char *)&__glXReply);
|
---|
72 |
|
---|
73 | #define __GLX_PUT_RETVAL(a) \
|
---|
74 | __glXReply.retval = (a);
|
---|
75 |
|
---|
76 | #define __GLX_PUT_SIZE(a) \
|
---|
77 | __glXReply.size = (a);
|
---|
78 |
|
---|
79 | #define __GLX_PUT_RENDERMODE(m) \
|
---|
80 | __glXReply.pad3 = (m)
|
---|
81 |
|
---|
82 | /*
|
---|
83 | ** Get a buffer to hold returned data, with the given alignment. If we have
|
---|
84 | ** to realloc, allocate size+align, in case the pointer has to be bumped for
|
---|
85 | ** alignment. The answerBuffer should already be aligned.
|
---|
86 | **
|
---|
87 | ** NOTE: the cast (long)res below assumes a long is large enough to hold a
|
---|
88 | ** pointer.
|
---|
89 | */
|
---|
90 | #define __GLX_GET_ANSWER_BUFFER(res,cl,size,align) \
|
---|
91 | if ((size) > sizeof(answerBuffer)) { \
|
---|
92 | int bump; \
|
---|
93 | if ((cl)->returnBufSize < (size)+(align)) { \
|
---|
94 | (cl)->returnBuf = (GLbyte*)Xrealloc((cl)->returnBuf, \
|
---|
95 | (size)+(align)); \
|
---|
96 | if (!(cl)->returnBuf) { \
|
---|
97 | return BadAlloc; \
|
---|
98 | } \
|
---|
99 | (cl)->returnBufSize = (size)+(align); \
|
---|
100 | } \
|
---|
101 | res = (char*)cl->returnBuf; \
|
---|
102 | bump = (long)(res) % (align); \
|
---|
103 | if (bump) res += (align) - (bump); \
|
---|
104 | } else { \
|
---|
105 | res = (char *)answerBuffer; \
|
---|
106 | }
|
---|
107 |
|
---|
108 | #define __GLX_PUT_BYTE() \
|
---|
109 | *(GLbyte *)&__glXReply.pad3 = *(GLbyte *)answer
|
---|
110 |
|
---|
111 | #define __GLX_PUT_SHORT() \
|
---|
112 | *(GLshort *)&__glXReply.pad3 = *(GLshort *)answer
|
---|
113 |
|
---|
114 | #define __GLX_PUT_INT() \
|
---|
115 | *(GLint *)&__glXReply.pad3 = *(GLint *)answer
|
---|
116 |
|
---|
117 | #define __GLX_PUT_FLOAT() \
|
---|
118 | *(GLfloat *)&__glXReply.pad3 = *(GLfloat *)answer
|
---|
119 |
|
---|
120 | #define __GLX_PUT_DOUBLE() \
|
---|
121 | *(GLdouble *)&__glXReply.pad3 = *(GLdouble *)answer
|
---|
122 |
|
---|
123 | #define __GLX_SEND_BYTE_ARRAY(len) \
|
---|
124 | WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT8), (char *)answer)
|
---|
125 |
|
---|
126 | #define __GLX_SEND_SHORT_ARRAY(len) \
|
---|
127 | WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT16), (char *)answer)
|
---|
128 |
|
---|
129 | #define __GLX_SEND_INT_ARRAY(len) \
|
---|
130 | WriteToClient(client, (len)*__GLX_SIZE_INT32, (char *)answer)
|
---|
131 |
|
---|
132 | #define __GLX_SEND_FLOAT_ARRAY(len) \
|
---|
133 | WriteToClient(client, (len)*__GLX_SIZE_FLOAT32, (char *)answer)
|
---|
134 |
|
---|
135 | #define __GLX_SEND_DOUBLE_ARRAY(len) \
|
---|
136 | WriteToClient(client, (len)*__GLX_SIZE_FLOAT64, (char *)answer)
|
---|
137 |
|
---|
138 |
|
---|
139 | #define __GLX_SEND_VOID_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
|
---|
140 | #define __GLX_SEND_UBYTE_ARRAY(len) __GLX_SEND_BYTE_ARRAY(len)
|
---|
141 | #define __GLX_SEND_USHORT_ARRAY(len) __GLX_SEND_SHORT_ARRAY(len)
|
---|
142 | #define __GLX_SEND_UINT_ARRAY(len) __GLX_SEND_INT_ARRAY(len)
|
---|
143 |
|
---|
144 | /*
|
---|
145 | ** PERFORMANCE NOTE:
|
---|
146 | ** Machine dependent optimizations abound here; these swapping macros can
|
---|
147 | ** conceivably be replaced with routines that do the job faster.
|
---|
148 | */
|
---|
149 | #define __GLX_DECLARE_SWAP_VARIABLES \
|
---|
150 | GLbyte sw
|
---|
151 |
|
---|
152 | #define __GLX_DECLARE_SWAP_ARRAY_VARIABLES \
|
---|
153 | GLbyte *swapPC; \
|
---|
154 | GLbyte *swapEnd
|
---|
155 |
|
---|
156 |
|
---|
157 | #define __GLX_SWAP_INT(pc) \
|
---|
158 | sw = ((GLbyte *)(pc))[0]; \
|
---|
159 | ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
|
---|
160 | ((GLbyte *)(pc))[3] = sw; \
|
---|
161 | sw = ((GLbyte *)(pc))[1]; \
|
---|
162 | ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
|
---|
163 | ((GLbyte *)(pc))[2] = sw;
|
---|
164 |
|
---|
165 | #define __GLX_SWAP_SHORT(pc) \
|
---|
166 | sw = ((GLbyte *)(pc))[0]; \
|
---|
167 | ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[1]; \
|
---|
168 | ((GLbyte *)(pc))[1] = sw;
|
---|
169 |
|
---|
170 | #define __GLX_SWAP_DOUBLE(pc) \
|
---|
171 | sw = ((GLbyte *)(pc))[0]; \
|
---|
172 | ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[7]; \
|
---|
173 | ((GLbyte *)(pc))[7] = sw; \
|
---|
174 | sw = ((GLbyte *)(pc))[1]; \
|
---|
175 | ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[6]; \
|
---|
176 | ((GLbyte *)(pc))[6] = sw; \
|
---|
177 | sw = ((GLbyte *)(pc))[2]; \
|
---|
178 | ((GLbyte *)(pc))[2] = ((GLbyte *)(pc))[5]; \
|
---|
179 | ((GLbyte *)(pc))[5] = sw; \
|
---|
180 | sw = ((GLbyte *)(pc))[3]; \
|
---|
181 | ((GLbyte *)(pc))[3] = ((GLbyte *)(pc))[4]; \
|
---|
182 | ((GLbyte *)(pc))[4] = sw;
|
---|
183 |
|
---|
184 | #define __GLX_SWAP_FLOAT(pc) \
|
---|
185 | sw = ((GLbyte *)(pc))[0]; \
|
---|
186 | ((GLbyte *)(pc))[0] = ((GLbyte *)(pc))[3]; \
|
---|
187 | ((GLbyte *)(pc))[3] = sw; \
|
---|
188 | sw = ((GLbyte *)(pc))[1]; \
|
---|
189 | ((GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; \
|
---|
190 | ((GLbyte *)(pc))[2] = sw;
|
---|
191 |
|
---|
192 | #define __GLX_SWAP_INT_ARRAY(pc, count) \
|
---|
193 | swapPC = ((GLbyte *)(pc)); \
|
---|
194 | swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT32;\
|
---|
195 | while (swapPC < swapEnd) { \
|
---|
196 | __GLX_SWAP_INT(swapPC); \
|
---|
197 | swapPC += __GLX_SIZE_INT32; \
|
---|
198 | }
|
---|
199 |
|
---|
200 | #define __GLX_SWAP_SHORT_ARRAY(pc, count) \
|
---|
201 | swapPC = ((GLbyte *)(pc)); \
|
---|
202 | swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_INT16;\
|
---|
203 | while (swapPC < swapEnd) { \
|
---|
204 | __GLX_SWAP_SHORT(swapPC); \
|
---|
205 | swapPC += __GLX_SIZE_INT16; \
|
---|
206 | }
|
---|
207 |
|
---|
208 | #define __GLX_SWAP_DOUBLE_ARRAY(pc, count) \
|
---|
209 | swapPC = ((GLbyte *)(pc)); \
|
---|
210 | swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT64;\
|
---|
211 | while (swapPC < swapEnd) { \
|
---|
212 | __GLX_SWAP_DOUBLE(swapPC); \
|
---|
213 | swapPC += __GLX_SIZE_FLOAT64; \
|
---|
214 | }
|
---|
215 |
|
---|
216 | #define __GLX_SWAP_FLOAT_ARRAY(pc, count) \
|
---|
217 | swapPC = ((GLbyte *)(pc)); \
|
---|
218 | swapEnd = ((GLbyte *)(pc)) + (count)*__GLX_SIZE_FLOAT32;\
|
---|
219 | while (swapPC < swapEnd) { \
|
---|
220 | __GLX_SWAP_FLOAT(swapPC); \
|
---|
221 | swapPC += __GLX_SIZE_FLOAT32; \
|
---|
222 | }
|
---|
223 |
|
---|
224 | #define __GLX_SWAP_REPLY_HEADER() \
|
---|
225 | __GLX_SWAP_SHORT(&__glXReply.sequenceNumber); \
|
---|
226 | __GLX_SWAP_INT(&__glXReply.length);
|
---|
227 |
|
---|
228 | #define __GLX_SWAP_REPLY_RETVAL() \
|
---|
229 | __GLX_SWAP_INT(&__glXReply.retval)
|
---|
230 |
|
---|
231 | #define __GLX_SWAP_REPLY_SIZE() \
|
---|
232 | __GLX_SWAP_INT(&__glXReply.size)
|
---|
233 |
|
---|
234 | #endif /* !__GLX_unpack_h__ */
|
---|
235 |
|
---|
236 |
|
---|
237 |
|
---|
238 |
|
---|
239 |
|
---|