1 /*
2 * Copyright © 2012 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24 #include <gtest/gtest.h>
25 #include "../../../mesa/main/glheader.h"
26
27 #include "glapi/glapi.h"
28 #include "glapitable.h"
29
30 struct name_offset {
31 const char *name;
32 int offset;
33 };
34
35 extern const struct name_offset linux_gl_abi[];
36
TEST(GetProcAddress,ABIOffsetByName)37 TEST(GetProcAddress, ABIOffsetByName)
38 {
39 /* 408 functions have had their locations in the dispatch table set since
40 * the dawn of time. Verify that all of these functions are at the correct
41 * locations.
42 */
43 for (unsigned i = 0; linux_gl_abi[i].name != NULL; i++) {
44 EXPECT_EQ(linux_gl_abi[i].offset,
45 _glapi_get_proc_offset(linux_gl_abi[i].name))
46 << "function name: " << linux_gl_abi[i].name;
47 }
48 }
49
TEST(GetProcAddress,TableBigEnoughForABI)50 TEST(GetProcAddress, TableBigEnoughForABI)
51 {
52 /* FINISHME: This should check that the dispatch table is large enough to
53 * FINISHME: hold all of the unique functions for OpenGL 1.2, OpenGL ES
54 * FINISHME: 1.1, and OpenGL ES 2.0.
55 */
56 EXPECT_LT(408u, _glapi_get_dispatch_table_size());
57 }
58
59 const struct name_offset linux_gl_abi[] = {
60 { "glNewList", 0 },
61 { "glEndList", 1 },
62 { "glCallList", 2 },
63 { "glCallLists", 3 },
64 { "glDeleteLists", 4 },
65 { "glGenLists", 5 },
66 { "glListBase", 6 },
67 { "glBegin", 7 },
68 { "glBitmap", 8 },
69 { "glColor3b", 9 },
70 { "glColor3bv", 10 },
71 { "glColor3d", 11 },
72 { "glColor3dv", 12 },
73 { "glColor3f", 13 },
74 { "glColor3fv", 14 },
75 { "glColor3i", 15 },
76 { "glColor3iv", 16 },
77 { "glColor3s", 17 },
78 { "glColor3sv", 18 },
79 { "glColor3ub", 19 },
80 { "glColor3ubv", 20 },
81 { "glColor3ui", 21 },
82 { "glColor3uiv", 22 },
83 { "glColor3us", 23 },
84 { "glColor3usv", 24 },
85 { "glColor4b", 25 },
86 { "glColor4bv", 26 },
87 { "glColor4d", 27 },
88 { "glColor4dv", 28 },
89 { "glColor4f", 29 },
90 { "glColor4fv", 30 },
91 { "glColor4i", 31 },
92 { "glColor4iv", 32 },
93 { "glColor4s", 33 },
94 { "glColor4sv", 34 },
95 { "glColor4ub", 35 },
96 { "glColor4ubv", 36 },
97 { "glColor4ui", 37 },
98 { "glColor4uiv", 38 },
99 { "glColor4us", 39 },
100 { "glColor4usv", 40 },
101 { "glEdgeFlag", 41 },
102 { "glEdgeFlagv", 42 },
103 { "glEnd", 43 },
104 { "glIndexd", 44 },
105 { "glIndexdv", 45 },
106 { "glIndexf", 46 },
107 { "glIndexfv", 47 },
108 { "glIndexi", 48 },
109 { "glIndexiv", 49 },
110 { "glIndexs", 50 },
111 { "glIndexsv", 51 },
112 { "glNormal3b", 52 },
113 { "glNormal3bv", 53 },
114 { "glNormal3d", 54 },
115 { "glNormal3dv", 55 },
116 { "glNormal3f", 56 },
117 { "glNormal3fv", 57 },
118 { "glNormal3i", 58 },
119 { "glNormal3iv", 59 },
120 { "glNormal3s", 60 },
121 { "glNormal3sv", 61 },
122 { "glRasterPos2d", 62 },
123 { "glRasterPos2dv", 63 },
124 { "glRasterPos2f", 64 },
125 { "glRasterPos2fv", 65 },
126 { "glRasterPos2i", 66 },
127 { "glRasterPos2iv", 67 },
128 { "glRasterPos2s", 68 },
129 { "glRasterPos2sv", 69 },
130 { "glRasterPos3d", 70 },
131 { "glRasterPos3dv", 71 },
132 { "glRasterPos3f", 72 },
133 { "glRasterPos3fv", 73 },
134 { "glRasterPos3i", 74 },
135 { "glRasterPos3iv", 75 },
136 { "glRasterPos3s", 76 },
137 { "glRasterPos3sv", 77 },
138 { "glRasterPos4d", 78 },
139 { "glRasterPos4dv", 79 },
140 { "glRasterPos4f", 80 },
141 { "glRasterPos4fv", 81 },
142 { "glRasterPos4i", 82 },
143 { "glRasterPos4iv", 83 },
144 { "glRasterPos4s", 84 },
145 { "glRasterPos4sv", 85 },
146 { "glRectd", 86 },
147 { "glRectdv", 87 },
148 { "glRectf", 88 },
149 { "glRectfv", 89 },
150 { "glRecti", 90 },
151 { "glRectiv", 91 },
152 { "glRects", 92 },
153 { "glRectsv", 93 },
154 { "glTexCoord1d", 94 },
155 { "glTexCoord1dv", 95 },
156 { "glTexCoord1f", 96 },
157 { "glTexCoord1fv", 97 },
158 { "glTexCoord1i", 98 },
159 { "glTexCoord1iv", 99 },
160 { "glTexCoord1s", 100 },
161 { "glTexCoord1sv", 101 },
162 { "glTexCoord2d", 102 },
163 { "glTexCoord2dv", 103 },
164 { "glTexCoord2f", 104 },
165 { "glTexCoord2fv", 105 },
166 { "glTexCoord2i", 106 },
167 { "glTexCoord2iv", 107 },
168 { "glTexCoord2s", 108 },
169 { "glTexCoord2sv", 109 },
170 { "glTexCoord3d", 110 },
171 { "glTexCoord3dv", 111 },
172 { "glTexCoord3f", 112 },
173 { "glTexCoord3fv", 113 },
174 { "glTexCoord3i", 114 },
175 { "glTexCoord3iv", 115 },
176 { "glTexCoord3s", 116 },
177 { "glTexCoord3sv", 117 },
178 { "glTexCoord4d", 118 },
179 { "glTexCoord4dv", 119 },
180 { "glTexCoord4f", 120 },
181 { "glTexCoord4fv", 121 },
182 { "glTexCoord4i", 122 },
183 { "glTexCoord4iv", 123 },
184 { "glTexCoord4s", 124 },
185 { "glTexCoord4sv", 125 },
186 { "glVertex2d", 126 },
187 { "glVertex2dv", 127 },
188 { "glVertex2f", 128 },
189 { "glVertex2fv", 129 },
190 { "glVertex2i", 130 },
191 { "glVertex2iv", 131 },
192 { "glVertex2s", 132 },
193 { "glVertex2sv", 133 },
194 { "glVertex3d", 134 },
195 { "glVertex3dv", 135 },
196 { "glVertex3f", 136 },
197 { "glVertex3fv", 137 },
198 { "glVertex3i", 138 },
199 { "glVertex3iv", 139 },
200 { "glVertex3s", 140 },
201 { "glVertex3sv", 141 },
202 { "glVertex4d", 142 },
203 { "glVertex4dv", 143 },
204 { "glVertex4f", 144 },
205 { "glVertex4fv", 145 },
206 { "glVertex4i", 146 },
207 { "glVertex4iv", 147 },
208 { "glVertex4s", 148 },
209 { "glVertex4sv", 149 },
210 { "glClipPlane", 150 },
211 { "glColorMaterial", 151 },
212 { "glCullFace", 152 },
213 { "glFogf", 153 },
214 { "glFogfv", 154 },
215 { "glFogi", 155 },
216 { "glFogiv", 156 },
217 { "glFrontFace", 157 },
218 { "glHint", 158 },
219 { "glLightf", 159 },
220 { "glLightfv", 160 },
221 { "glLighti", 161 },
222 { "glLightiv", 162 },
223 { "glLightModelf", 163 },
224 { "glLightModelfv", 164 },
225 { "glLightModeli", 165 },
226 { "glLightModeliv", 166 },
227 { "glLineStipple", 167 },
228 { "glLineWidth", 168 },
229 { "glMaterialf", 169 },
230 { "glMaterialfv", 170 },
231 { "glMateriali", 171 },
232 { "glMaterialiv", 172 },
233 { "glPointSize", 173 },
234 { "glPolygonMode", 174 },
235 { "glPolygonStipple", 175 },
236 { "glScissor", 176 },
237 { "glShadeModel", 177 },
238 { "glTexParameterf", 178 },
239 { "glTexParameterfv", 179 },
240 { "glTexParameteri", 180 },
241 { "glTexParameteriv", 181 },
242 { "glTexImage1D", 182 },
243 { "glTexImage2D", 183 },
244 { "glTexEnvf", 184 },
245 { "glTexEnvfv", 185 },
246 { "glTexEnvi", 186 },
247 { "glTexEnviv", 187 },
248 { "glTexGend", 188 },
249 { "glTexGendv", 189 },
250 { "glTexGenf", 190 },
251 { "glTexGenfv", 191 },
252 { "glTexGeni", 192 },
253 { "glTexGeniv", 193 },
254 { "glFeedbackBuffer", 194 },
255 { "glSelectBuffer", 195 },
256 { "glRenderMode", 196 },
257 { "glInitNames", 197 },
258 { "glLoadName", 198 },
259 { "glPassThrough", 199 },
260 { "glPopName", 200 },
261 { "glPushName", 201 },
262 { "glDrawBuffer", 202 },
263 { "glClear", 203 },
264 { "glClearAccum", 204 },
265 { "glClearIndex", 205 },
266 { "glClearColor", 206 },
267 { "glClearStencil", 207 },
268 { "glClearDepth", 208 },
269 { "glStencilMask", 209 },
270 { "glColorMask", 210 },
271 { "glDepthMask", 211 },
272 { "glIndexMask", 212 },
273 { "glAccum", 213 },
274 { "glDisable", 214 },
275 { "glEnable", 215 },
276 { "glFinish", 216 },
277 { "glFlush", 217 },
278 { "glPopAttrib", 218 },
279 { "glPushAttrib", 219 },
280 { "glMap1d", 220 },
281 { "glMap1f", 221 },
282 { "glMap2d", 222 },
283 { "glMap2f", 223 },
284 { "glMapGrid1d", 224 },
285 { "glMapGrid1f", 225 },
286 { "glMapGrid2d", 226 },
287 { "glMapGrid2f", 227 },
288 { "glEvalCoord1d", 228 },
289 { "glEvalCoord1dv", 229 },
290 { "glEvalCoord1f", 230 },
291 { "glEvalCoord1fv", 231 },
292 { "glEvalCoord2d", 232 },
293 { "glEvalCoord2dv", 233 },
294 { "glEvalCoord2f", 234 },
295 { "glEvalCoord2fv", 235 },
296 { "glEvalMesh1", 236 },
297 { "glEvalPoint1", 237 },
298 { "glEvalMesh2", 238 },
299 { "glEvalPoint2", 239 },
300 { "glAlphaFunc", 240 },
301 { "glBlendFunc", 241 },
302 { "glLogicOp", 242 },
303 { "glStencilFunc", 243 },
304 { "glStencilOp", 244 },
305 { "glDepthFunc", 245 },
306 { "glPixelZoom", 246 },
307 { "glPixelTransferf", 247 },
308 { "glPixelTransferi", 248 },
309 { "glPixelStoref", 249 },
310 { "glPixelStorei", 250 },
311 { "glPixelMapfv", 251 },
312 { "glPixelMapuiv", 252 },
313 { "glPixelMapusv", 253 },
314 { "glReadBuffer", 254 },
315 { "glCopyPixels", 255 },
316 { "glReadPixels", 256 },
317 { "glDrawPixels", 257 },
318 { "glGetBooleanv", 258 },
319 { "glGetClipPlane", 259 },
320 { "glGetDoublev", 260 },
321 { "glGetError", 261 },
322 { "glGetFloatv", 262 },
323 { "glGetIntegerv", 263 },
324 { "glGetLightfv", 264 },
325 { "glGetLightiv", 265 },
326 { "glGetMapdv", 266 },
327 { "glGetMapfv", 267 },
328 { "glGetMapiv", 268 },
329 { "glGetMaterialfv", 269 },
330 { "glGetMaterialiv", 270 },
331 { "glGetPixelMapfv", 271 },
332 { "glGetPixelMapuiv", 272 },
333 { "glGetPixelMapusv", 273 },
334 { "glGetPolygonStipple", 274 },
335 { "glGetString", 275 },
336 { "glGetTexEnvfv", 276 },
337 { "glGetTexEnviv", 277 },
338 { "glGetTexGendv", 278 },
339 { "glGetTexGenfv", 279 },
340 { "glGetTexGeniv", 280 },
341 { "glGetTexImage", 281 },
342 { "glGetTexParameterfv", 282 },
343 { "glGetTexParameteriv", 283 },
344 { "glGetTexLevelParameterfv", 284 },
345 { "glGetTexLevelParameteriv", 285 },
346 { "glIsEnabled", 286 },
347 { "glIsList", 287 },
348 { "glDepthRange", 288 },
349 { "glFrustum", 289 },
350 { "glLoadIdentity", 290 },
351 { "glLoadMatrixf", 291 },
352 { "glLoadMatrixd", 292 },
353 { "glMatrixMode", 293 },
354 { "glMultMatrixf", 294 },
355 { "glMultMatrixd", 295 },
356 { "glOrtho", 296 },
357 { "glPopMatrix", 297 },
358 { "glPushMatrix", 298 },
359 { "glRotated", 299 },
360 { "glRotatef", 300 },
361 { "glScaled", 301 },
362 { "glScalef", 302 },
363 { "glTranslated", 303 },
364 { "glTranslatef", 304 },
365 { "glViewport", 305 },
366 { "glArrayElement", 306 },
367 { "glColorPointer", 308 },
368 { "glDisableClientState", 309 },
369 { "glDrawArrays", 310 },
370 { "glDrawElements", 311 },
371 { "glEdgeFlagPointer", 312 },
372 { "glEnableClientState", 313 },
373 { "glGetPointerv", 329 },
374 { "glIndexPointer", 314 },
375 { "glInterleavedArrays", 317 },
376 { "glNormalPointer", 318 },
377 { "glTexCoordPointer", 320 },
378 { "glVertexPointer", 321 },
379 { "glPolygonOffset", 319 },
380 { "glCopyTexImage1D", 323 },
381 { "glCopyTexImage2D", 324 },
382 { "glCopyTexSubImage1D", 325 },
383 { "glCopyTexSubImage2D", 326 },
384 { "glTexSubImage1D", 332 },
385 { "glTexSubImage2D", 333 },
386 { "glAreTexturesResident", 322 },
387 { "glBindTexture", 307 },
388 { "glDeleteTextures", 327 },
389 { "glGenTextures", 328 },
390 { "glIsTexture", 330 },
391 { "glPrioritizeTextures", 331 },
392 { "glIndexub", 315 },
393 { "glIndexubv", 316 },
394 { "glPopClientAttrib", 334 },
395 { "glPushClientAttrib", 335 },
396 { "glBlendColor", 336 },
397 { "glBlendEquation", 337 },
398 { "glDrawRangeElements", 338 },
399 { "glColorTable", 339 },
400 { "glColorTableParameterfv", 340 },
401 { "glColorTableParameteriv", 341 },
402 { "glCopyColorTable", 342 },
403 { "glGetColorTable", 343 },
404 { "glGetColorTableParameterfv", 344 },
405 { "glGetColorTableParameteriv", 345 },
406 { "glColorSubTable", 346 },
407 { "glCopyColorSubTable", 347 },
408 { "glConvolutionFilter1D", 348 },
409 { "glConvolutionFilter2D", 349 },
410 { "glConvolutionParameterf", 350 },
411 { "glConvolutionParameterfv", 351 },
412 { "glConvolutionParameteri", 352 },
413 { "glConvolutionParameteriv", 353 },
414 { "glCopyConvolutionFilter1D", 354 },
415 { "glCopyConvolutionFilter2D", 355 },
416 { "glGetConvolutionFilter", 356 },
417 { "glGetConvolutionParameterfv", 357 },
418 { "glGetConvolutionParameteriv", 358 },
419 { "glGetSeparableFilter", 359 },
420 { "glSeparableFilter2D", 360 },
421 { "glGetHistogram", 361 },
422 { "glGetHistogramParameterfv", 362 },
423 { "glGetHistogramParameteriv", 363 },
424 { "glGetMinmax", 364 },
425 { "glGetMinmaxParameterfv", 365 },
426 { "glGetMinmaxParameteriv", 366 },
427 { "glHistogram", 367 },
428 { "glMinmax", 368 },
429 { "glResetHistogram", 369 },
430 { "glResetMinmax", 370 },
431 { "glTexImage3D", 371 },
432 { "glTexSubImage3D", 372 },
433 { "glCopyTexSubImage3D", 373 },
434 { "glActiveTextureARB", 374 },
435 { "glClientActiveTextureARB", 375 },
436 { "glMultiTexCoord1dARB", 376 },
437 { "glMultiTexCoord1dvARB", 377 },
438 { "glMultiTexCoord1fARB", 378 },
439 { "glMultiTexCoord1fvARB", 379 },
440 { "glMultiTexCoord1iARB", 380 },
441 { "glMultiTexCoord1ivARB", 381 },
442 { "glMultiTexCoord1sARB", 382 },
443 { "glMultiTexCoord1svARB", 383 },
444 { "glMultiTexCoord2dARB", 384 },
445 { "glMultiTexCoord2dvARB", 385 },
446 { "glMultiTexCoord2fARB", 386 },
447 { "glMultiTexCoord2fvARB", 387 },
448 { "glMultiTexCoord2iARB", 388 },
449 { "glMultiTexCoord2ivARB", 389 },
450 { "glMultiTexCoord2sARB", 390 },
451 { "glMultiTexCoord2svARB", 391 },
452 { "glMultiTexCoord3dARB", 392 },
453 { "glMultiTexCoord3dvARB", 393 },
454 { "glMultiTexCoord3fARB", 394 },
455 { "glMultiTexCoord3fvARB", 395 },
456 { "glMultiTexCoord3iARB", 396 },
457 { "glMultiTexCoord3ivARB", 397 },
458 { "glMultiTexCoord3sARB", 398 },
459 { "glMultiTexCoord3svARB", 399 },
460 { "glMultiTexCoord4dARB", 400 },
461 { "glMultiTexCoord4dvARB", 401 },
462 { "glMultiTexCoord4fARB", 402 },
463 { "glMultiTexCoord4fvARB", 403 },
464 { "glMultiTexCoord4iARB", 404 },
465 { "glMultiTexCoord4ivARB", 405 },
466 { "glMultiTexCoord4sARB", 406 },
467 { "glMultiTexCoord4svARB", 407 },
468 { NULL, 0 }
469 };
470