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"
41 __glXDisp_Map1f(GLbyte * pc)
44 GLfloat u1, u2, *points;
47 target = *(GLenum *) (pc + 0);
48 order = *(GLint *) (pc + 12);
49 u1 = *(GLfloat *) (pc + 4);
50 u2 = *(GLfloat *) (pc + 8);
51 points = (GLfloat *) (pc + 16);
52 k = __glMap1f_size(target);
54 glMap1f(target, u1, u2, k, order, points);
58 __glXDisp_Map2f(GLbyte * pc)
60 GLint uorder, vorder, ustride, vstride, k;
61 GLfloat u1, u2, v1, v2, *points;
64 target = *(GLenum *) (pc + 0);
65 uorder = *(GLint *) (pc + 12);
66 vorder = *(GLint *) (pc + 24);
67 u1 = *(GLfloat *) (pc + 4);
68 u2 = *(GLfloat *) (pc + 8);
69 v1 = *(GLfloat *) (pc + 16);
70 v2 = *(GLfloat *) (pc + 20);
71 points = (GLfloat *) (pc + 28);
73 k = __glMap2f_size(target);
77 glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
81 __glXDisp_Map1d(GLbyte * pc)
89 GLdouble u1, u2, *points;
91 target = *(GLenum *) (pc + 16);
92 order = *(GLint *) (pc + 20);
93 k = __glMap1d_size(target);
96 if (order < 0 || k < 0) {
100 compsize = order * k;
104 __GLX_GET_DOUBLE(u1, pc);
105 __GLX_GET_DOUBLE(u2, pc + 8);
109 if (((unsigned long) pc) & 7) {
111 ** Copy the doubles up 4 bytes, trashing the command but aligning
112 ** the data in the process
114 __GLX_MEM_COPY(pc - 4, pc, compsize * 8);
115 points = (GLdouble *) (pc - 4);
118 points = (GLdouble *) pc;
121 points = (GLdouble *) pc;
123 glMap1d(target, u1, u2, k, order, points);
127 __glXDisp_Map2d(GLbyte * pc)
129 GLdouble u1, u2, v1, v2, *points;
130 GLint uorder, vorder, ustride, vstride, k;
137 target = *(GLenum *) (pc + 32);
138 uorder = *(GLint *) (pc + 36);
139 vorder = *(GLint *) (pc + 40);
140 k = __glMap2d_size(target);
143 if (vorder < 0 || uorder < 0 || k < 0) {
147 compsize = uorder * vorder * k;
151 __GLX_GET_DOUBLE(u1, pc);
152 __GLX_GET_DOUBLE(u2, pc + 8);
153 __GLX_GET_DOUBLE(v1, pc + 16);
154 __GLX_GET_DOUBLE(v2, pc + 24);
157 ustride = vorder * k;
161 if (((unsigned long) pc) & 7) {
163 ** Copy the doubles up 4 bytes, trashing the command but aligning
164 ** the data in the process
166 __GLX_MEM_COPY(pc - 4, pc, compsize * 8);
167 points = (GLdouble *) (pc - 4);
170 points = (GLdouble *) pc;
173 points = (GLdouble *) pc;
175 glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
179 __glXDisp_DrawArrays(GLbyte * pc)
181 __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *) pc;
182 __GLXdispatchDrawArraysComponentHeader *compHeader;
183 GLint numVertexes = hdr->numVertexes;
184 GLint numComponents = hdr->numComponents;
185 GLenum primType = hdr->primType;
189 pc += sizeof(__GLXdispatchDrawArraysHeader);
190 compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc;
192 /* compute stride (same for all component arrays) */
193 for (i = 0; i < numComponents; i++) {
194 GLenum datatype = compHeader[i].datatype;
195 GLint numVals = compHeader[i].numVals;
197 stride += __GLX_PAD(numVals * __glXTypeSize(datatype));
200 pc += numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader);
202 /* set up component arrays */
203 for (i = 0; i < numComponents; i++) {
204 GLenum datatype = compHeader[i].datatype;
205 GLint numVals = compHeader[i].numVals;
206 GLenum component = compHeader[i].component;
209 case GL_VERTEX_ARRAY:
210 glEnableClientState(GL_VERTEX_ARRAY);
211 glVertexPointer(numVals, datatype, stride, pc);
213 case GL_NORMAL_ARRAY:
214 glEnableClientState(GL_NORMAL_ARRAY);
215 glNormalPointer(datatype, stride, pc);
218 glEnableClientState(GL_COLOR_ARRAY);
219 glColorPointer(numVals, datatype, stride, pc);
222 glEnableClientState(GL_INDEX_ARRAY);
223 glIndexPointer(datatype, stride, pc);
225 case GL_TEXTURE_COORD_ARRAY:
226 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
227 glTexCoordPointer(numVals, datatype, stride, pc);
229 case GL_EDGE_FLAG_ARRAY:
230 glEnableClientState(GL_EDGE_FLAG_ARRAY);
231 glEdgeFlagPointer(stride, (const GLboolean *) pc);
233 case GL_SECONDARY_COLOR_ARRAY:
235 PFNGLSECONDARYCOLORPOINTERPROC SecondaryColorPointerEXT =
236 __glGetProcAddress("glSecondaryColorPointerEXT");
237 glEnableClientState(GL_SECONDARY_COLOR_ARRAY);
238 SecondaryColorPointerEXT(numVals, datatype, stride, pc);
241 case GL_FOG_COORD_ARRAY:
243 PFNGLFOGCOORDPOINTERPROC FogCoordPointerEXT =
244 __glGetProcAddress("glFogCoordPointerEXT");
245 glEnableClientState(GL_FOG_COORD_ARRAY);
246 FogCoordPointerEXT(datatype, stride, pc);
253 pc += __GLX_PAD(numVals * __glXTypeSize(datatype));
256 glDrawArrays(primType, 0, numVertexes);
258 /* turn off anything we might have turned on */
259 glDisableClientState(GL_VERTEX_ARRAY);
260 glDisableClientState(GL_NORMAL_ARRAY);
261 glDisableClientState(GL_COLOR_ARRAY);
262 glDisableClientState(GL_INDEX_ARRAY);
263 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
264 glDisableClientState(GL_EDGE_FLAG_ARRAY);
265 glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
266 glDisableClientState(GL_FOG_COORD_ARRAY);