2 ** License Applicability. Except to the extent portions of this file are
3 ** made subject to an alternative license as permitted in the SGI Free
4 ** Software License B, Version 1.1 (the "License"), the contents of this
5 ** file are subject only to the provisions of the License. You may not use
6 ** this file except in compliance with the License. You may obtain a copy
7 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
10 ** http://oss.sgi.com/projects/FreeB
12 ** Note that, as provided in the License, the Software is distributed on an
13 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
18 ** Original Code. The Original Code is: OpenGL Sample Implementation,
19 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21 ** Copyright in any portions created by third parties is as indicated
22 ** elsewhere herein. All Rights Reserved.
24 ** Additional Notice Provisions: The application programming interfaces
25 ** established by SGI in conjunction with the Original Code are The
26 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29 ** Window System(R) (Version 1.3), released October 19, 1998. This software
30 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31 ** published by SGI, but has not been independently verified as being
32 ** compliant with the OpenGL(R) version 1.2.1 Specification.
36 /* #define NEED_REPLIES */
37 #ifdef HAVE_DIX_CONFIG_H
38 #include <dix-config.h>
41 #include "glxserver.h"
43 #include "indirect_size.h"
44 #include "indirect_dispatch.h"
45 #include "glapitable.h"
51 void __glXDispSwap_Map1f(GLbyte
*pc
)
54 GLfloat u1
, u2
, *points
;
57 __GLX_DECLARE_SWAP_VARIABLES
;
58 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
60 __GLX_SWAP_INT(pc
+ 0);
61 __GLX_SWAP_INT(pc
+ 12);
62 __GLX_SWAP_FLOAT(pc
+ 4);
63 __GLX_SWAP_FLOAT(pc
+ 8);
65 target
= *(GLenum
*)(pc
+ 0);
66 order
= *(GLint
*)(pc
+ 12);
67 u1
= *(GLfloat
*)(pc
+ 4);
68 u2
= *(GLfloat
*)(pc
+ 8);
69 points
= (GLfloat
*)(pc
+ 16);
70 k
= __glMap1f_size(target
);
72 if (order
<= 0 || k
< 0) {
73 /* Erroneous command. */
78 __GLX_SWAP_FLOAT_ARRAY(points
, compsize
);
80 CALL_Map1f( GET_DISPATCH(), (target
, u1
, u2
, k
, order
, points
) );
83 void __glXDispSwap_Map2f(GLbyte
*pc
)
85 GLint uorder
, vorder
, ustride
, vstride
, k
;
86 GLfloat u1
, u2
, v1
, v2
, *points
;
89 __GLX_DECLARE_SWAP_VARIABLES
;
90 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
92 __GLX_SWAP_INT(pc
+ 0);
93 __GLX_SWAP_INT(pc
+ 12);
94 __GLX_SWAP_INT(pc
+ 24);
95 __GLX_SWAP_FLOAT(pc
+ 4);
96 __GLX_SWAP_FLOAT(pc
+ 8);
97 __GLX_SWAP_FLOAT(pc
+ 16);
98 __GLX_SWAP_FLOAT(pc
+ 20);
100 target
= *(GLenum
*)(pc
+ 0);
101 uorder
= *(GLint
*)(pc
+ 12);
102 vorder
= *(GLint
*)(pc
+ 24);
103 u1
= *(GLfloat
*)(pc
+ 4);
104 u2
= *(GLfloat
*)(pc
+ 8);
105 v1
= *(GLfloat
*)(pc
+ 16);
106 v2
= *(GLfloat
*)(pc
+ 20);
107 points
= (GLfloat
*)(pc
+ 28);
109 k
= __glMap2f_size(target
);
110 ustride
= vorder
* k
;
113 if (vorder
<= 0 || uorder
<= 0 || k
< 0) {
114 /* Erroneous command. */
117 compsize
= uorder
* vorder
* k
;
119 __GLX_SWAP_FLOAT_ARRAY(points
, compsize
);
121 CALL_Map2f( GET_DISPATCH(), (target
, u1
, u2
, ustride
, uorder
, v1
, v2
, vstride
, vorder
, points
) );
124 void __glXDispSwap_Map1d(GLbyte
*pc
)
126 GLint order
, k
, compsize
;
128 GLdouble u1
, u2
, *points
;
129 __GLX_DECLARE_SWAP_VARIABLES
;
130 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
132 __GLX_SWAP_DOUBLE(pc
+ 0);
133 __GLX_SWAP_DOUBLE(pc
+ 8);
134 __GLX_SWAP_INT(pc
+ 16);
135 __GLX_SWAP_INT(pc
+ 20);
137 target
= *(GLenum
*) (pc
+ 16);
138 order
= *(GLint
*) (pc
+ 20);
139 k
= __glMap1d_size(target
);
140 if (order
<= 0 || k
< 0) {
141 /* Erroneous command. */
144 compsize
= order
* k
;
146 __GLX_GET_DOUBLE(u1
,pc
);
147 __GLX_GET_DOUBLE(u2
,pc
+8);
148 __GLX_SWAP_DOUBLE_ARRAY(pc
+24, compsize
);
152 if (((unsigned long)pc
) & 7) {
154 ** Copy the doubles up 4 bytes, trashing the command but aligning
155 ** the data in the process
157 __GLX_MEM_COPY(pc
-4, pc
, compsize
*8);
158 points
= (GLdouble
*) (pc
- 4);
160 points
= (GLdouble
*) pc
;
163 points
= (GLdouble
*) pc
;
165 CALL_Map1d( GET_DISPATCH(), (target
, u1
, u2
, k
, order
, points
) );
168 void __glXDispSwap_Map2d(GLbyte
*pc
)
170 GLdouble u1
, u2
, v1
, v2
, *points
;
171 GLint uorder
, vorder
, ustride
, vstride
, k
, compsize
;
173 __GLX_DECLARE_SWAP_VARIABLES
;
174 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
176 __GLX_SWAP_DOUBLE(pc
+ 0);
177 __GLX_SWAP_DOUBLE(pc
+ 8);
178 __GLX_SWAP_DOUBLE(pc
+ 16);
179 __GLX_SWAP_DOUBLE(pc
+ 24);
180 __GLX_SWAP_INT(pc
+ 32);
181 __GLX_SWAP_INT(pc
+ 36);
182 __GLX_SWAP_INT(pc
+ 40);
184 target
= *(GLenum
*)(pc
+ 32);
185 uorder
= *(GLint
*)(pc
+ 36);
186 vorder
= *(GLint
*)(pc
+ 40);
187 k
= __glMap2d_size(target
);
188 if (vorder
<= 0 || uorder
<= 0 || k
< 0) {
189 /* Erroneous command. */
192 compsize
= uorder
* vorder
* k
;
194 __GLX_GET_DOUBLE(u1
,pc
);
195 __GLX_GET_DOUBLE(u2
,pc
+8);
196 __GLX_GET_DOUBLE(v1
,pc
+16);
197 __GLX_GET_DOUBLE(v2
,pc
+24);
198 __GLX_SWAP_DOUBLE_ARRAY(pc
+44, compsize
);
200 ustride
= vorder
* k
;
204 if (((unsigned long)pc
) & 7) {
206 ** Copy the doubles up 4 bytes, trashing the command but aligning
207 ** the data in the process
209 __GLX_MEM_COPY(pc
-4, pc
, compsize
*8);
210 points
= (GLdouble
*) (pc
- 4);
212 points
= (GLdouble
*) pc
;
215 points
= (GLdouble
*) pc
;
217 CALL_Map2d( GET_DISPATCH(), (target
, u1
, u2
, ustride
, uorder
, v1
, v2
, vstride
, vorder
, points
) );
220 static void swapArray(GLint numVals
, GLenum datatype
,
221 GLint stride
, GLint numVertexes
, GLbyte
*pc
)
224 __GLX_DECLARE_SWAP_VARIABLES
;
228 case GL_UNSIGNED_BYTE
:
229 /* don't need to swap */
232 case GL_UNSIGNED_SHORT
:
233 for (i
=0; i
<numVertexes
; i
++) {
234 GLshort
*pVal
= (GLshort
*) pc
;
235 for (j
=0; j
<numVals
; j
++) {
236 __GLX_SWAP_SHORT(&pVal
[j
]);
242 case GL_UNSIGNED_INT
:
243 for (i
=0; i
<numVertexes
; i
++) {
244 GLint
*pVal
= (GLint
*) pc
;
245 for (j
=0; j
<numVals
; j
++) {
246 __GLX_SWAP_INT(&pVal
[j
]);
252 for (i
=0; i
<numVertexes
; i
++) {
253 GLfloat
*pVal
= (GLfloat
*) pc
;
254 for (j
=0; j
<numVals
; j
++) {
255 __GLX_SWAP_FLOAT(&pVal
[j
]);
261 for (i
=0; i
<numVertexes
; i
++) {
262 GLdouble
*pVal
= (GLdouble
*) pc
;
263 for (j
=0; j
<numVals
; j
++) {
264 __GLX_SWAP_DOUBLE(&pVal
[j
]);
274 void __glXDispSwap_DrawArrays(GLbyte
*pc
)
276 __GLXdispatchDrawArraysHeader
*hdr
= (__GLXdispatchDrawArraysHeader
*)pc
;
277 __GLXdispatchDrawArraysComponentHeader
*compHeader
;
278 GLint numVertexes
= hdr
->numVertexes
;
279 GLint numComponents
= hdr
->numComponents
;
280 GLenum primType
= hdr
->primType
;
283 __GLX_DECLARE_SWAP_VARIABLES
;
285 __GLX_SWAP_INT(&numVertexes
);
286 __GLX_SWAP_INT(&numComponents
);
287 __GLX_SWAP_INT(&primType
);
289 pc
+= sizeof(__GLXdispatchDrawArraysHeader
);
290 compHeader
= (__GLXdispatchDrawArraysComponentHeader
*) pc
;
292 /* compute stride (same for all component arrays) */
293 for (i
=0; i
<numComponents
; i
++) {
294 GLenum datatype
= compHeader
[i
].datatype
;
295 GLint numVals
= compHeader
[i
].numVals
;
296 GLenum component
= compHeader
[i
].component
;
298 __GLX_SWAP_INT(&datatype
);
299 __GLX_SWAP_INT(&numVals
);
300 __GLX_SWAP_INT(&component
);
302 stride
+= __GLX_PAD(numVals
* __glXTypeSize(datatype
));
305 pc
+= numComponents
* sizeof(__GLXdispatchDrawArraysComponentHeader
);
307 /* set up component arrays */
308 for (i
=0; i
<numComponents
; i
++) {
309 GLenum datatype
= compHeader
[i
].datatype
;
310 GLint numVals
= compHeader
[i
].numVals
;
311 GLenum component
= compHeader
[i
].component
;
313 __GLX_SWAP_INT(&datatype
);
314 __GLX_SWAP_INT(&numVals
);
315 __GLX_SWAP_INT(&component
);
317 swapArray(numVals
, datatype
, stride
, numVertexes
, pc
);
320 case GL_VERTEX_ARRAY
:
321 CALL_EnableClientState( GET_DISPATCH(), (GL_VERTEX_ARRAY
) );
322 CALL_VertexPointer( GET_DISPATCH(), (numVals
, datatype
, stride
, pc
) );
324 case GL_NORMAL_ARRAY
:
325 CALL_EnableClientState( GET_DISPATCH(), (GL_NORMAL_ARRAY
) );
326 CALL_NormalPointer( GET_DISPATCH(), (datatype
, stride
, pc
) );
329 CALL_EnableClientState( GET_DISPATCH(), (GL_COLOR_ARRAY
) );
330 CALL_ColorPointer( GET_DISPATCH(), (numVals
, datatype
, stride
, pc
) );
333 CALL_EnableClientState( GET_DISPATCH(), (GL_INDEX_ARRAY
) );
334 CALL_IndexPointer( GET_DISPATCH(), (datatype
, stride
, pc
) );
336 case GL_TEXTURE_COORD_ARRAY
:
337 CALL_EnableClientState( GET_DISPATCH(), (GL_TEXTURE_COORD_ARRAY
) );
338 CALL_TexCoordPointer( GET_DISPATCH(), (numVals
, datatype
, stride
, pc
) );
340 case GL_EDGE_FLAG_ARRAY
:
341 CALL_EnableClientState( GET_DISPATCH(), (GL_EDGE_FLAG_ARRAY
) );
342 CALL_EdgeFlagPointer( GET_DISPATCH(), (stride
, (const GLboolean
*)pc
) );
344 case GL_SECONDARY_COLOR_ARRAY
:
345 CALL_EnableClientState( GET_DISPATCH(), (GL_SECONDARY_COLOR_ARRAY
) );
346 CALL_SecondaryColorPointerEXT( GET_DISPATCH(), (numVals
, datatype
, stride
, pc
) );
348 case GL_FOG_COORD_ARRAY
:
349 CALL_EnableClientState( GET_DISPATCH(), (GL_FOG_COORD_ARRAY
) );
350 CALL_FogCoordPointerEXT( GET_DISPATCH(), (datatype
, stride
, pc
) );
356 pc
+= __GLX_PAD(numVals
* __glXTypeSize(datatype
));
359 CALL_DrawArrays( GET_DISPATCH(), (primType
, 0, numVertexes
) );
361 /* turn off anything we might have turned on */
362 CALL_DisableClientState( GET_DISPATCH(), (GL_VERTEX_ARRAY
) );
363 CALL_DisableClientState( GET_DISPATCH(), (GL_NORMAL_ARRAY
) );
364 CALL_DisableClientState( GET_DISPATCH(), (GL_COLOR_ARRAY
) );
365 CALL_DisableClientState( GET_DISPATCH(), (GL_INDEX_ARRAY
) );
366 CALL_DisableClientState( GET_DISPATCH(), (GL_TEXTURE_COORD_ARRAY
) );
367 CALL_DisableClientState( GET_DISPATCH(), (GL_EDGE_FLAG_ARRAY
) );
368 CALL_DisableClientState( GET_DISPATCH(), (GL_SECONDARY_COLOR_ARRAY
) );
369 CALL_DisableClientState( GET_DISPATCH(), (GL_FOG_COORD_ARRAY
) );
372 void __glXDispSwap_DrawArraysEXT(GLbyte
*pc
)
374 __glXDispSwap_DrawArrays(pc
);