OSDN Git Service

Remove CVS keywords.
[android-x86/external-mesa.git] / src / glx / x11 / packsingle.h
1 #ifndef __GLX_packsingle_h__
2 #define __GLX_packsingle_h__
3
4 /*
5 ** License Applicability. Except to the extent portions of this file are
6 ** made subject to an alternative license as permitted in the SGI Free
7 ** Software License B, Version 1.1 (the "License"), the contents of this
8 ** file are subject only to the provisions of the License. You may not use
9 ** this file except in compliance with the License. You may obtain a copy
10 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
11 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
12 ** 
13 ** http://oss.sgi.com/projects/FreeB
14 ** 
15 ** Note that, as provided in the License, the Software is distributed on an
16 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
17 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
18 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
19 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
20 ** 
21 ** Original Code. The Original Code is: OpenGL Sample Implementation,
22 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
23 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
24 ** Copyright in any portions created by third parties is as indicated
25 ** elsewhere herein. All Rights Reserved.
26 ** 
27 ** Additional Notice Provisions: The application programming interfaces
28 ** established by SGI in conjunction with the Original Code are The
29 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
30 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
31 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
32 ** Window System(R) (Version 1.3), released October 19, 1998. This software
33 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
34 ** published by SGI, but has not been independently verified as being
35 ** compliant with the OpenGL(R) version 1.2.1 Specification.
36 **
37 */
38
39 #include "packrender.h"
40
41 /*
42 ** The macros in this header convert wire protocol data types to the client
43 ** machine's native data types.  The header is part of the porting layer of
44 ** the client library, and it is intended that hardware vendors will rewrite
45 ** this header to suit their own machines.
46 */
47
48 /*
49 ** Dummy define to make the GetReqExtra macro happy.  The value is not
50 ** used, but instead the code in __GLX_SINGLE_BEGIN issues its own store
51 ** to req->reqType with the proper code (our extension code).
52 */
53 #define X_GLXSingle 0
54
55 /* Declare common variables used during a single command */
56 #define __GLX_SINGLE_DECLARE_VARIABLES()         \
57     __GLXcontext *gc = __glXGetCurrentContext(); \
58     GLubyte *pc, *pixelHeaderPC;                 \
59     GLuint compsize, cmdlen;                     \
60     Display *dpy = gc->currentDpy;               \
61     xGLXSingleReq *req
62
63 #define __GLX_SINGLE_LOAD_VARIABLES() \
64     pc = gc->pc;           \
65     /* Muffle compilers */                   \
66     pixelHeaderPC = 0;  (void)pixelHeaderPC; \
67     compsize = 0;       (void)compsize;      \
68     cmdlen = 0;         (void)cmdlen
69
70 /* Start a single command */
71 #define __GLX_SINGLE_BEGIN(opcode,bytes)           \
72     if (dpy) {                                     \
73         (void) __glXFlushRenderBuffer(gc, pc);     \
74         LockDisplay(dpy);                          \
75         GetReqExtra(GLXSingle,bytes,req);          \
76         req->reqType = gc->majorOpcode;            \
77         req->glxCode = opcode;                     \
78         req->contextTag = gc->currentContextTag;   \
79         pc = ((GLubyte *)(req) + sz_xGLXSingleReq)
80
81 /* End a single command */
82 #define __GLX_SINGLE_END()                         \
83         UnlockDisplay(dpy);                        \
84         SyncHandle();                              \
85     }
86
87 /* Store data to sending for a single command */
88 #define __GLX_SINGLE_PUT_CHAR(offset,a) \
89     *((INT8 *) (pc + offset)) = a
90
91 #ifndef CRAY
92 #define __GLX_SINGLE_PUT_SHORT(offset,a) \
93     *((INT16 *) (pc + offset)) = a
94
95 #define __GLX_SINGLE_PUT_LONG(offset,a) \
96     *((INT32 *) (pc + offset)) = a
97
98 #define __GLX_SINGLE_PUT_FLOAT(offset,a) \
99     *((FLOAT32 *) (pc + offset)) = a
100
101 #else
102 #define __GLX_SINGLE_PUT_SHORT(offset,a) \
103     { GLubyte *cp = (pc+offset); \
104       int shift = (64-16) - ((int)(cp) >> (64-6)); \
105       *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
106
107 #define __GLX_SINGLE_PUT_LONG(offset,a) \
108     { GLubyte *cp = (pc+offset); \
109       int shift = (64-32) - ((int)(cp) >> (64-6)); \
110       *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
111
112 #define __GLX_SINGLE_PUT_FLOAT(offset,a) \
113     gl_put_float(pc + offset, a)
114 #endif
115
116 /* Read support macros */
117 #define __GLX_SINGLE_READ_XREPLY()                  \
118     (void) _XReply(dpy, (xReply*) &reply, 0, False)
119
120 #define __GLX_SINGLE_GET_RETVAL(a,cast) \
121     a = (cast) reply.retval
122
123 #define __GLX_SINGLE_GET_SIZE(a) \
124     a = (GLint) reply.size
125
126 #ifndef _CRAY
127 #define __GLX_SINGLE_GET_CHAR(p) \
128     *p = *(GLbyte *)&reply.pad3;
129
130 #define __GLX_SINGLE_GET_SHORT(p) \
131     *p = *(GLshort *)&reply.pad3;
132
133 #define __GLX_SINGLE_GET_LONG(p) \
134     *p = *(GLint *)&reply.pad3;
135
136 #define __GLX_SINGLE_GET_FLOAT(p) \
137     *p = *(GLfloat *)&reply.pad3;
138
139 #else
140 #define __GLX_SINGLE_GET_CHAR(p) \
141     *p = reply.pad3 >> 24;
142
143 #define __GLX_SINGLE_GET_SHORT(p) \
144     {int t = reply.pad3 >> 16; \
145      *p = (t & 0x8000) ? (t | ~0xffff) : (t & 0xffff);}
146
147 #define __GLX_SINGLE_GET_LONG(p) \
148     {int t = reply.pad3; \
149      *p = (t & 0x80000000) ? (t | ~0xffffffff) : (t & 0xffffffff);}
150
151 #define PAD3OFFSET 16
152 #define __GLX_SINGLE_GET_FLOAT(p) \
153     *p = gl_ntoh_float((GLubyte *)&reply + PAD3OFFSET);
154
155 #define __GLX_SINGLE_GET_DOUBLE(p) \
156     *p = gl_ntoh_double((GLubyte *)&reply + PAD3OFFSET);
157
158 extern float gl_ntoh_float(GLubyte *);
159 extern float gl_ntoh_double(GLubyte *);
160 #endif
161
162 #ifndef _CRAY
163
164 #ifdef __GLX_ALIGN64
165 #define __GLX_SINGLE_GET_DOUBLE(p) \
166     __GLX_MEM_COPY(p, &reply.pad3, 8)
167 #else
168 #define __GLX_SINGLE_GET_DOUBLE(p) \
169     *p = *(GLdouble *)&reply.pad3
170 #endif
171
172 #endif
173           
174 /* Get an array of typed data */
175 #define __GLX_SINGLE_GET_VOID_ARRAY(a,alen)     \
176 {                                               \
177     GLint slop = alen*__GLX_SIZE_INT8 & 3;      \
178     _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
179     if (slop) _XEatData(dpy,4-slop);            \
180 }
181
182 #define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen)     \
183 {                                               \
184     GLint slop = alen*__GLX_SIZE_INT8 & 3;      \
185     _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
186     if (slop) _XEatData(dpy,4-slop);            \
187 }
188                                         
189
190 #define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen)    \
191 {                                               \
192     GLint slop = (alen*__GLX_SIZE_INT16) & 3;   \
193     _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16);\
194     if (slop) _XEatData(dpy,4-slop);            \
195 }
196
197 #define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \
198     _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32);        
199
200 #ifndef _CRAY
201 #define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
202     _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32);      
203
204 #define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
205     _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64);      
206
207 #else
208 #define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
209     gl_get_float_array(dpy,a,alen);
210
211 #define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
212     gl_get_double_array(dpy, a, alen);
213
214 extern void gl_get_float_array(Display *dpy, float *a, int alen);
215 extern void gl_get_double_array(Display *dpy, double *a, int alen);
216 #endif
217
218 #endif /* !__GLX_packsingle_h__ */