2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
31 #include "glxserver.h"
33 #include "g_disptab.h"
36 __glEvalComputeK(GLenum target
)
39 case GL_MAP1_VERTEX_4
:
41 case GL_MAP1_TEXTURE_COORD_4
:
42 case GL_MAP2_VERTEX_4
:
44 case GL_MAP2_TEXTURE_COORD_4
:
46 case GL_MAP1_VERTEX_3
:
47 case GL_MAP1_TEXTURE_COORD_3
:
49 case GL_MAP2_VERTEX_3
:
50 case GL_MAP2_TEXTURE_COORD_3
:
53 case GL_MAP1_TEXTURE_COORD_2
:
54 case GL_MAP2_TEXTURE_COORD_2
:
56 case GL_MAP1_TEXTURE_COORD_1
:
57 case GL_MAP2_TEXTURE_COORD_1
:
67 __glXDispSwap_Map1f(GLbyte
* pc
)
70 GLfloat u1
, u2
, *points
;
74 __GLX_DECLARE_SWAP_VARIABLES
;
75 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
77 __GLX_SWAP_INT(pc
+ 0);
78 __GLX_SWAP_INT(pc
+ 12);
79 __GLX_SWAP_FLOAT(pc
+ 4);
80 __GLX_SWAP_FLOAT(pc
+ 8);
82 target
= *(GLenum
*) (pc
+ 0);
83 order
= *(GLint
*) (pc
+ 12);
84 u1
= *(GLfloat
*) (pc
+ 4);
85 u2
= *(GLfloat
*) (pc
+ 8);
86 points
= (GLfloat
*) (pc
+ 16);
87 k
= __glEvalComputeK(target
);
89 if (order
<= 0 || k
< 0) {
90 /* Erroneous command. */
96 __GLX_SWAP_FLOAT_ARRAY(points
, compsize
);
101 __glXDispSwap_Map2f(GLbyte
* pc
)
103 GLint uorder
, vorder
, ustride
, vstride
, k
;
104 GLfloat u1
, u2
, v1
, v2
, *points
;
108 __GLX_DECLARE_SWAP_VARIABLES
;
109 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
111 __GLX_SWAP_INT(pc
+ 0);
112 __GLX_SWAP_INT(pc
+ 12);
113 __GLX_SWAP_INT(pc
+ 24);
114 __GLX_SWAP_FLOAT(pc
+ 4);
115 __GLX_SWAP_FLOAT(pc
+ 8);
116 __GLX_SWAP_FLOAT(pc
+ 16);
117 __GLX_SWAP_FLOAT(pc
+ 20);
119 target
= *(GLenum
*) (pc
+ 0);
120 uorder
= *(GLint
*) (pc
+ 12);
121 vorder
= *(GLint
*) (pc
+ 24);
122 u1
= *(GLfloat
*) (pc
+ 4);
123 u2
= *(GLfloat
*) (pc
+ 8);
124 v1
= *(GLfloat
*) (pc
+ 16);
125 v2
= *(GLfloat
*) (pc
+ 20);
126 points
= (GLfloat
*) (pc
+ 28);
128 k
= __glEvalComputeK(target
);
129 ustride
= vorder
* k
;
132 if (vorder
<= 0 || uorder
<= 0 || k
< 0) {
133 /* Erroneous command. */
137 compsize
= uorder
* vorder
* k
;
139 __GLX_SWAP_FLOAT_ARRAY(points
, compsize
);
144 __glXDispSwap_Map1d(GLbyte
* pc
)
146 GLint order
, k
, compsize
;
148 GLdouble u1
, u2
, *points
;
150 __GLX_DECLARE_SWAP_VARIABLES
;
151 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
153 __GLX_SWAP_DOUBLE(pc
+ 0);
154 __GLX_SWAP_DOUBLE(pc
+ 8);
155 __GLX_SWAP_INT(pc
+ 16);
156 __GLX_SWAP_INT(pc
+ 20);
158 target
= *(GLenum
*) (pc
+ 16);
159 order
= *(GLint
*) (pc
+ 20);
160 k
= __glEvalComputeK(target
);
161 if (order
<= 0 || k
< 0) {
162 /* Erroneous command. */
166 compsize
= order
* k
;
168 __GLX_GET_DOUBLE(u1
, pc
);
169 __GLX_GET_DOUBLE(u2
, pc
+ 8);
170 __GLX_SWAP_DOUBLE_ARRAY(pc
+ 24, compsize
);
174 if (((unsigned long) pc
) & 7) {
176 ** Copy the doubles up 4 bytes, trashing the command but aligning
177 ** the data in the process
179 __GLX_MEM_COPY(pc
- 4, pc
, compsize
* 8);
180 points
= (GLdouble
*) (pc
- 4);
183 points
= (GLdouble
*) pc
;
186 points
= (GLdouble
*) pc
;
191 __glXDispSwap_Map2d(GLbyte
* pc
)
193 GLdouble u1
, u2
, v1
, v2
, *points
;
194 GLint uorder
, vorder
, ustride
, vstride
, k
, compsize
;
197 __GLX_DECLARE_SWAP_VARIABLES
;
198 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
200 __GLX_SWAP_DOUBLE(pc
+ 0);
201 __GLX_SWAP_DOUBLE(pc
+ 8);
202 __GLX_SWAP_DOUBLE(pc
+ 16);
203 __GLX_SWAP_DOUBLE(pc
+ 24);
204 __GLX_SWAP_INT(pc
+ 32);
205 __GLX_SWAP_INT(pc
+ 36);
206 __GLX_SWAP_INT(pc
+ 40);
208 target
= *(GLenum
*) (pc
+ 32);
209 uorder
= *(GLint
*) (pc
+ 36);
210 vorder
= *(GLint
*) (pc
+ 40);
211 k
= __glEvalComputeK(target
);
212 if (vorder
<= 0 || uorder
<= 0 || k
< 0) {
213 /* Erroneous command. */
217 compsize
= uorder
* vorder
* k
;
219 __GLX_GET_DOUBLE(u1
, pc
);
220 __GLX_GET_DOUBLE(u2
, pc
+ 8);
221 __GLX_GET_DOUBLE(v1
, pc
+ 16);
222 __GLX_GET_DOUBLE(v2
, pc
+ 24);
223 __GLX_SWAP_DOUBLE_ARRAY(pc
+ 44, compsize
);
225 ustride
= vorder
* k
;
229 if (((unsigned long) pc
) & 7) {
231 ** Copy the doubles up 4 bytes, trashing the command but aligning
232 ** the data in the process
234 __GLX_MEM_COPY(pc
- 4, pc
, compsize
* 8);
235 points
= (GLdouble
*) (pc
- 4);
238 points
= (GLdouble
*) pc
;
241 points
= (GLdouble
*) pc
;
246 __glXDispSwap_CallLists(GLbyte
* pc
)
251 __GLX_DECLARE_SWAP_VARIABLES
;
252 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
254 __GLX_SWAP_INT(pc
+ 4);
255 __GLX_SWAP_INT(pc
+ 0);
256 type
= *(GLenum
*) (pc
+ 4);
257 n
= *(GLsizei
*) (pc
+ 0);
261 case GL_UNSIGNED_BYTE
:
267 case GL_UNSIGNED_SHORT
:
268 __GLX_SWAP_SHORT_ARRAY(pc
+ 8, n
);
271 case GL_UNSIGNED_INT
:
272 __GLX_SWAP_INT_ARRAY(pc
+ 8, n
);
275 __GLX_SWAP_FLOAT_ARRAY(pc
+ 8, n
);
282 __glXDispSwap_DrawArrays(GLbyte
* pc
)
284 __GLXdispatchDrawArraysHeader
*hdr
= (__GLXdispatchDrawArraysHeader
*) pc
;
285 __GLXdispatchDrawArraysComponentHeader
*compHeader
;
288 __GLX_DECLARE_SWAP_VARIABLES
;
290 __GLX_SWAP_INT(&hdr
->numVertexes
);
291 __GLX_SWAP_INT(&hdr
->numComponents
);
292 __GLX_SWAP_INT(&hdr
->primType
);
294 pc
+= sizeof(__GLXdispatchDrawArraysHeader
);
295 compHeader
= (__GLXdispatchDrawArraysComponentHeader
*) pc
;
297 /* compute stride (same for all component arrays) */
298 for (i
= 0; i
< hdr
->numComponents
; i
++) {
299 __GLX_SWAP_INT(&compHeader
[i
].datatype
);
300 __GLX_SWAP_INT(&compHeader
[i
].numVals
);
301 __GLX_SWAP_INT(&compHeader
[i
].component
);