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