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 __glXDisp_Map1f(GLbyte *pc)
48 GLfloat u1, u2, *points;
51 target = *(GLenum *)(pc + 0);
52 order = *(GLint *)(pc + 12);
53 u1 = *(GLfloat *)(pc + 4);
54 u2 = *(GLfloat *)(pc + 8);
55 points = (GLfloat *)(pc + 16);
56 k = __glMap1f_size(target);
58 CALL_Map1f( GET_DISPATCH(), (target, u1, u2, k, order, points) );
61 void __glXDisp_Map2f(GLbyte *pc)
63 GLint uorder, vorder, ustride, vstride, k;
64 GLfloat u1, u2, v1, v2, *points;
67 target = *(GLenum *)(pc + 0);
68 uorder = *(GLint *)(pc + 12);
69 vorder = *(GLint *)(pc + 24);
70 u1 = *(GLfloat *)(pc + 4);
71 u2 = *(GLfloat *)(pc + 8);
72 v1 = *(GLfloat *)(pc + 16);
73 v2 = *(GLfloat *)(pc + 20);
74 points = (GLfloat *)(pc + 28);
76 k = __glMap2f_size(target);
80 CALL_Map2f( GET_DISPATCH(), (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points) );
83 void __glXDisp_Map1d(GLbyte *pc)
90 GLdouble u1, u2, *points;
92 target = *(GLenum*) (pc + 16);
93 order = *(GLint*) (pc + 20);
94 k = __glMap1d_size(target);
97 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);
117 points = (GLdouble*) pc;
120 points = (GLdouble*) pc;
122 CALL_Map1d( GET_DISPATCH(), (target, u1, u2, k, order, points) );
125 void __glXDisp_Map2d(GLbyte *pc)
127 GLdouble u1, u2, v1, v2, *points;
128 GLint uorder, vorder, ustride, vstride, k;
134 target = *(GLenum *)(pc + 32);
135 uorder = *(GLint *)(pc + 36);
136 vorder = *(GLint *)(pc + 40);
137 k = __glMap2d_size(target);
140 if (vorder < 0 || uorder < 0 || k < 0) {
143 compsize = uorder * vorder * k;
147 __GLX_GET_DOUBLE(u1,pc);
148 __GLX_GET_DOUBLE(u2,pc+8);
149 __GLX_GET_DOUBLE(v1,pc+16);
150 __GLX_GET_DOUBLE(v2,pc+24);
153 ustride = vorder * k;
157 if (((unsigned long)pc) & 7) {
159 ** Copy the doubles up 4 bytes, trashing the command but aligning
160 ** the data in the process
162 __GLX_MEM_COPY(pc-4, pc, compsize*8);
163 points = (GLdouble*) (pc - 4);
165 points = (GLdouble*) pc;
168 points = (GLdouble*) pc;
170 CALL_Map2d( GET_DISPATCH(), (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points) );
173 void __glXDisp_DrawArrays(GLbyte *pc)
175 __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *)pc;
176 __GLXdispatchDrawArraysComponentHeader *compHeader;
177 GLint numVertexes = hdr->numVertexes;
178 GLint numComponents = hdr->numComponents;
179 GLenum primType = hdr->primType;
183 pc += sizeof(__GLXdispatchDrawArraysHeader);
184 compHeader = (__GLXdispatchDrawArraysComponentHeader *)pc;
186 /* compute stride (same for all component arrays) */
187 for (i = 0; i < numComponents; i++) {
188 GLenum datatype = compHeader[i].datatype;
189 GLint numVals = compHeader[i].numVals;
191 stride += __GLX_PAD(numVals * __glXTypeSize(datatype));
194 pc += numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader);
196 /* set up component arrays */
197 for (i = 0; i < numComponents; i++) {
198 GLenum datatype = compHeader[i].datatype;
199 GLint numVals = compHeader[i].numVals;
200 GLenum component = compHeader[i].component;
203 case GL_VERTEX_ARRAY:
204 CALL_EnableClientState( GET_DISPATCH(), (GL_VERTEX_ARRAY) );
205 CALL_VertexPointer( GET_DISPATCH(), (numVals, datatype, stride, pc) );
207 case GL_NORMAL_ARRAY:
208 CALL_EnableClientState( GET_DISPATCH(), (GL_NORMAL_ARRAY) );
209 CALL_NormalPointer( GET_DISPATCH(), (datatype, stride, pc) );
212 CALL_EnableClientState( GET_DISPATCH(), (GL_COLOR_ARRAY) );
213 CALL_ColorPointer( GET_DISPATCH(), (numVals, datatype, stride, pc) );
216 CALL_EnableClientState( GET_DISPATCH(), (GL_INDEX_ARRAY) );
217 CALL_IndexPointer( GET_DISPATCH(), (datatype, stride, pc) );
219 case GL_TEXTURE_COORD_ARRAY:
220 CALL_EnableClientState( GET_DISPATCH(), (GL_TEXTURE_COORD_ARRAY) );
221 CALL_TexCoordPointer( GET_DISPATCH(), (numVals, datatype, stride, pc) );
223 case GL_EDGE_FLAG_ARRAY:
224 CALL_EnableClientState( GET_DISPATCH(), (GL_EDGE_FLAG_ARRAY) );
225 CALL_EdgeFlagPointer( GET_DISPATCH(), (stride, (const GLboolean *)pc) );
227 case GL_SECONDARY_COLOR_ARRAY:
228 CALL_EnableClientState( GET_DISPATCH(), (GL_SECONDARY_COLOR_ARRAY) );
229 CALL_SecondaryColorPointerEXT( GET_DISPATCH(), (numVals, datatype, stride, pc) );
231 case GL_FOG_COORD_ARRAY:
232 CALL_EnableClientState( GET_DISPATCH(), (GL_FOG_COORD_ARRAY) );
233 CALL_FogCoordPointerEXT( GET_DISPATCH(), (datatype, stride, pc) );
239 pc += __GLX_PAD(numVals * __glXTypeSize(datatype));
242 CALL_DrawArrays( GET_DISPATCH(), (primType, 0, numVertexes) );
244 /* turn off anything we might have turned on */
245 CALL_DisableClientState( GET_DISPATCH(), (GL_VERTEX_ARRAY) );
246 CALL_DisableClientState( GET_DISPATCH(), (GL_NORMAL_ARRAY) );
247 CALL_DisableClientState( GET_DISPATCH(), (GL_COLOR_ARRAY) );
248 CALL_DisableClientState( GET_DISPATCH(), (GL_INDEX_ARRAY) );
249 CALL_DisableClientState( GET_DISPATCH(), (GL_TEXTURE_COORD_ARRAY) );
250 CALL_DisableClientState( GET_DISPATCH(), (GL_EDGE_FLAG_ARRAY) );
251 CALL_DisableClientState( GET_DISPATCH(), (GL_SECONDARY_COLOR_ARRAY) );
252 CALL_DisableClientState( GET_DISPATCH(), (GL_FOG_COORD_ARRAY) );