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 #ifdef HAVE_DIX_CONFIG_H
32 #include <dix-config.h>
35 #include "glxserver.h"
37 #include "indirect_size.h"
38 #include "indirect_dispatch.h"
39 #include "glapitable.h"
45 void __glXDispSwap_Map1f(GLbyte *pc)
48 GLfloat u1, u2, *points;
51 __GLX_DECLARE_SWAP_VARIABLES;
52 __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
54 __GLX_SWAP_INT(pc + 0);
55 __GLX_SWAP_INT(pc + 12);
56 __GLX_SWAP_FLOAT(pc + 4);
57 __GLX_SWAP_FLOAT(pc + 8);
59 target = *(GLenum *)(pc + 0);
60 order = *(GLint *)(pc + 12);
61 u1 = *(GLfloat *)(pc + 4);
62 u2 = *(GLfloat *)(pc + 8);
63 points = (GLfloat *)(pc + 16);
64 k = __glMap1f_size(target);
66 if (order <= 0 || k < 0) {
67 /* Erroneous command. */
72 __GLX_SWAP_FLOAT_ARRAY(points, compsize);
74 CALL_Map1f( GET_DISPATCH(), (target, u1, u2, k, order, points) );
77 void __glXDispSwap_Map2f(GLbyte *pc)
79 GLint uorder, vorder, ustride, vstride, k;
80 GLfloat u1, u2, v1, v2, *points;
83 __GLX_DECLARE_SWAP_VARIABLES;
84 __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
86 __GLX_SWAP_INT(pc + 0);
87 __GLX_SWAP_INT(pc + 12);
88 __GLX_SWAP_INT(pc + 24);
89 __GLX_SWAP_FLOAT(pc + 4);
90 __GLX_SWAP_FLOAT(pc + 8);
91 __GLX_SWAP_FLOAT(pc + 16);
92 __GLX_SWAP_FLOAT(pc + 20);
94 target = *(GLenum *)(pc + 0);
95 uorder = *(GLint *)(pc + 12);
96 vorder = *(GLint *)(pc + 24);
97 u1 = *(GLfloat *)(pc + 4);
98 u2 = *(GLfloat *)(pc + 8);
99 v1 = *(GLfloat *)(pc + 16);
100 v2 = *(GLfloat *)(pc + 20);
101 points = (GLfloat *)(pc + 28);
103 k = __glMap2f_size(target);
104 ustride = vorder * k;
107 if (vorder <= 0 || uorder <= 0 || k < 0) {
108 /* Erroneous command. */
111 compsize = uorder * vorder * k;
113 __GLX_SWAP_FLOAT_ARRAY(points, compsize);
115 CALL_Map2f( GET_DISPATCH(), (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points) );
118 void __glXDispSwap_Map1d(GLbyte *pc)
120 GLint order, k, compsize;
122 GLdouble u1, u2, *points;
123 __GLX_DECLARE_SWAP_VARIABLES;
124 __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
126 __GLX_SWAP_DOUBLE(pc + 0);
127 __GLX_SWAP_DOUBLE(pc + 8);
128 __GLX_SWAP_INT(pc + 16);
129 __GLX_SWAP_INT(pc + 20);
131 target = *(GLenum*) (pc + 16);
132 order = *(GLint*) (pc + 20);
133 k = __glMap1d_size(target);
134 if (order <= 0 || k < 0) {
135 /* Erroneous command. */
138 compsize = order * k;
140 __GLX_GET_DOUBLE(u1,pc);
141 __GLX_GET_DOUBLE(u2,pc+8);
142 __GLX_SWAP_DOUBLE_ARRAY(pc+24, compsize);
146 if (((unsigned long)pc) & 7) {
148 ** Copy the doubles up 4 bytes, trashing the command but aligning
149 ** the data in the process
151 __GLX_MEM_COPY(pc-4, pc, compsize*8);
152 points = (GLdouble*) (pc - 4);
154 points = (GLdouble*) pc;
157 points = (GLdouble*) pc;
159 CALL_Map1d( GET_DISPATCH(), (target, u1, u2, k, order, points) );
162 void __glXDispSwap_Map2d(GLbyte *pc)
164 GLdouble u1, u2, v1, v2, *points;
165 GLint uorder, vorder, ustride, vstride, k, compsize;
167 __GLX_DECLARE_SWAP_VARIABLES;
168 __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
170 __GLX_SWAP_DOUBLE(pc + 0);
171 __GLX_SWAP_DOUBLE(pc + 8);
172 __GLX_SWAP_DOUBLE(pc + 16);
173 __GLX_SWAP_DOUBLE(pc + 24);
174 __GLX_SWAP_INT(pc + 32);
175 __GLX_SWAP_INT(pc + 36);
176 __GLX_SWAP_INT(pc + 40);
178 target = *(GLenum *)(pc + 32);
179 uorder = *(GLint *)(pc + 36);
180 vorder = *(GLint *)(pc + 40);
181 k = __glMap2d_size(target);
182 if (vorder <= 0 || uorder <= 0 || k < 0) {
183 /* Erroneous command. */
186 compsize = uorder * vorder * k;
188 __GLX_GET_DOUBLE(u1,pc);
189 __GLX_GET_DOUBLE(u2,pc+8);
190 __GLX_GET_DOUBLE(v1,pc+16);
191 __GLX_GET_DOUBLE(v2,pc+24);
192 __GLX_SWAP_DOUBLE_ARRAY(pc+44, compsize);
194 ustride = vorder * k;
198 if (((unsigned long)pc) & 7) {
200 ** Copy the doubles up 4 bytes, trashing the command but aligning
201 ** the data in the process
203 __GLX_MEM_COPY(pc-4, pc, compsize*8);
204 points = (GLdouble*) (pc - 4);
206 points = (GLdouble*) pc;
209 points = (GLdouble*) pc;
211 CALL_Map2d( GET_DISPATCH(), (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points) );
214 static void swapArray(GLint numVals, GLenum datatype,
215 GLint stride, GLint numVertexes, GLbyte *pc)
218 __GLX_DECLARE_SWAP_VARIABLES;
222 case GL_UNSIGNED_BYTE:
223 /* don't need to swap */
226 case GL_UNSIGNED_SHORT:
227 for (i=0; i<numVertexes; i++) {
228 GLshort *pVal = (GLshort *) pc;
229 for (j=0; j<numVals; j++) {
230 __GLX_SWAP_SHORT(&pVal[j]);
236 case GL_UNSIGNED_INT:
237 for (i=0; i<numVertexes; i++) {
238 GLint *pVal = (GLint *) pc;
239 for (j=0; j<numVals; j++) {
240 __GLX_SWAP_INT(&pVal[j]);
246 for (i=0; i<numVertexes; i++) {
247 GLfloat *pVal = (GLfloat *) pc;
248 for (j=0; j<numVals; j++) {
249 __GLX_SWAP_FLOAT(&pVal[j]);
255 for (i=0; i<numVertexes; i++) {
256 GLdouble *pVal = (GLdouble *) pc;
257 for (j=0; j<numVals; j++) {
258 __GLX_SWAP_DOUBLE(&pVal[j]);
268 void __glXDispSwap_DrawArrays(GLbyte *pc)
270 __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *)pc;
271 __GLXdispatchDrawArraysComponentHeader *compHeader;
272 GLint numVertexes = hdr->numVertexes;
273 GLint numComponents = hdr->numComponents;
274 GLenum primType = hdr->primType;
277 __GLX_DECLARE_SWAP_VARIABLES;
279 __GLX_SWAP_INT(&numVertexes);
280 __GLX_SWAP_INT(&numComponents);
281 __GLX_SWAP_INT(&primType);
283 pc += sizeof(__GLXdispatchDrawArraysHeader);
284 compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc;
286 /* compute stride (same for all component arrays) */
287 for (i=0; i<numComponents; i++) {
288 GLenum datatype = compHeader[i].datatype;
289 GLint numVals = compHeader[i].numVals;
290 GLenum component = compHeader[i].component;
292 __GLX_SWAP_INT(&datatype);
293 __GLX_SWAP_INT(&numVals);
294 __GLX_SWAP_INT(&component);
296 stride += __GLX_PAD(numVals * __glXTypeSize(datatype));
299 pc += numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader);
301 /* set up component arrays */
302 for (i=0; i<numComponents; i++) {
303 GLenum datatype = compHeader[i].datatype;
304 GLint numVals = compHeader[i].numVals;
305 GLenum component = compHeader[i].component;
307 __GLX_SWAP_INT(&datatype);
308 __GLX_SWAP_INT(&numVals);
309 __GLX_SWAP_INT(&component);
311 swapArray(numVals, datatype, stride, numVertexes, pc);
314 case GL_VERTEX_ARRAY:
315 CALL_EnableClientState( GET_DISPATCH(), (GL_VERTEX_ARRAY) );
316 CALL_VertexPointer( GET_DISPATCH(), (numVals, datatype, stride, pc) );
318 case GL_NORMAL_ARRAY:
319 CALL_EnableClientState( GET_DISPATCH(), (GL_NORMAL_ARRAY) );
320 CALL_NormalPointer( GET_DISPATCH(), (datatype, stride, pc) );
323 CALL_EnableClientState( GET_DISPATCH(), (GL_COLOR_ARRAY) );
324 CALL_ColorPointer( GET_DISPATCH(), (numVals, datatype, stride, pc) );
327 CALL_EnableClientState( GET_DISPATCH(), (GL_INDEX_ARRAY) );
328 CALL_IndexPointer( GET_DISPATCH(), (datatype, stride, pc) );
330 case GL_TEXTURE_COORD_ARRAY:
331 CALL_EnableClientState( GET_DISPATCH(), (GL_TEXTURE_COORD_ARRAY) );
332 CALL_TexCoordPointer( GET_DISPATCH(), (numVals, datatype, stride, pc) );
334 case GL_EDGE_FLAG_ARRAY:
335 CALL_EnableClientState( GET_DISPATCH(), (GL_EDGE_FLAG_ARRAY) );
336 CALL_EdgeFlagPointer( GET_DISPATCH(), (stride, (const GLboolean *)pc) );
338 case GL_SECONDARY_COLOR_ARRAY:
339 CALL_EnableClientState( GET_DISPATCH(), (GL_SECONDARY_COLOR_ARRAY) );
340 CALL_SecondaryColorPointerEXT( GET_DISPATCH(), (numVals, datatype, stride, pc) );
342 case GL_FOG_COORD_ARRAY:
343 CALL_EnableClientState( GET_DISPATCH(), (GL_FOG_COORD_ARRAY) );
344 CALL_FogCoordPointerEXT( GET_DISPATCH(), (datatype, stride, pc) );
350 pc += __GLX_PAD(numVals * __glXTypeSize(datatype));
353 CALL_DrawArrays( GET_DISPATCH(), (primType, 0, numVertexes) );
355 /* turn off anything we might have turned on */
356 CALL_DisableClientState( GET_DISPATCH(), (GL_VERTEX_ARRAY) );
357 CALL_DisableClientState( GET_DISPATCH(), (GL_NORMAL_ARRAY) );
358 CALL_DisableClientState( GET_DISPATCH(), (GL_COLOR_ARRAY) );
359 CALL_DisableClientState( GET_DISPATCH(), (GL_INDEX_ARRAY) );
360 CALL_DisableClientState( GET_DISPATCH(), (GL_TEXTURE_COORD_ARRAY) );
361 CALL_DisableClientState( GET_DISPATCH(), (GL_EDGE_FLAG_ARRAY) );
362 CALL_DisableClientState( GET_DISPATCH(), (GL_SECONDARY_COLOR_ARRAY) );
363 CALL_DisableClientState( GET_DISPATCH(), (GL_FOG_COORD_ARRAY) );