Commit | Line | Data |
---|---|---|
a09e091a JB |
1 | /* |
2 | * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) | |
3 | * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. | |
4 | * | |
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: | |
11 | * | |
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. | |
16 | * | |
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 | |
23 | * SOFTWARE. | |
24 | * | |
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. | |
29 | */ | |
30 | ||
31 | #ifdef HAVE_DIX_CONFIG_H | |
32 | #include <dix-config.h> | |
33 | #endif | |
34 | ||
35 | #include <glxserver.h> | |
36 | #include "unpack.h" | |
37 | #include "indirect_size.h" | |
38 | #include "indirect_dispatch.h" | |
39 | ||
40 | void | |
41 | __glXDisp_Map1f(GLbyte * pc) | |
42 | { | |
43 | GLint order, k; | |
44 | GLfloat u1, u2, *points; | |
45 | GLenum target; | |
46 | ||
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); | |
53 | ||
54 | glMap1f(target, u1, u2, k, order, points); | |
55 | } | |
56 | ||
57 | void | |
58 | __glXDisp_Map2f(GLbyte * pc) | |
59 | { | |
60 | GLint uorder, vorder, ustride, vstride, k; | |
61 | GLfloat u1, u2, v1, v2, *points; | |
62 | GLenum target; | |
63 | ||
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); | |
72 | ||
73 | k = __glMap2f_size(target); | |
74 | ustride = vorder * k; | |
75 | vstride = k; | |
76 | ||
77 | glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); | |
78 | } | |
79 | ||
80 | void | |
81 | __glXDisp_Map1d(GLbyte * pc) | |
82 | { | |
83 | GLint order, k; | |
84 | ||
85 | #ifdef __GLX_ALIGN64 | |
86 | GLint compsize; | |
87 | #endif | |
88 | GLenum target; | |
89 | GLdouble u1, u2, *points; | |
90 | ||
91 | target = *(GLenum *) (pc + 16); | |
92 | order = *(GLint *) (pc + 20); | |
93 | k = __glMap1d_size(target); | |
94 | ||
95 | #ifdef __GLX_ALIGN64 | |
96 | if (order < 0 || k < 0) { | |
97 | compsize = 0; | |
98 | } | |
99 | else { | |
100 | compsize = order * k; | |
101 | } | |
102 | #endif | |
103 | ||
104 | __GLX_GET_DOUBLE(u1, pc); | |
105 | __GLX_GET_DOUBLE(u2, pc + 8); | |
106 | pc += 24; | |
107 | ||
108 | #ifdef __GLX_ALIGN64 | |
109 | if (((unsigned long) pc) & 7) { | |
110 | /* | |
111 | ** Copy the doubles up 4 bytes, trashing the command but aligning | |
112 | ** the data in the process | |
113 | */ | |
114 | __GLX_MEM_COPY(pc - 4, pc, compsize * 8); | |
115 | points = (GLdouble *) (pc - 4); | |
116 | } | |
117 | else { | |
118 | points = (GLdouble *) pc; | |
119 | } | |
120 | #else | |
121 | points = (GLdouble *) pc; | |
122 | #endif | |
123 | glMap1d(target, u1, u2, k, order, points); | |
124 | } | |
125 | ||
126 | void | |
127 | __glXDisp_Map2d(GLbyte * pc) | |
128 | { | |
129 | GLdouble u1, u2, v1, v2, *points; | |
130 | GLint uorder, vorder, ustride, vstride, k; | |
131 | ||
132 | #ifdef __GLX_ALIGN64 | |
133 | GLint compsize; | |
134 | #endif | |
135 | GLenum target; | |
136 | ||
137 | target = *(GLenum *) (pc + 32); | |
138 | uorder = *(GLint *) (pc + 36); | |
139 | vorder = *(GLint *) (pc + 40); | |
140 | k = __glMap2d_size(target); | |
141 | ||
142 | #ifdef __GLX_ALIGN64 | |
143 | if (vorder < 0 || uorder < 0 || k < 0) { | |
144 | compsize = 0; | |
145 | } | |
146 | else { | |
147 | compsize = uorder * vorder * k; | |
148 | } | |
149 | #endif | |
150 | ||
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); | |
155 | pc += 44; | |
156 | ||
157 | ustride = vorder * k; | |
158 | vstride = k; | |
159 | ||
160 | #ifdef __GLX_ALIGN64 | |
161 | if (((unsigned long) pc) & 7) { | |
162 | /* | |
163 | ** Copy the doubles up 4 bytes, trashing the command but aligning | |
164 | ** the data in the process | |
165 | */ | |
166 | __GLX_MEM_COPY(pc - 4, pc, compsize * 8); | |
167 | points = (GLdouble *) (pc - 4); | |
168 | } | |
169 | else { | |
170 | points = (GLdouble *) pc; | |
171 | } | |
172 | #else | |
173 | points = (GLdouble *) pc; | |
174 | #endif | |
175 | glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); | |
176 | } | |
177 | ||
178 | void | |
179 | __glXDisp_DrawArrays(GLbyte * pc) | |
180 | { | |
181 | __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *) pc; | |
182 | __GLXdispatchDrawArraysComponentHeader *compHeader; | |
183 | GLint numVertexes = hdr->numVertexes; | |
184 | GLint numComponents = hdr->numComponents; | |
185 | GLenum primType = hdr->primType; | |
186 | GLint stride = 0; | |
187 | int i; | |
188 | ||
189 | pc += sizeof(__GLXdispatchDrawArraysHeader); | |
190 | compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc; | |
191 | ||
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; | |
196 | ||
197 | stride += __GLX_PAD(numVals * __glXTypeSize(datatype)); | |
198 | } | |
199 | ||
200 | pc += numComponents * sizeof(__GLXdispatchDrawArraysComponentHeader); | |
201 | ||
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; | |
207 | ||
208 | switch (component) { | |
209 | case GL_VERTEX_ARRAY: | |
210 | glEnableClientState(GL_VERTEX_ARRAY); | |
211 | glVertexPointer(numVals, datatype, stride, pc); | |
212 | break; | |
213 | case GL_NORMAL_ARRAY: | |
214 | glEnableClientState(GL_NORMAL_ARRAY); | |
215 | glNormalPointer(datatype, stride, pc); | |
216 | break; | |
217 | case GL_COLOR_ARRAY: | |
218 | glEnableClientState(GL_COLOR_ARRAY); | |
219 | glColorPointer(numVals, datatype, stride, pc); | |
220 | break; | |
221 | case GL_INDEX_ARRAY: | |
222 | glEnableClientState(GL_INDEX_ARRAY); | |
223 | glIndexPointer(datatype, stride, pc); | |
224 | break; | |
225 | case GL_TEXTURE_COORD_ARRAY: | |
226 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | |
227 | glTexCoordPointer(numVals, datatype, stride, pc); | |
228 | break; | |
229 | case GL_EDGE_FLAG_ARRAY: | |
230 | glEnableClientState(GL_EDGE_FLAG_ARRAY); | |
231 | glEdgeFlagPointer(stride, (const GLboolean *) pc); | |
232 | break; | |
233 | case GL_SECONDARY_COLOR_ARRAY: | |
234 | { | |
235 | PFNGLSECONDARYCOLORPOINTERPROC SecondaryColorPointerEXT = | |
236 | __glGetProcAddress("glSecondaryColorPointerEXT"); | |
237 | glEnableClientState(GL_SECONDARY_COLOR_ARRAY); | |
238 | SecondaryColorPointerEXT(numVals, datatype, stride, pc); | |
239 | break; | |
240 | } | |
241 | case GL_FOG_COORD_ARRAY: | |
242 | { | |
243 | PFNGLFOGCOORDPOINTERPROC FogCoordPointerEXT = | |
244 | __glGetProcAddress("glFogCoordPointerEXT"); | |
245 | glEnableClientState(GL_FOG_COORD_ARRAY); | |
246 | FogCoordPointerEXT(datatype, stride, pc); | |
247 | break; | |
248 | } | |
249 | default: | |
250 | break; | |
251 | } | |
252 | ||
253 | pc += __GLX_PAD(numVals * __glXTypeSize(datatype)); | |
254 | } | |
255 | ||
256 | glDrawArrays(primType, 0, numVertexes); | |
257 | ||
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); | |
267 | } |