2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """code generator for GL/GLES extension wrangler."""
14 from subprocess
import call
15 from collections
import namedtuple
18 '../../third_party/khronos',
19 '../../third_party/mesa/src/include',
24 UNCONDITIONALLY_BOUND_EXTENSIONS
= set([
25 'WGL_ARB_extensions_string',
26 'WGL_EXT_extensions_string',
27 'GL_CHROMIUM_gles_depth_binding_hack', # crbug.com/448206
28 'GL_CHROMIUM_glgetstringi_hack', # crbug.com/470396
31 """Function binding conditions can be specified manually by supplying a versions
32 array instead of the names array. Each version has the following keys:
33 name: Mandatory. Name of the function. Multiple versions can have the same
34 name but different conditions.
35 extensions: Extra Extensions for which the function is bound. Only needed
36 in some cases where the extension cannot be parsed from the
39 By default, the function gets its name from the first name in its names or
40 versions array. This can be overridden by supplying a 'known_as' key.
43 { 'return_type': 'void',
44 'names': ['glActiveTexture'],
45 'arguments': 'GLenum texture', },
46 { 'return_type': 'void',
47 'names': ['glAttachShader'],
48 'arguments': 'GLuint program, GLuint shader', },
49 { 'return_type': 'void',
50 'versions': [{ 'name': 'glBeginQuery' },
51 { 'name': 'glBeginQueryARB' },
52 { 'name': 'glBeginQueryEXT',
53 'extensions': ['GL_EXT_occlusion_query_boolean'] }],
54 'arguments': 'GLenum target, GLuint id', },
55 { 'return_type': 'void',
56 'versions': [{ 'name': 'glBeginTransformFeedback' }],
57 'arguments': 'GLenum primitiveMode', },
58 { 'return_type': 'void',
59 'names': ['glBindAttribLocation'],
60 'arguments': 'GLuint program, GLuint index, const char* name', },
61 { 'return_type': 'void',
62 'names': ['glBindBuffer'],
63 'arguments': 'GLenum target, GLuint buffer', },
64 { 'return_type': 'void',
65 'versions': [{ 'name': 'glBindBufferBase' }],
66 'arguments': 'GLenum target, GLuint index, GLuint buffer', },
67 { 'return_type': 'void',
68 'versions': [{ 'name': 'glBindBufferRange' }],
69 'arguments': 'GLenum target, GLuint index, GLuint buffer, GLintptr offset, '
71 { 'return_type': 'void',
72 'names': ['glBindFragDataLocation'],
73 'arguments': 'GLuint program, GLuint colorNumber, const char* name', },
74 { 'return_type': 'void',
75 'names': ['glBindFragDataLocationIndexed'],
77 'GLuint program, GLuint colorNumber, GLuint index, const char* name', },
78 { 'return_type': 'void',
79 'names': ['glBindFramebufferEXT', 'glBindFramebuffer'],
80 'arguments': 'GLenum target, GLuint framebuffer', },
81 { 'return_type': 'void',
82 'names': ['glBindRenderbufferEXT', 'glBindRenderbuffer'],
83 'arguments': 'GLenum target, GLuint renderbuffer', },
84 { 'return_type': 'void',
85 'versions': [{ 'name': 'glBindSampler' }],
86 'arguments': 'GLuint unit, GLuint sampler', },
87 { 'return_type': 'void',
88 'names': ['glBindTexture'],
89 'arguments': 'GLenum target, GLuint texture', },
90 { 'return_type': 'void',
91 'versions': [{ 'name': 'glBindTransformFeedback' }],
92 'arguments': 'GLenum target, GLuint id', },
93 { 'return_type': 'void',
94 'known_as': 'glBindVertexArrayOES',
95 'versions': [{ 'name': 'glBindVertexArray',
96 'extensions': ['GL_ARB_vertex_array_object'], },
97 { 'name': 'glBindVertexArrayOES' },
98 { 'name': 'glBindVertexArrayAPPLE',
99 'extensions': ['GL_APPLE_vertex_array_object'] }],
100 'arguments': 'GLuint array' },
101 { 'return_type': 'void',
102 'known_as': 'glBlendBarrierKHR',
103 'versions': [{ 'name': 'glBlendBarrierNV',
104 'extensions': ['GL_NV_blend_equation_advanced'] },
105 { 'name': 'glBlendBarrierKHR',
106 'extensions': ['GL_KHR_blend_equation_advanced'] }],
107 'arguments': 'void' },
108 { 'return_type': 'void',
109 'names': ['glBlendColor'],
110 'arguments': 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha', },
111 { 'return_type': 'void',
112 'names': ['glBlendEquation'],
113 'arguments': ' GLenum mode ', },
114 { 'return_type': 'void',
115 'names': ['glBlendEquationSeparate'],
116 'arguments': 'GLenum modeRGB, GLenum modeAlpha', },
117 { 'return_type': 'void',
118 'names': ['glBlendFunc'],
119 'arguments': 'GLenum sfactor, GLenum dfactor', },
120 { 'return_type': 'void',
121 'names': ['glBlendFuncSeparate'],
123 'GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha', },
124 { 'return_type': 'void',
125 'names': ['glBlitFramebuffer'],
126 'arguments': 'GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, '
127 'GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, '
128 'GLbitfield mask, GLenum filter', },
129 { 'return_type': 'void',
130 'names': ['glBlitFramebufferANGLE', 'glBlitFramebuffer'],
131 'arguments': 'GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, '
132 'GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, '
133 'GLbitfield mask, GLenum filter', },
134 { 'return_type': 'void',
135 'names': ['glBlitFramebufferEXT', 'glBlitFramebuffer'],
136 'arguments': 'GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, '
137 'GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, '
138 'GLbitfield mask, GLenum filter', },
139 { 'return_type': 'void',
140 'names': ['glBufferData'],
142 'GLenum target, GLsizeiptr size, const void* data, GLenum usage', },
143 { 'return_type': 'void',
144 'names': ['glBufferSubData'],
146 'GLenum target, GLintptr offset, GLsizeiptr size, const void* data', },
147 { 'return_type': 'GLenum',
148 'names': ['glCheckFramebufferStatusEXT',
149 'glCheckFramebufferStatus'],
150 'arguments': 'GLenum target',
152 GL_SERVICE_LOG("GL_RESULT: " << GLEnums::GetStringEnum(result));
154 { 'return_type': 'void',
155 'names': ['glClear'],
156 'arguments': 'GLbitfield mask', },
157 { 'return_type': 'void',
158 'versions': [{ 'name': 'glClearBufferfi' }],
159 'arguments': 'GLenum buffer, GLint drawbuffer, const GLfloat depth, '
161 { 'return_type': 'void',
162 'versions': [{ 'name': 'glClearBufferfv' }],
163 'arguments': 'GLenum buffer, GLint drawbuffer, const GLfloat* value', },
164 { 'return_type': 'void',
165 'versions': [{ 'name': 'glClearBufferiv' }],
166 'arguments': 'GLenum buffer, GLint drawbuffer, const GLint* value', },
167 { 'return_type': 'void',
168 'versions': [{ 'name': 'glClearBufferuiv' }],
169 'arguments': 'GLenum buffer, GLint drawbuffer, const GLuint* value', },
170 { 'return_type': 'void',
171 'names': ['glClearColor'],
172 'arguments': 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha', },
173 { 'return_type': 'void',
174 'versions': [{ 'name': 'glClearDepth',
175 'extensions': ['GL_CHROMIUM_gles_depth_binding_hack'] }],
176 'arguments': 'GLclampd depth', },
177 { 'return_type': 'void',
178 'names': ['glClearDepthf'],
179 'arguments': 'GLclampf depth', },
180 { 'return_type': 'void',
181 'names': ['glClearStencil'],
182 'arguments': 'GLint s', },
183 { 'return_type': 'GLenum',
184 'versions': [{ 'name': 'glClientWaitSync',
185 'extensions': ['GL_ARB_sync'] }],
186 'arguments': 'GLsync sync, GLbitfield flags, GLuint64 timeout', },
187 { 'return_type': 'void',
188 'names': ['glColorMask'],
190 'GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha', },
191 { 'return_type': 'void',
192 'names': ['glCompileShader'],
193 'arguments': 'GLuint shader', },
194 { 'return_type': 'void',
195 'names': ['glCompressedTexImage2D'],
197 'GLenum target, GLint level, GLenum internalformat, GLsizei width, '
198 'GLsizei height, GLint border, GLsizei imageSize, const void* data', },
199 { 'return_type': 'void',
200 'versions': [{ 'name': 'glCompressedTexImage3D' }],
202 'GLenum target, GLint level, GLenum internalformat, GLsizei width, '
203 'GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, '
204 'const void* data', },
205 { 'return_type': 'void',
206 'names': ['glCompressedTexSubImage2D'],
208 'GLenum target, GLint level, GLint xoffset, GLint yoffset, '
209 'GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, '
210 'const void* data', },
211 # TODO(zmo): wait for MOCK_METHOD11.
212 # { 'return_type': 'void',
213 # 'versions': [{ 'name': 'glCompressedTexSubImage3D' }],
215 # 'GLenum target, GLint level, GLint xoffset, GLint yoffset, '
216 # 'GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, '
217 # 'GLenum format, GLsizei imageSize, const void* data', },
218 { 'return_type': 'void',
219 'versions': [{ 'name': 'glCopyBufferSubData' }],
221 'GLenum readTarget, GLenum writeTarget, GLintptr readOffset, '
222 'GLintptr writeOffset, GLsizeiptr size', },
223 { 'return_type': 'void',
224 'names': ['glCopyTexImage2D'],
226 'GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, '
227 'GLsizei width, GLsizei height, GLint border', },
228 { 'return_type': 'void',
229 'names': ['glCopyTexSubImage2D'],
231 'GLenum target, GLint level, GLint xoffset, '
232 'GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height', },
233 { 'return_type': 'void',
234 'versions': [{ 'name': 'glCopyTexSubImage3D' }],
236 'GLenum target, GLint level, GLint xoffset, GLint yoffset, '
237 'GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height', },
238 { 'return_type': 'GLuint',
239 'names': ['glCreateProgram'],
240 'arguments': 'void', },
241 { 'return_type': 'GLuint',
242 'names': ['glCreateShader'],
243 'arguments': 'GLenum type', },
244 { 'return_type': 'void',
245 'names': ['glCullFace'],
246 'arguments': 'GLenum mode', },
247 { 'return_type': 'void',
248 'names': ['glDeleteBuffers'],
249 'known_as': 'glDeleteBuffersARB',
250 'arguments': 'GLsizei n, const GLuint* buffers', },
251 { 'return_type': 'void',
252 'known_as': 'glDeleteFencesAPPLE',
253 'versions': [{ 'name': 'glDeleteFencesAPPLE',
254 'extensions': ['GL_APPLE_fence'] }],
255 'arguments': 'GLsizei n, const GLuint* fences', },
256 { 'return_type': 'void',
257 'names': ['glDeleteFencesNV'],
258 'arguments': 'GLsizei n, const GLuint* fences', },
259 { 'return_type': 'void',
260 'names': ['glDeleteFramebuffersEXT', 'glDeleteFramebuffers'],
261 'arguments': 'GLsizei n, const GLuint* framebuffers', },
262 { 'return_type': 'void',
263 'names': ['glDeleteProgram'],
264 'arguments': 'GLuint program', },
265 { 'return_type': 'void',
266 'versions': [{ 'name': 'glDeleteQueries' },
267 { 'name': 'glDeleteQueriesARB'},
268 { 'name': 'glDeleteQueriesEXT',
269 'extensions': ['GL_EXT_occlusion_query_boolean'] }],
270 'arguments': 'GLsizei n, const GLuint* ids', },
271 { 'return_type': 'void',
272 'names': ['glDeleteRenderbuffersEXT', 'glDeleteRenderbuffers'],
273 'arguments': 'GLsizei n, const GLuint* renderbuffers', },
274 { 'return_type': 'void',
275 'versions': [{ 'name': 'glDeleteSamplers' }],
276 'arguments': 'GLsizei n, const GLuint* samplers', },
277 { 'return_type': 'void',
278 'names': ['glDeleteShader'],
279 'arguments': 'GLuint shader', },
280 { 'return_type': 'void',
281 'versions': [{ 'name': 'glDeleteSync',
282 'extensions': ['GL_ARB_sync'] }],
283 'arguments': 'GLsync sync', },
284 { 'return_type': 'void',
285 'names': ['glDeleteTextures'],
286 'arguments': 'GLsizei n, const GLuint* textures', },
287 { 'return_type': 'void',
288 'versions': [{ 'name': 'glDeleteTransformFeedbacks' }],
289 'arguments': 'GLsizei n, const GLuint* ids', },
290 { 'return_type': 'void',
291 'known_as': 'glDeleteVertexArraysOES',
292 'versions': [{ 'name': 'glDeleteVertexArrays',
293 'extensions': ['GL_ARB_vertex_array_object'], },
294 { 'name': 'glDeleteVertexArraysOES' },
295 { 'name': 'glDeleteVertexArraysAPPLE',
296 'extensions': ['GL_APPLE_vertex_array_object'] }],
297 'arguments': 'GLsizei n, const GLuint* arrays' },
298 { 'return_type': 'void',
299 'names': ['glDepthFunc'],
300 'arguments': 'GLenum func', },
301 { 'return_type': 'void',
302 'names': ['glDepthMask'],
303 'arguments': 'GLboolean flag', },
304 { 'return_type': 'void',
305 'versions': [{ 'name': 'glDepthRange',
306 'extensions': ['GL_CHROMIUM_gles_depth_binding_hack'] }],
307 'arguments': 'GLclampd zNear, GLclampd zFar', },
308 { 'return_type': 'void',
309 'names': ['glDepthRangef'],
310 'arguments': 'GLclampf zNear, GLclampf zFar', },
311 { 'return_type': 'void',
312 'names': ['glDetachShader'],
313 'arguments': 'GLuint program, GLuint shader', },
314 { 'return_type': 'void',
315 'names': ['glDisable'],
316 'arguments': 'GLenum cap', },
317 { 'return_type': 'void',
318 'names': ['glDisableVertexAttribArray'],
319 'arguments': 'GLuint index', },
320 { 'return_type': 'void',
321 'versions': [{ 'name': 'glDiscardFramebufferEXT',
322 'extensions': ['GL_EXT_discard_framebuffer'] }],
323 'arguments': 'GLenum target, GLsizei numAttachments, '
324 'const GLenum* attachments' },
325 { 'return_type': 'void',
326 'names': ['glDrawArrays'],
327 'arguments': 'GLenum mode, GLint first, GLsizei count', },
328 { 'return_type': 'void',
329 'known_as': 'glDrawArraysInstancedANGLE',
330 'names': ['glDrawArraysInstancedARB', 'glDrawArraysInstancedANGLE',
331 'glDrawArraysInstanced'],
332 'arguments': 'GLenum mode, GLint first, GLsizei count, GLsizei primcount', },
333 { 'return_type': 'void',
334 'names': ['glDrawBuffer'],
335 'arguments': 'GLenum mode', },
336 { 'return_type': 'void',
337 'names': ['glDrawBuffersARB', 'glDrawBuffersEXT', 'glDrawBuffers'],
338 'arguments': 'GLsizei n, const GLenum* bufs', },
339 { 'return_type': 'void',
340 'names': ['glDrawElements'],
342 'GLenum mode, GLsizei count, GLenum type, const void* indices', },
343 { 'return_type': 'void',
344 'known_as': 'glDrawElementsInstancedANGLE',
345 'names': ['glDrawElementsInstancedARB', 'glDrawElementsInstancedANGLE',
346 'glDrawElementsInstanced'],
348 'GLenum mode, GLsizei count, GLenum type, const void* indices, '
349 'GLsizei primcount', },
350 { 'return_type': 'void',
351 'versions': [{ 'name': 'glDrawRangeElements' }],
352 'arguments': 'GLenum mode, GLuint start, GLuint end, GLsizei count, '
353 'GLenum type, const void* indices', },
354 { 'return_type': 'void',
355 'names': ['glEGLImageTargetRenderbufferStorageOES'],
356 'arguments': 'GLenum target, GLeglImageOES image', },
357 { 'return_type': 'void',
358 'names': ['glEGLImageTargetTexture2DOES'],
359 'arguments': 'GLenum target, GLeglImageOES image', },
360 { 'return_type': 'void',
361 'names': ['glEnable'],
362 'arguments': 'GLenum cap', },
363 { 'return_type': 'void',
364 'names': ['glEnableVertexAttribArray'],
365 'arguments': 'GLuint index', },
366 { 'return_type': 'void',
367 'versions': [{ 'name': 'glEndQuery' },
368 { 'name': 'glEndQueryARB' },
369 { 'name': 'glEndQueryEXT',
370 'extensions': ['GL_EXT_occlusion_query_boolean'] }],
371 'arguments': 'GLenum target', },
372 { 'return_type': 'void',
373 'versions': [{ 'name': 'glEndTransformFeedback' }],
374 'arguments': 'void', },
375 { 'return_type': 'GLsync',
376 'versions': [{ 'name': 'glFenceSync',
377 'extensions': ['GL_ARB_sync'] }],
378 'arguments': 'GLenum condition, GLbitfield flags', },
379 { 'return_type': 'void',
380 'names': ['glFinish'],
381 'arguments': 'void', },
382 { 'return_type': 'void',
383 'known_as': 'glFinishFenceAPPLE',
384 'versions': [{ 'name': 'glFinishFenceAPPLE',
385 'extensions': ['GL_APPLE_fence'] }],
386 'arguments': 'GLuint fence', },
387 { 'return_type': 'void',
388 'names': ['glFinishFenceNV'],
389 'arguments': 'GLuint fence', },
390 { 'return_type': 'void',
391 'names': ['glFlush'],
392 'arguments': 'void', },
393 { 'return_type': 'void',
394 'names': ['glFlushMappedBufferRange'],
395 'arguments': 'GLenum target, GLintptr offset, GLsizeiptr length', },
396 { 'return_type': 'void',
397 'names': ['glFramebufferRenderbufferEXT', 'glFramebufferRenderbuffer'],
399 'GLenum target, GLenum attachment, GLenum renderbuffertarget, '
400 'GLuint renderbuffer', },
401 { 'return_type': 'void',
402 'names': ['glFramebufferTexture2DEXT', 'glFramebufferTexture2D'],
404 'GLenum target, GLenum attachment, GLenum textarget, GLuint texture, '
406 { 'return_type': 'void',
407 'names': ['glFramebufferTexture2DMultisampleEXT'],
409 'GLenum target, GLenum attachment, GLenum textarget, GLuint texture, '
410 'GLint level, GLsizei samples', },
411 { 'return_type': 'void',
412 'names': ['glFramebufferTexture2DMultisampleIMG'],
414 'GLenum target, GLenum attachment, GLenum textarget, GLuint texture, '
415 'GLint level, GLsizei samples', },
416 { 'return_type': 'void',
417 'versions': [{ 'name': 'glFramebufferTextureLayer' }],
418 'arguments': 'GLenum target, GLenum attachment, GLuint texture, GLint level, '
420 { 'return_type': 'void',
421 'names': ['glFrontFace'],
422 'arguments': 'GLenum mode', },
423 { 'return_type': 'void',
424 'names': ['glGenBuffers'],
425 'known_as': 'glGenBuffersARB',
426 'arguments': 'GLsizei n, GLuint* buffers', },
427 { 'return_type': 'void',
428 'names': ['glGenerateMipmapEXT', 'glGenerateMipmap'],
429 'arguments': 'GLenum target', },
430 { 'return_type': 'void',
431 'known_as': 'glGenFencesAPPLE',
432 'versions': [{ 'name': 'glGenFencesAPPLE',
433 'extensions': ['GL_APPLE_fence'] }],
434 'arguments': 'GLsizei n, GLuint* fences', },
435 { 'return_type': 'void',
436 'names': ['glGenFencesNV'],
437 'arguments': 'GLsizei n, GLuint* fences', },
438 { 'return_type': 'void',
439 'names': ['glGenFramebuffersEXT', 'glGenFramebuffers'],
440 'arguments': 'GLsizei n, GLuint* framebuffers', },
441 { 'return_type': 'void',
442 'versions': [{ 'name': 'glGenQueries' },
443 { 'name': 'glGenQueriesARB', },
444 { 'name' : 'glGenQueriesEXT',
445 'extensions': ['GL_EXT_occlusion_query_boolean'] }],
446 'arguments': 'GLsizei n, GLuint* ids', },
447 { 'return_type': 'void',
448 'names': ['glGenRenderbuffersEXT', 'glGenRenderbuffers'],
449 'arguments': 'GLsizei n, GLuint* renderbuffers', },
450 { 'return_type': 'void',
451 'versions': [{ 'name': 'glGenSamplers' }],
452 'arguments': 'GLsizei n, GLuint* samplers', },
453 { 'return_type': 'void',
454 'names': ['glGenTextures'],
455 'arguments': 'GLsizei n, GLuint* textures', },
456 { 'return_type': 'void',
457 'versions': [{ 'name': 'glGenTransformFeedbacks' }],
458 'arguments': 'GLsizei n, GLuint* ids', },
459 { 'return_type': 'void',
460 'known_as': 'glGenVertexArraysOES',
461 'versions': [{ 'name': 'glGenVertexArrays',
462 'extensions': ['GL_ARB_vertex_array_object'], },
463 { 'name': 'glGenVertexArraysOES' },
464 { 'name': 'glGenVertexArraysAPPLE',
465 'extensions': ['GL_APPLE_vertex_array_object'] }],
466 'arguments': 'GLsizei n, GLuint* arrays', },
467 { 'return_type': 'void',
468 'names': ['glGetActiveAttrib'],
470 'GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, '
471 'GLint* size, GLenum* type, char* name', },
472 { 'return_type': 'void',
473 'names': ['glGetActiveUniform'],
475 'GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, '
476 'GLint* size, GLenum* type, char* name', },
477 { 'return_type': 'void',
478 'versions': [{ 'name': 'glGetActiveUniformBlockiv' }],
479 'arguments': 'GLuint program, GLuint uniformBlockIndex, GLenum pname, '
481 { 'return_type': 'void',
482 'versions': [{ 'name': 'glGetActiveUniformBlockName' }],
483 'arguments': 'GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, '
484 'GLsizei* length, char* uniformBlockName', },
485 { 'return_type': 'void',
486 'versions': [{ 'name': 'glGetActiveUniformsiv' }],
487 'arguments': 'GLuint program, GLsizei uniformCount, '
488 'const GLuint* uniformIndices, GLenum pname, GLint* params', },
489 { 'return_type': 'void',
490 'names': ['glGetAttachedShaders'],
492 'GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders', },
493 { 'return_type': 'GLint',
494 'names': ['glGetAttribLocation'],
495 'arguments': 'GLuint program, const char* name', },
496 { 'return_type': 'void',
497 'names': ['glGetBooleanv'],
498 'arguments': 'GLenum pname, GLboolean* params', },
499 { 'return_type': 'void',
500 'names': ['glGetBufferParameteriv'],
501 'arguments': 'GLenum target, GLenum pname, GLint* params', },
502 { 'return_type': 'GLenum',
503 'names': ['glGetError'],
506 GL_SERVICE_LOG("GL_RESULT: " << GLEnums::GetStringError(result));
508 { 'return_type': 'void',
509 'names': ['glGetFenceivNV'],
510 'arguments': 'GLuint fence, GLenum pname, GLint* params', },
511 { 'return_type': 'void',
512 'names': ['glGetFloatv'],
513 'arguments': 'GLenum pname, GLfloat* params', },
514 { 'return_type': 'GLint',
515 'versions': [{ 'name': 'glGetFragDataLocation' }],
516 'arguments': 'GLuint program, const char* name', },
517 { 'return_type': 'void',
518 'names': ['glGetFramebufferAttachmentParameterivEXT',
519 'glGetFramebufferAttachmentParameteriv'],
520 'arguments': 'GLenum target, '
521 'GLenum attachment, GLenum pname, GLint* params', },
522 { 'return_type': 'GLenum',
523 'names': ['glGetGraphicsResetStatusARB',
524 'glGetGraphicsResetStatusKHR',
525 'glGetGraphicsResetStatusEXT',
526 'glGetGraphicsResetStatus'],
527 'arguments': 'void', },
528 { 'return_type': 'void',
529 'versions': [{ 'name': 'glGetInteger64i_v' }],
530 'arguments': 'GLenum target, GLuint index, GLint64* data', },
531 { 'return_type': 'void',
532 'names': ['glGetInteger64v'],
533 'arguments': 'GLenum pname, GLint64* params', },
534 { 'return_type': 'void',
535 'versions': [{ 'name': 'glGetIntegeri_v' }],
536 'arguments': 'GLenum target, GLuint index, GLint* data', },
537 { 'return_type': 'void',
538 'names': ['glGetIntegerv'],
539 'arguments': 'GLenum pname, GLint* params', },
540 { 'return_type': 'void',
541 'versions': [{ 'name': 'glGetInternalformativ' }],
542 'arguments': 'GLenum target, GLenum internalformat, GLenum pname, '
543 'GLsizei bufSize, GLint* params', },
544 { 'return_type': 'void',
545 'known_as': 'glGetProgramBinary',
546 'versions': [{ 'name': 'glGetProgramBinaryOES' },
547 { 'name': 'glGetProgramBinary',
548 'extensions': ['GL_ARB_get_program_binary'] }],
549 'arguments': 'GLuint program, GLsizei bufSize, GLsizei* length, '
550 'GLenum* binaryFormat, GLvoid* binary' },
551 { 'return_type': 'void',
552 'names': ['glGetProgramInfoLog'],
554 'GLuint program, GLsizei bufsize, GLsizei* length, char* infolog', },
555 { 'return_type': 'void',
556 'names': ['glGetProgramiv'],
557 'arguments': 'GLuint program, GLenum pname, GLint* params', },
558 { 'return_type': 'GLint',
559 'names': ['glGetProgramResourceLocation'],
560 'arguments': 'GLuint program, GLenum programInterface, const char* name', },
561 { 'return_type': 'void',
562 'versions': [{ 'name': 'glGetQueryiv' },
563 { 'name': 'glGetQueryivARB' },
564 { 'name': 'glGetQueryivEXT',
565 'extensions': ['GL_EXT_occlusion_query_boolean'] }],
566 'arguments': 'GLenum target, GLenum pname, GLint* params', },
567 { 'return_type': 'void',
568 'versions': [{ 'name': 'glGetQueryObjecti64v',
569 'extensions': ['GL_ARB_timer_query'] },
570 { 'name': 'glGetQueryObjecti64vEXT' }],
571 'arguments': 'GLuint id, GLenum pname, GLint64* params', },
572 { 'return_type': 'void',
573 'versions': [{ 'name': 'glGetQueryObjectiv' },
574 { 'name': 'glGetQueryObjectivARB' },
575 { 'name': 'glGetQueryObjectivEXT' }],
576 'arguments': 'GLuint id, GLenum pname, GLint* params', },
577 { 'return_type': 'void',
578 'versions': [{ 'name': 'glGetQueryObjectui64v',
579 'extensions': ['GL_ARB_timer_query'] },
580 { 'name': 'glGetQueryObjectui64vEXT' }],
581 'arguments': 'GLuint id, GLenum pname, GLuint64* params', },
582 { 'return_type': 'void',
583 'versions': [{ 'name': 'glGetQueryObjectuiv' },
584 { 'name': 'glGetQueryObjectuivARB' },
585 { 'name': 'glGetQueryObjectuivEXT',
586 'extensions': ['GL_EXT_occlusion_query_boolean'] }],
587 'arguments': 'GLuint id, GLenum pname, GLuint* params', },
588 { 'return_type': 'void',
589 'names': ['glGetRenderbufferParameterivEXT', 'glGetRenderbufferParameteriv'],
590 'arguments': 'GLenum target, GLenum pname, GLint* params', },
591 { 'return_type': 'void',
592 'versions': [{ 'name': 'glGetSamplerParameterfv' }],
593 'arguments': 'GLuint sampler, GLenum pname, GLfloat* params', },
594 { 'return_type': 'void',
595 'versions': [{ 'name': 'glGetSamplerParameteriv' }],
596 'arguments': 'GLuint sampler, GLenum pname, GLint* params', },
597 { 'return_type': 'void',
598 'names': ['glGetShaderInfoLog'],
600 'GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog', },
601 { 'return_type': 'void',
602 'names': ['glGetShaderiv'],
603 'arguments': 'GLuint shader, GLenum pname, GLint* params', },
604 { 'return_type': 'void',
605 'names': ['glGetShaderPrecisionFormat'],
606 'arguments': 'GLenum shadertype, GLenum precisiontype, '
607 'GLint* range, GLint* precision', },
608 { 'return_type': 'void',
609 'names': ['glGetShaderSource'],
611 'GLuint shader, GLsizei bufsize, GLsizei* length, char* source', },
612 { 'return_type': 'const GLubyte*',
613 'names': ['glGetString'],
614 'arguments': 'GLenum name', },
615 { 'return_type': 'const GLubyte*',
616 # This is needed for bootstrapping on the desktop GL core profile.
617 # It won't be called unless the expected GL version is used.
618 'versions': [{ 'name': 'glGetStringi',
619 'extensions': ['GL_CHROMIUM_glgetstringi_hack'] }],
620 'arguments': 'GLenum name, GLuint index', },
621 { 'return_type': 'void',
622 'versions': [{ 'name': 'glGetSynciv',
623 'extensions': ['GL_ARB_sync'] }],
625 'GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length,'
627 { 'return_type': 'void',
628 'names': ['glGetTexLevelParameterfv'],
629 'arguments': 'GLenum target, GLint level, GLenum pname, GLfloat* params', },
630 { 'return_type': 'void',
631 'names': ['glGetTexLevelParameteriv'],
632 'arguments': 'GLenum target, GLint level, GLenum pname, GLint* params', },
633 { 'return_type': 'void',
634 'names': ['glGetTexParameterfv'],
635 'arguments': 'GLenum target, GLenum pname, GLfloat* params', },
636 { 'return_type': 'void',
637 'names': ['glGetTexParameteriv'],
638 'arguments': 'GLenum target, GLenum pname, GLint* params', },
639 { 'return_type': 'void',
640 'versions': [{ 'name': 'glGetTransformFeedbackVarying' }],
641 'arguments': 'GLuint program, GLuint index, GLsizei bufSize, '
642 'GLsizei* length, GLsizei* size, GLenum* type, char* name', },
643 { 'return_type': 'void',
644 'names': ['glGetTranslatedShaderSourceANGLE'],
646 'GLuint shader, GLsizei bufsize, GLsizei* length, char* source', },
647 { 'return_type': 'GLuint',
648 'versions': [{ 'name': 'glGetUniformBlockIndex' }],
649 'arguments': 'GLuint program, const char* uniformBlockName', },
650 { 'return_type': 'void',
651 'names': ['glGetUniformfv'],
652 'arguments': 'GLuint program, GLint location, GLfloat* params', },
653 { 'return_type': 'void',
654 'versions': [{ 'name': 'glGetUniformIndices' }],
655 'arguments': 'GLuint program, GLsizei uniformCount, '
656 'const char* const* uniformNames, GLuint* uniformIndices', },
657 { 'return_type': 'void',
658 'names': ['glGetUniformiv'],
659 'arguments': 'GLuint program, GLint location, GLint* params', },
660 { 'return_type': 'GLint',
661 'names': ['glGetUniformLocation'],
662 'arguments': 'GLuint program, const char* name', },
663 { 'return_type': 'void',
664 'names': ['glGetVertexAttribfv'],
665 'arguments': 'GLuint index, GLenum pname, GLfloat* params', },
666 { 'return_type': 'void',
667 'names': ['glGetVertexAttribiv'],
668 'arguments': 'GLuint index, GLenum pname, GLint* params', },
669 { 'return_type': 'void',
670 'names': ['glGetVertexAttribPointerv'],
671 'arguments': 'GLuint index, GLenum pname, void** pointer', },
672 { 'return_type': 'void',
674 'arguments': 'GLenum target, GLenum mode', },
675 { 'return_type': 'void',
676 'names': ['glInsertEventMarkerEXT'],
677 'arguments': 'GLsizei length, const char* marker', },
678 { 'return_type': 'void',
679 'versions': [{ 'name': 'glInvalidateFramebuffer' }],
680 'arguments': 'GLenum target, GLsizei numAttachments, '
681 'const GLenum* attachments' },
682 { 'return_type': 'void',
683 'versions': [{ 'name': 'glInvalidateSubFramebuffer' }],
685 'GLenum target, GLsizei numAttachments, const GLenum* attachments, '
686 'GLint x, GLint y, GLint width, GLint height', },
687 { 'return_type': 'GLboolean',
688 'names': ['glIsBuffer'],
689 'arguments': 'GLuint buffer', },
690 { 'return_type': 'GLboolean',
691 'names': ['glIsEnabled'],
692 'arguments': 'GLenum cap', },
693 { 'return_type': 'GLboolean',
694 'known_as': 'glIsFenceAPPLE',
695 'versions': [{ 'name': 'glIsFenceAPPLE',
696 'extensions': ['GL_APPLE_fence'] }],
697 'arguments': 'GLuint fence', },
698 { 'return_type': 'GLboolean',
699 'names': ['glIsFenceNV'],
700 'arguments': 'GLuint fence', },
701 { 'return_type': 'GLboolean',
702 'names': ['glIsFramebufferEXT', 'glIsFramebuffer'],
703 'arguments': 'GLuint framebuffer', },
704 { 'return_type': 'GLboolean',
705 'names': ['glIsProgram'],
706 'arguments': 'GLuint program', },
707 { 'return_type': 'GLboolean',
708 'versions': [{ 'name': 'glIsQuery' },
709 { 'name': 'glIsQueryARB' },
710 { 'name': 'glIsQueryEXT',
711 'extensions': ['GL_EXT_occlusion_query_boolean'] }],
712 'arguments': 'GLuint query', },
713 { 'return_type': 'GLboolean',
714 'names': ['glIsRenderbufferEXT', 'glIsRenderbuffer'],
715 'arguments': 'GLuint renderbuffer', },
716 { 'return_type': 'GLboolean',
717 'versions': [{ 'name': 'glIsSampler' }],
718 'arguments': 'GLuint sampler', },
719 { 'return_type': 'GLboolean',
720 'names': ['glIsShader'],
721 'arguments': 'GLuint shader', },
722 { 'return_type': 'GLboolean',
723 'versions': [{ 'name': 'glIsSync',
724 'extensions': ['GL_ARB_sync'] }],
725 'arguments': 'GLsync sync', },
726 { 'return_type': 'GLboolean',
727 'names': ['glIsTexture'],
728 'arguments': 'GLuint texture', },
729 { 'return_type': 'GLboolean',
730 'versions': [{ 'name': 'glIsTransformFeedback' }],
731 'arguments': 'GLuint id', },
732 { 'return_type': 'GLboolean',
733 'known_as': 'glIsVertexArrayOES',
734 'versions': [{ 'name': 'glIsVertexArray',
735 'extensions': ['GL_ARB_vertex_array_object'], },
736 { 'name': 'glIsVertexArrayOES' },
737 { 'name': 'glIsVertexArrayAPPLE',
738 'extensions': ['GL_APPLE_vertex_array_object'] }],
739 'arguments': 'GLuint array' },
740 { 'return_type': 'void',
741 'names': ['glLineWidth'],
742 'arguments': 'GLfloat width', },
743 { 'return_type': 'void',
744 'names': ['glLinkProgram'],
745 'arguments': 'GLuint program', },
746 { 'return_type': 'void*',
747 'known_as': 'glMapBuffer',
748 'names': ['glMapBufferOES', 'glMapBuffer'],
749 'arguments': 'GLenum target, GLenum access', },
750 { 'return_type': 'void*',
751 'known_as': 'glMapBufferRange',
752 'versions': [{ 'name': 'glMapBufferRange',
753 'extensions': ['GL_ARB_map_buffer_range'] },
754 { 'name': 'glMapBufferRangeEXT',
755 'extensions': ['GL_EXT_map_buffer_range'] }],
757 'GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access', },
758 { 'return_type': 'void',
759 'known_as': 'glMatrixLoadfEXT',
760 'versions': [{ 'name': 'glMatrixLoadfEXT',
761 'extensions': ['GL_EXT_direct_state_access',
762 'GL_NV_path_rendering'] }],
763 'arguments': 'GLenum matrixMode, const GLfloat* m' },
764 { 'return_type': 'void',
765 'known_as': 'glMatrixLoadIdentityEXT',
766 'versions': [{ 'name': 'glMatrixLoadIdentityEXT',
767 'extensions': ['GL_EXT_direct_state_access',
768 'GL_NV_path_rendering'] },],
769 'arguments': 'GLenum matrixMode' },
770 { 'return_type': 'void',
771 'versions': [{ 'name': 'glPauseTransformFeedback' }],
772 'arguments': 'void', },
773 { 'return_type': 'void',
774 'names': ['glPixelStorei'],
775 'arguments': 'GLenum pname, GLint param', },
776 { 'return_type': 'void',
777 'names': ['glPointParameteri'],
778 'arguments': 'GLenum pname, GLint param', },
779 { 'return_type': 'void',
780 'names': ['glPolygonOffset'],
781 'arguments': 'GLfloat factor, GLfloat units', },
782 { 'return_type': 'void',
783 'names': ['glPopGroupMarkerEXT'],
784 'arguments': 'void', },
785 { 'return_type': 'void',
786 'known_as': 'glProgramBinary',
787 'versions': [{ 'name': 'glProgramBinaryOES' },
788 { 'name': 'glProgramBinary',
789 'extensions': ['GL_ARB_get_program_binary'] }],
790 'arguments': 'GLuint program, GLenum binaryFormat, '
791 'const GLvoid* binary, GLsizei length' },
792 { 'return_type': 'void',
793 'versions': [{ 'name': 'glProgramParameteri',
794 'extensions': ['GL_ARB_get_program_binary'] }],
795 'arguments': 'GLuint program, GLenum pname, GLint value' },
796 { 'return_type': 'void',
797 'names': ['glPushGroupMarkerEXT'],
798 'arguments': 'GLsizei length, const char* marker', },
799 { 'return_type': 'void',
800 'versions': [{ 'name': 'glQueryCounter',
801 'extensions': ['GL_ARB_timer_query'] },
802 { 'name': 'glQueryCounterEXT' }],
803 'arguments': 'GLuint id, GLenum target', },
804 { 'return_type': 'void',
805 'names': ['glReadBuffer'],
806 'arguments': 'GLenum src', },
807 { 'return_type': 'void',
808 'names': ['glReadPixels'],
810 'GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, '
811 'GLenum type, void* pixels', },
812 { 'return_type': 'void',
813 'names': ['glReleaseShaderCompiler'],
814 'arguments': 'void', },
815 { 'return_type': 'void',
816 'names': ['glRenderbufferStorageEXT', 'glRenderbufferStorage'],
818 'GLenum target, GLenum internalformat, GLsizei width, GLsizei height', },
819 { 'return_type': 'void',
820 'names': ['glRenderbufferStorageMultisample'],
821 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, '
822 'GLsizei width, GLsizei height', },
823 { 'return_type': 'void',
824 'names': ['glRenderbufferStorageMultisampleANGLE'],
825 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, '
826 'GLsizei width, GLsizei height', },
827 { 'return_type': 'void',
828 'names': ['glRenderbufferStorageMultisampleEXT'],
829 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, '
830 'GLsizei width, GLsizei height', },
831 { 'return_type': 'void',
832 'names': ['glRenderbufferStorageMultisampleIMG'],
833 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, '
834 'GLsizei width, GLsizei height', },
835 { 'return_type': 'void',
836 'versions': [{ 'name': 'glResumeTransformFeedback' }],
837 'arguments': 'void', },
838 { 'return_type': 'void',
839 'names': ['glSampleCoverage'],
840 'arguments': 'GLclampf value, GLboolean invert', },
841 { 'return_type': 'void',
842 'versions': [{ 'name': 'glSamplerParameterf' }],
843 'arguments': 'GLuint sampler, GLenum pname, GLfloat param', },
844 { 'return_type': 'void',
845 'versions': [{ 'name': 'glSamplerParameterfv' }],
846 'arguments': 'GLuint sampler, GLenum pname, const GLfloat* params', },
847 { 'return_type': 'void',
848 'versions': [{ 'name': 'glSamplerParameteri' }],
849 'arguments': 'GLuint sampler, GLenum pname, GLint param', },
850 { 'return_type': 'void',
851 'versions': [{ 'name': 'glSamplerParameteriv' }],
852 'arguments': 'GLuint sampler, GLenum pname, const GLint* params', },
853 { 'return_type': 'void',
854 'names': ['glScissor'],
855 'arguments': 'GLint x, GLint y, GLsizei width, GLsizei height', },
856 { 'return_type': 'void',
857 'known_as': 'glSetFenceAPPLE',
858 'versions': [{ 'name': 'glSetFenceAPPLE',
859 'extensions': ['GL_APPLE_fence'] }],
860 'arguments': 'GLuint fence', },
861 { 'return_type': 'void',
862 'names': ['glSetFenceNV'],
863 'arguments': 'GLuint fence, GLenum condition', },
864 { 'return_type': 'void',
865 'names': ['glShaderBinary'],
866 'arguments': 'GLsizei n, const GLuint* shaders, GLenum binaryformat, '
867 'const void* binary, GLsizei length', },
868 { 'return_type': 'void',
869 'names': ['glShaderSource'],
870 'arguments': 'GLuint shader, GLsizei count, const char* const* str, '
871 'const GLint* length',
873 GL_SERVICE_LOG_CODE_BLOCK({
874 for (GLsizei ii = 0; ii < count; ++ii) {
876 if (length && length[ii] >= 0) {
877 std::string source(str[ii], length[ii]);
878 GL_SERVICE_LOG(" " << ii << ": ---\\n" << source << "\\n---");
880 GL_SERVICE_LOG(" " << ii << ": ---\\n" << str[ii] << "\\n---");
883 GL_SERVICE_LOG(" " << ii << ": NULL");
888 { 'return_type': 'void',
889 'names': ['glStencilFunc'],
890 'arguments': 'GLenum func, GLint ref, GLuint mask', },
891 { 'return_type': 'void',
892 'names': ['glStencilFuncSeparate'],
893 'arguments': 'GLenum face, GLenum func, GLint ref, GLuint mask', },
894 { 'return_type': 'void',
895 'names': ['glStencilMask'],
896 'arguments': 'GLuint mask', },
897 { 'return_type': 'void',
898 'names': ['glStencilMaskSeparate'],
899 'arguments': 'GLenum face, GLuint mask', },
900 { 'return_type': 'void',
901 'names': ['glStencilOp'],
902 'arguments': 'GLenum fail, GLenum zfail, GLenum zpass', },
903 { 'return_type': 'void',
904 'names': ['glStencilOpSeparate'],
905 'arguments': 'GLenum face, GLenum fail, GLenum zfail, GLenum zpass', },
906 { 'return_type': 'GLboolean',
907 'known_as': 'glTestFenceAPPLE',
908 'versions': [{ 'name': 'glTestFenceAPPLE',
909 'extensions': ['GL_APPLE_fence'] }],
910 'arguments': 'GLuint fence', },
911 { 'return_type': 'GLboolean',
912 'names': ['glTestFenceNV'],
913 'arguments': 'GLuint fence', },
914 { 'return_type': 'void',
915 'names': ['glTexImage2D'],
917 'GLenum target, GLint level, GLint internalformat, GLsizei width, '
918 'GLsizei height, GLint border, GLenum format, GLenum type, '
919 'const void* pixels', },
920 { 'return_type': 'void',
921 'versions': [{ 'name': 'glTexImage3D' }],
923 'GLenum target, GLint level, GLint internalformat, GLsizei width, '
924 'GLsizei height, GLsizei depth, GLint border, GLenum format, '
925 'GLenum type, const void* pixels', },
926 { 'return_type': 'void',
927 'names': ['glTexParameterf'],
928 'arguments': 'GLenum target, GLenum pname, GLfloat param', },
929 { 'return_type': 'void',
930 'names': ['glTexParameterfv'],
931 'arguments': 'GLenum target, GLenum pname, const GLfloat* params', },
932 { 'return_type': 'void',
933 'names': ['glTexParameteri'],
934 'arguments': 'GLenum target, GLenum pname, GLint param', },
935 { 'return_type': 'void',
936 'names': ['glTexParameteriv'],
937 'arguments': 'GLenum target, GLenum pname, const GLint* params', },
938 { 'return_type': 'void',
939 'known_as': 'glTexStorage2DEXT',
940 'versions': [{ 'name': 'glTexStorage2D',
941 'extensions': ['GL_ARB_texture_storage'] },
942 { 'name': 'glTexStorage2DEXT',
943 'extensions': ['GL_EXT_texture_storage'] }],
944 'arguments': 'GLenum target, GLsizei levels, GLenum internalformat, '
945 'GLsizei width, GLsizei height', },
946 { 'return_type': 'void',
947 'versions': [{ 'name': 'glTexStorage3D' }],
948 'arguments': 'GLenum target, GLsizei levels, GLenum internalformat, '
949 'GLsizei width, GLsizei height, GLsizei depth', },
950 { 'return_type': 'void',
951 'names': ['glTexSubImage2D'],
953 'GLenum target, GLint level, GLint xoffset, GLint yoffset, '
954 'GLsizei width, GLsizei height, GLenum format, GLenum type, '
955 'const void* pixels', },
956 # TODO(zmo): wait for MOCK_METHOD11.
957 # { 'return_type': 'void',
958 # 'versions': [{ 'name': 'glTexSubImage3D' }],
960 # 'GLenum target, GLint level, GLint xoffset, GLint yoffset, '
961 # 'GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, '
962 # 'GLenum format, GLenum type, const void* pixels', },
963 { 'return_type': 'void',
964 'versions': [{ 'name': 'glTransformFeedbackVaryings' }],
965 'arguments': 'GLuint program, GLsizei count, const char* const* varyings, '
966 'GLenum bufferMode', },
967 { 'return_type': 'void',
968 'names': ['glUniform1f'],
969 'arguments': 'GLint location, GLfloat x', },
970 { 'return_type': 'void',
971 'names': ['glUniform1fv'],
972 'arguments': 'GLint location, GLsizei count, const GLfloat* v', },
973 { 'return_type': 'void',
974 'names': ['glUniform1i'],
975 'arguments': 'GLint location, GLint x', },
976 { 'return_type': 'void',
977 'names': ['glUniform1iv'],
978 'arguments': 'GLint location, GLsizei count, const GLint* v', },
979 { 'return_type': 'void',
980 'versions': [{ 'name': 'glUniform1ui' }],
981 'arguments': 'GLint location, GLuint v0', },
982 { 'return_type': 'void',
983 'versions': [{ 'name': 'glUniform1uiv' }],
984 'arguments': 'GLint location, GLsizei count, const GLuint* v', },
985 { 'return_type': 'void',
986 'names': ['glUniform2f'],
987 'arguments': 'GLint location, GLfloat x, GLfloat y', },
988 { 'return_type': 'void',
989 'names': ['glUniform2fv'],
990 'arguments': 'GLint location, GLsizei count, const GLfloat* v', },
991 { 'return_type': 'void',
992 'names': ['glUniform2i'],
993 'arguments': 'GLint location, GLint x, GLint y', },
994 { 'return_type': 'void',
995 'names': ['glUniform2iv'],
996 'arguments': 'GLint location, GLsizei count, const GLint* v', },
997 { 'return_type': 'void',
998 'versions': [{ 'name': 'glUniform2ui' }],
999 'arguments': 'GLint location, GLuint v0, GLuint v1', },
1000 { 'return_type': 'void',
1001 'versions': [{ 'name': 'glUniform2uiv' }],
1002 'arguments': 'GLint location, GLsizei count, const GLuint* v', },
1003 { 'return_type': 'void',
1004 'names': ['glUniform3f'],
1005 'arguments': 'GLint location, GLfloat x, GLfloat y, GLfloat z', },
1006 { 'return_type': 'void',
1007 'names': ['glUniform3fv'],
1008 'arguments': 'GLint location, GLsizei count, const GLfloat* v', },
1009 { 'return_type': 'void',
1010 'names': ['glUniform3i'],
1011 'arguments': 'GLint location, GLint x, GLint y, GLint z', },
1012 { 'return_type': 'void',
1013 'names': ['glUniform3iv'],
1014 'arguments': 'GLint location, GLsizei count, const GLint* v', },
1015 { 'return_type': 'void',
1016 'versions': [{ 'name': 'glUniform3ui' }],
1017 'arguments': 'GLint location, GLuint v0, GLuint v1, GLuint v2', },
1018 { 'return_type': 'void',
1019 'versions': [{ 'name': 'glUniform3uiv' }],
1020 'arguments': 'GLint location, GLsizei count, const GLuint* v', },
1021 { 'return_type': 'void',
1022 'names': ['glUniform4f'],
1023 'arguments': 'GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w', },
1024 { 'return_type': 'void',
1025 'names': ['glUniform4fv'],
1026 'arguments': 'GLint location, GLsizei count, const GLfloat* v', },
1027 { 'return_type': 'void',
1028 'names': ['glUniform4i'],
1029 'arguments': 'GLint location, GLint x, GLint y, GLint z, GLint w', },
1030 { 'return_type': 'void',
1031 'names': ['glUniform4iv'],
1032 'arguments': 'GLint location, GLsizei count, const GLint* v', },
1033 { 'return_type': 'void',
1034 'versions': [{ 'name': 'glUniform4ui' }],
1035 'arguments': 'GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3', },
1036 { 'return_type': 'void',
1037 'versions': [{ 'name': 'glUniform4uiv' }],
1038 'arguments': 'GLint location, GLsizei count, const GLuint* v', },
1039 { 'return_type': 'void',
1040 'versions': [{ 'name': 'glUniformBlockBinding' }],
1041 'arguments': 'GLuint program, GLuint uniformBlockIndex, '
1042 'GLuint uniformBlockBinding', },
1043 { 'return_type': 'void',
1044 'names': ['glUniformMatrix2fv'],
1045 'arguments': 'GLint location, GLsizei count, '
1046 'GLboolean transpose, const GLfloat* value', },
1047 { 'return_type': 'void',
1048 'versions': [{ 'name': 'glUniformMatrix2x3fv' }],
1049 'arguments': 'GLint location, GLsizei count, '
1050 'GLboolean transpose, const GLfloat* value', },
1051 { 'return_type': 'void',
1052 'versions': [{ 'name': 'glUniformMatrix2x4fv' }],
1053 'arguments': 'GLint location, GLsizei count, '
1054 'GLboolean transpose, const GLfloat* value', },
1055 { 'return_type': 'void',
1056 'names': ['glUniformMatrix3fv'],
1057 'arguments': 'GLint location, GLsizei count, '
1058 'GLboolean transpose, const GLfloat* value', },
1059 { 'return_type': 'void',
1060 'versions': [{ 'name': 'glUniformMatrix3x2fv' }],
1061 'arguments': 'GLint location, GLsizei count, '
1062 'GLboolean transpose, const GLfloat* value', },
1063 { 'return_type': 'void',
1064 'versions': [{ 'name': 'glUniformMatrix3x4fv' }],
1065 'arguments': 'GLint location, GLsizei count, '
1066 'GLboolean transpose, const GLfloat* value', },
1067 { 'return_type': 'void',
1068 'names': ['glUniformMatrix4fv'],
1069 'arguments': 'GLint location, GLsizei count, '
1070 'GLboolean transpose, const GLfloat* value', },
1071 { 'return_type': 'void',
1072 'versions': [{ 'name': 'glUniformMatrix4x2fv' }],
1073 'arguments': 'GLint location, GLsizei count, '
1074 'GLboolean transpose, const GLfloat* value', },
1075 { 'return_type': 'void',
1076 'versions': [{ 'name': 'glUniformMatrix4x3fv' }],
1077 'arguments': 'GLint location, GLsizei count, '
1078 'GLboolean transpose, const GLfloat* value', },
1079 { 'return_type': 'GLboolean',
1080 'known_as': 'glUnmapBuffer',
1081 'names': ['glUnmapBufferOES', 'glUnmapBuffer'],
1082 'arguments': 'GLenum target', },
1083 { 'return_type': 'void',
1084 'names': ['glUseProgram'],
1085 'arguments': 'GLuint program', },
1086 { 'return_type': 'void',
1087 'names': ['glValidateProgram'],
1088 'arguments': 'GLuint program', },
1089 { 'return_type': 'void',
1090 'names': ['glVertexAttrib1f'],
1091 'arguments': 'GLuint indx, GLfloat x', },
1092 { 'return_type': 'void',
1093 'names': ['glVertexAttrib1fv'],
1094 'arguments': 'GLuint indx, const GLfloat* values', },
1095 { 'return_type': 'void',
1096 'names': ['glVertexAttrib2f'],
1097 'arguments': 'GLuint indx, GLfloat x, GLfloat y', },
1098 { 'return_type': 'void',
1099 'names': ['glVertexAttrib2fv'],
1100 'arguments': 'GLuint indx, const GLfloat* values', },
1101 { 'return_type': 'void',
1102 'names': ['glVertexAttrib3f'],
1103 'arguments': 'GLuint indx, GLfloat x, GLfloat y, GLfloat z', },
1104 { 'return_type': 'void',
1105 'names': ['glVertexAttrib3fv'],
1106 'arguments': 'GLuint indx, const GLfloat* values', },
1107 { 'return_type': 'void',
1108 'names': ['glVertexAttrib4f'],
1109 'arguments': 'GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w', },
1110 { 'return_type': 'void',
1111 'names': ['glVertexAttrib4fv'],
1112 'arguments': 'GLuint indx, const GLfloat* values', },
1113 { 'return_type': 'void',
1114 'known_as': 'glVertexAttribDivisorANGLE',
1115 'names': ['glVertexAttribDivisorARB', 'glVertexAttribDivisorANGLE',
1116 'glVertexAttribDivisor'],
1118 'GLuint index, GLuint divisor', },
1119 { 'return_type': 'void',
1120 'versions': [{ 'name': 'glVertexAttribI4i' }],
1121 'arguments': 'GLuint indx, GLint x, GLint y, GLint z, GLint w', },
1122 { 'return_type': 'void',
1123 'versions': [{ 'name': 'glVertexAttribI4iv' }],
1124 'arguments': 'GLuint indx, const GLint* values', },
1125 { 'return_type': 'void',
1126 'versions': [{ 'name': 'glVertexAttribI4ui' }],
1127 'arguments': 'GLuint indx, GLuint x, GLuint y, GLuint z, GLuint w', },
1128 { 'return_type': 'void',
1129 'versions': [{ 'name': 'glVertexAttribI4uiv' }],
1130 'arguments': 'GLuint indx, const GLuint* values', },
1131 { 'return_type': 'void',
1132 'versions': [{ 'name': 'glVertexAttribIPointer' }],
1133 'arguments': 'GLuint indx, GLint size, GLenum type, GLsizei stride, '
1134 'const void* ptr', },
1135 { 'return_type': 'void',
1136 'names': ['glVertexAttribPointer'],
1137 'arguments': 'GLuint indx, GLint size, GLenum type, GLboolean normalized, '
1138 'GLsizei stride, const void* ptr', },
1139 { 'return_type': 'void',
1140 'names': ['glViewport'],
1141 'arguments': 'GLint x, GLint y, GLsizei width, GLsizei height', },
1142 { 'return_type': 'GLenum',
1143 'versions': [{ 'name': 'glWaitSync',
1144 'extensions': ['GL_ARB_sync'] }],
1146 'GLsync sync, GLbitfield flags, GLuint64 timeout', },
1149 OSMESA_FUNCTIONS
= [
1150 { 'return_type': 'void',
1151 'names': ['OSMesaColorClamp'],
1152 'arguments': 'GLboolean enable', },
1153 { 'return_type': 'OSMesaContext',
1154 'names': ['OSMesaCreateContext'],
1155 'arguments': 'GLenum format, OSMesaContext sharelist', },
1156 { 'return_type': 'OSMesaContext',
1157 'names': ['OSMesaCreateContextExt'],
1159 'GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, '
1160 'OSMesaContext sharelist', },
1161 { 'return_type': 'void',
1162 'names': ['OSMesaDestroyContext'],
1163 'arguments': 'OSMesaContext ctx', },
1164 { 'return_type': 'GLboolean',
1165 'names': ['OSMesaGetColorBuffer'],
1166 'arguments': 'OSMesaContext c, GLint* width, GLint* height, GLint* format, '
1168 { 'return_type': 'OSMesaContext',
1169 'names': ['OSMesaGetCurrentContext'],
1170 'arguments': 'void', },
1171 { 'return_type': 'GLboolean',
1172 'names': ['OSMesaGetDepthBuffer'],
1174 'OSMesaContext c, GLint* width, GLint* height, GLint* bytesPerValue, '
1176 { 'return_type': 'void',
1177 'names': ['OSMesaGetIntegerv'],
1178 'arguments': 'GLint pname, GLint* value', },
1179 { 'return_type': 'OSMESAproc',
1180 'names': ['OSMesaGetProcAddress'],
1181 'arguments': 'const char* funcName', },
1182 { 'return_type': 'GLboolean',
1183 'names': ['OSMesaMakeCurrent'],
1184 'arguments': 'OSMesaContext ctx, void* buffer, GLenum type, GLsizei width, '
1185 'GLsizei height', },
1186 { 'return_type': 'void',
1187 'names': ['OSMesaPixelStore'],
1188 'arguments': 'GLint pname, GLint value', },
1192 { 'return_type': 'EGLBoolean',
1193 'names': ['eglBindAPI'],
1194 'arguments': 'EGLenum api', },
1195 { 'return_type': 'EGLBoolean',
1196 'names': ['eglBindTexImage'],
1197 'arguments': 'EGLDisplay dpy, EGLSurface surface, EGLint buffer', },
1198 { 'return_type': 'EGLBoolean',
1199 'names': ['eglChooseConfig'],
1200 'arguments': 'EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, '
1201 'EGLint config_size, EGLint* num_config', },
1202 { 'return_type': 'EGLint',
1203 'versions': [{ 'name': 'eglClientWaitSyncKHR',
1204 'extensions': ['EGL_KHR_fence_sync'] }],
1205 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, '
1206 'EGLTimeKHR timeout' },
1207 { 'return_type': 'EGLBoolean',
1208 'names': ['eglCopyBuffers'],
1210 'EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target', },
1211 { 'return_type': 'EGLContext',
1212 'names': ['eglCreateContext'],
1213 'arguments': 'EGLDisplay dpy, EGLConfig config, EGLContext share_context, '
1214 'const EGLint* attrib_list', },
1215 { 'return_type': 'EGLImageKHR',
1216 'versions': [{ 'name': 'eglCreateImageKHR',
1218 ['EGL_KHR_image_base', 'EGL_KHR_gl_texture_2D_image'] }],
1220 'EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, '
1221 'const EGLint* attrib_list' },
1222 { 'return_type': 'EGLSurface',
1223 'names': ['eglCreatePbufferFromClientBuffer'],
1225 'EGLDisplay dpy, EGLenum buftype, void* buffer, EGLConfig config, '
1226 'const EGLint* attrib_list', },
1227 { 'return_type': 'EGLSurface',
1228 'names': ['eglCreatePbufferSurface'],
1229 'arguments': 'EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list', },
1230 { 'return_type': 'EGLSurface',
1231 'names': ['eglCreatePixmapSurface'],
1232 'arguments': 'EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, '
1233 'const EGLint* attrib_list', },
1234 { 'return_type': 'EGLSyncKHR',
1235 'versions': [{ 'name': 'eglCreateSyncKHR',
1236 'extensions': ['EGL_KHR_fence_sync'] }],
1237 'arguments': 'EGLDisplay dpy, EGLenum type, const EGLint* attrib_list' },
1238 { 'return_type': 'EGLSurface',
1239 'names': ['eglCreateWindowSurface'],
1240 'arguments': 'EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, '
1241 'const EGLint* attrib_list', },
1242 { 'return_type': 'EGLBoolean',
1243 'names': ['eglDestroyContext'],
1244 'arguments': 'EGLDisplay dpy, EGLContext ctx', },
1245 { 'return_type': 'EGLBoolean',
1246 'versions': [{ 'name' : 'eglDestroyImageKHR',
1247 'extensions': ['EGL_KHR_image_base'] }],
1248 'arguments': 'EGLDisplay dpy, EGLImageKHR image' },
1249 { 'return_type': 'EGLBoolean',
1250 'names': ['eglDestroySurface'],
1251 'arguments': 'EGLDisplay dpy, EGLSurface surface', },
1252 { 'return_type': 'EGLBoolean',
1253 'versions': [{ 'name': 'eglDestroySyncKHR',
1254 'extensions': ['EGL_KHR_fence_sync'] }],
1255 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync' },
1256 { 'return_type': 'EGLBoolean',
1257 'names': ['eglGetConfigAttrib'],
1259 'EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value', },
1260 { 'return_type': 'EGLBoolean',
1261 'names': ['eglGetConfigs'],
1262 'arguments': 'EGLDisplay dpy, EGLConfig* configs, EGLint config_size, '
1263 'EGLint* num_config', },
1264 { 'return_type': 'EGLContext',
1265 'names': ['eglGetCurrentContext'],
1266 'arguments': 'void', },
1267 { 'return_type': 'EGLDisplay',
1268 'names': ['eglGetCurrentDisplay'],
1269 'arguments': 'void', },
1270 { 'return_type': 'EGLSurface',
1271 'names': ['eglGetCurrentSurface'],
1272 'arguments': 'EGLint readdraw', },
1273 { 'return_type': 'EGLDisplay',
1274 'names': ['eglGetDisplay'],
1275 'arguments': 'EGLNativeDisplayType display_id', },
1276 { 'return_type': 'EGLint',
1277 'names': ['eglGetError'],
1278 'arguments': 'void', },
1279 { 'return_type': 'EGLDisplay',
1280 'known_as': 'eglGetPlatformDisplayEXT',
1281 'versions': [{ 'name': 'eglGetPlatformDisplayEXT',
1282 'extensions': ['EGL_ANGLE_platform_angle'] }],
1283 'arguments': 'EGLenum platform, void* native_display, '
1284 'const EGLint* attrib_list', },
1285 { 'return_type': '__eglMustCastToProperFunctionPointerType',
1286 'names': ['eglGetProcAddress'],
1287 'arguments': 'const char* procname', },
1288 { 'return_type': 'EGLBoolean',
1289 'versions': [{ 'name': 'eglGetSyncAttribKHR',
1290 'extensions': ['EGL_KHR_fence_sync'] }],
1291 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, '
1293 { 'return_type': 'EGLBoolean',
1294 'names': ['eglGetSyncValuesCHROMIUM'],
1296 'EGLDisplay dpy, EGLSurface surface, '
1297 'EGLuint64CHROMIUM* ust, EGLuint64CHROMIUM* msc, '
1298 'EGLuint64CHROMIUM* sbc', },
1299 { 'return_type': 'EGLBoolean',
1300 'names': ['eglInitialize'],
1301 'arguments': 'EGLDisplay dpy, EGLint* major, EGLint* minor', },
1302 { 'return_type': 'EGLBoolean',
1303 'names': ['eglMakeCurrent'],
1305 'EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx', },
1306 { 'return_type': 'EGLBoolean',
1307 'names': ['eglPostSubBufferNV'],
1308 'arguments': 'EGLDisplay dpy, EGLSurface surface, '
1309 'EGLint x, EGLint y, EGLint width, EGLint height', },
1310 { 'return_type': 'EGLenum',
1311 'names': ['eglQueryAPI'],
1312 'arguments': 'void', },
1313 { 'return_type': 'EGLBoolean',
1314 'names': ['eglQueryContext'],
1316 'EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value', },
1317 { 'return_type': 'const char*',
1318 'names': ['eglQueryString'],
1319 'arguments': 'EGLDisplay dpy, EGLint name', },
1320 { 'return_type': 'EGLBoolean',
1321 'names': ['eglQuerySurface'],
1323 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value', },
1324 { 'return_type': 'EGLBoolean',
1325 'names': ['eglQuerySurfacePointerANGLE'],
1327 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value', },
1328 { 'return_type': 'EGLBoolean',
1329 'names': ['eglReleaseTexImage'],
1330 'arguments': 'EGLDisplay dpy, EGLSurface surface, EGLint buffer', },
1331 { 'return_type': 'EGLBoolean',
1332 'names': ['eglReleaseThread'],
1333 'arguments': 'void', },
1334 { 'return_type': 'EGLBoolean',
1335 'names': ['eglSurfaceAttrib'],
1337 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value', },
1338 { 'return_type': 'EGLBoolean',
1339 'names': ['eglSwapBuffers'],
1340 'arguments': 'EGLDisplay dpy, EGLSurface surface', },
1341 { 'return_type': 'EGLBoolean',
1342 'names': ['eglSwapInterval'],
1343 'arguments': 'EGLDisplay dpy, EGLint interval', },
1344 { 'return_type': 'EGLBoolean',
1345 'names': ['eglTerminate'],
1346 'arguments': 'EGLDisplay dpy', },
1347 { 'return_type': 'EGLBoolean',
1348 'names': ['eglWaitClient'],
1349 'arguments': 'void', },
1350 { 'return_type': 'EGLBoolean',
1351 'names': ['eglWaitGL'],
1352 'arguments': 'void', },
1353 { 'return_type': 'EGLBoolean',
1354 'names': ['eglWaitNative'],
1355 'arguments': 'EGLint engine', },
1356 { 'return_type': 'EGLint',
1357 'versions': [{ 'name': 'eglWaitSyncKHR',
1358 'extensions': ['EGL_KHR_wait_sync'] }],
1359 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync, EGLint flags' },
1363 { 'return_type': 'BOOL',
1364 'names': ['wglChoosePixelFormatARB'],
1366 'HDC dc, const int* int_attrib_list, const float* float_attrib_list, '
1367 'UINT max_formats, int* formats, UINT* num_formats', },
1368 { 'return_type': 'BOOL',
1369 'names': ['wglCopyContext'],
1370 'arguments': 'HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask', },
1371 { 'return_type': 'HGLRC',
1372 'names': ['wglCreateContext'],
1373 'arguments': 'HDC hdc', },
1374 { 'return_type': 'HGLRC',
1375 'names': ['wglCreateLayerContext'],
1376 'arguments': 'HDC hdc, int iLayerPlane', },
1377 { 'return_type': 'HPBUFFERARB',
1378 'names': ['wglCreatePbufferARB'],
1379 'arguments': 'HDC hDC, int iPixelFormat, int iWidth, int iHeight, '
1380 'const int* piAttribList', },
1381 { 'return_type': 'BOOL',
1382 'names': ['wglDeleteContext'],
1383 'arguments': 'HGLRC hglrc', },
1384 { 'return_type': 'BOOL',
1385 'names': ['wglDestroyPbufferARB'],
1386 'arguments': 'HPBUFFERARB hPbuffer', },
1387 { 'return_type': 'HGLRC',
1388 'names': ['wglGetCurrentContext'],
1390 { 'return_type': 'HDC',
1391 'names': ['wglGetCurrentDC'],
1393 { 'return_type': 'const char*',
1394 'names': ['wglGetExtensionsStringARB'],
1395 'arguments': 'HDC hDC', },
1396 { 'return_type': 'const char*',
1397 'names': ['wglGetExtensionsStringEXT'],
1399 { 'return_type': 'HDC',
1400 'names': ['wglGetPbufferDCARB'],
1401 'arguments': 'HPBUFFERARB hPbuffer', },
1402 { 'return_type': 'BOOL',
1403 'names': ['wglMakeCurrent'],
1404 'arguments': 'HDC hdc, HGLRC hglrc', },
1405 { 'return_type': 'BOOL',
1406 'names': ['wglQueryPbufferARB'],
1407 'arguments': 'HPBUFFERARB hPbuffer, int iAttribute, int* piValue', },
1408 { 'return_type': 'int',
1409 'names': ['wglReleasePbufferDCARB'],
1410 'arguments': 'HPBUFFERARB hPbuffer, HDC hDC', },
1411 { 'return_type': 'BOOL',
1412 'names': ['wglShareLists'],
1413 'arguments': 'HGLRC hglrc1, HGLRC hglrc2', },
1414 { 'return_type': 'BOOL',
1415 'names': ['wglSwapIntervalEXT'],
1416 'arguments': 'int interval', },
1417 { 'return_type': 'BOOL',
1418 'names': ['wglSwapLayerBuffers'],
1419 'arguments': 'HDC hdc, UINT fuPlanes', },
1423 { 'return_type': 'void',
1424 'names': ['glXBindTexImageEXT'],
1426 'Display* dpy, GLXDrawable drawable, int buffer, int* attribList', },
1427 { 'return_type': 'GLXFBConfig*',
1428 'names': ['glXChooseFBConfig'],
1430 'Display* dpy, int screen, const int* attribList, int* nitems', },
1431 { 'return_type': 'XVisualInfo*',
1432 'names': ['glXChooseVisual'],
1433 'arguments': 'Display* dpy, int screen, int* attribList', },
1434 { 'return_type': 'void',
1435 'names': ['glXCopyContext'],
1437 'Display* dpy, GLXContext src, GLXContext dst, unsigned long mask', },
1438 { 'return_type': 'void',
1439 'names': ['glXCopySubBufferMESA'],
1440 'arguments': 'Display* dpy, GLXDrawable drawable, '
1441 'int x, int y, int width, int height', },
1442 { 'return_type': 'GLXContext',
1443 'names': ['glXCreateContext'],
1445 'Display* dpy, XVisualInfo* vis, GLXContext shareList, int direct', },
1446 { 'return_type': 'GLXContext',
1447 'names': ['glXCreateContextAttribsARB'],
1449 'Display* dpy, GLXFBConfig config, GLXContext share_context, int direct, '
1450 'const int* attrib_list', },
1451 { 'return_type': 'GLXPixmap',
1452 'names': ['glXCreateGLXPixmap'],
1453 'arguments': 'Display* dpy, XVisualInfo* visual, Pixmap pixmap', },
1454 { 'return_type': 'GLXContext',
1455 'names': ['glXCreateNewContext'],
1456 'arguments': 'Display* dpy, GLXFBConfig config, int renderType, '
1457 'GLXContext shareList, int direct', },
1458 { 'return_type': 'GLXPbuffer',
1459 'names': ['glXCreatePbuffer'],
1460 'arguments': 'Display* dpy, GLXFBConfig config, const int* attribList', },
1461 { 'return_type': 'GLXPixmap',
1462 'names': ['glXCreatePixmap'],
1463 'arguments': 'Display* dpy, GLXFBConfig config, '
1464 'Pixmap pixmap, const int* attribList', },
1465 { 'return_type': 'GLXWindow',
1466 'names': ['glXCreateWindow'],
1468 'Display* dpy, GLXFBConfig config, Window win, const int* attribList', },
1469 { 'return_type': 'void',
1470 'names': ['glXDestroyContext'],
1471 'arguments': 'Display* dpy, GLXContext ctx', },
1472 { 'return_type': 'void',
1473 'names': ['glXDestroyGLXPixmap'],
1474 'arguments': 'Display* dpy, GLXPixmap pixmap', },
1475 { 'return_type': 'void',
1476 'names': ['glXDestroyPbuffer'],
1477 'arguments': 'Display* dpy, GLXPbuffer pbuf', },
1478 { 'return_type': 'void',
1479 'names': ['glXDestroyPixmap'],
1480 'arguments': 'Display* dpy, GLXPixmap pixmap', },
1481 { 'return_type': 'void',
1482 'names': ['glXDestroyWindow'],
1483 'arguments': 'Display* dpy, GLXWindow window', },
1484 { 'return_type': 'const char*',
1485 'names': ['glXGetClientString'],
1486 'arguments': 'Display* dpy, int name', },
1487 { 'return_type': 'int',
1488 'names': ['glXGetConfig'],
1489 'arguments': 'Display* dpy, XVisualInfo* visual, int attrib, int* value', },
1490 { 'return_type': 'GLXContext',
1491 'names': ['glXGetCurrentContext'],
1492 'arguments': 'void', },
1493 { 'return_type': 'Display*',
1494 'names': ['glXGetCurrentDisplay'],
1495 'arguments': 'void', },
1496 { 'return_type': 'GLXDrawable',
1497 'names': ['glXGetCurrentDrawable'],
1498 'arguments': 'void', },
1499 { 'return_type': 'GLXDrawable',
1500 'names': ['glXGetCurrentReadDrawable'],
1501 'arguments': 'void', },
1502 { 'return_type': 'int',
1503 'names': ['glXGetFBConfigAttrib'],
1504 'arguments': 'Display* dpy, GLXFBConfig config, int attribute, int* value', },
1505 { 'return_type': 'GLXFBConfig',
1506 'names': ['glXGetFBConfigFromVisualSGIX'],
1507 'arguments': 'Display* dpy, XVisualInfo* visualInfo', },
1508 { 'return_type': 'GLXFBConfig*',
1509 'names': ['glXGetFBConfigs'],
1510 'arguments': 'Display* dpy, int screen, int* nelements', },
1511 { 'return_type': 'bool',
1512 'names': ['glXGetMscRateOML'],
1514 'Display* dpy, GLXDrawable drawable, int32* numerator, '
1515 'int32* denominator' },
1516 { 'return_type': 'void',
1517 'names': ['glXGetSelectedEvent'],
1518 'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long* mask', },
1519 { 'return_type': 'bool',
1520 'names': ['glXGetSyncValuesOML'],
1522 'Display* dpy, GLXDrawable drawable, int64* ust, int64* msc, '
1524 { 'return_type': 'XVisualInfo*',
1525 'names': ['glXGetVisualFromFBConfig'],
1526 'arguments': 'Display* dpy, GLXFBConfig config', },
1527 { 'return_type': 'int',
1528 'names': ['glXIsDirect'],
1529 'arguments': 'Display* dpy, GLXContext ctx', },
1530 { 'return_type': 'int',
1531 'names': ['glXMakeContextCurrent'],
1533 'Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx', },
1534 { 'return_type': 'int',
1535 'names': ['glXMakeCurrent'],
1536 'arguments': 'Display* dpy, GLXDrawable drawable, GLXContext ctx', },
1537 { 'return_type': 'int',
1538 'names': ['glXQueryContext'],
1539 'arguments': 'Display* dpy, GLXContext ctx, int attribute, int* value', },
1540 { 'return_type': 'void',
1541 'names': ['glXQueryDrawable'],
1543 'Display* dpy, GLXDrawable draw, int attribute, unsigned int* value', },
1544 { 'return_type': 'int',
1545 'names': ['glXQueryExtension'],
1546 'arguments': 'Display* dpy, int* errorb, int* event', },
1547 { 'return_type': 'const char*',
1548 'names': ['glXQueryExtensionsString'],
1549 'arguments': 'Display* dpy, int screen', },
1550 { 'return_type': 'const char*',
1551 'names': ['glXQueryServerString'],
1552 'arguments': 'Display* dpy, int screen, int name', },
1553 { 'return_type': 'int',
1554 'names': ['glXQueryVersion'],
1555 'arguments': 'Display* dpy, int* maj, int* min', },
1556 { 'return_type': 'void',
1557 'names': ['glXReleaseTexImageEXT'],
1558 'arguments': 'Display* dpy, GLXDrawable drawable, int buffer', },
1559 { 'return_type': 'void',
1560 'names': ['glXSelectEvent'],
1561 'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long mask', },
1562 { 'return_type': 'void',
1563 'names': ['glXSwapBuffers'],
1564 'arguments': 'Display* dpy, GLXDrawable drawable', },
1565 { 'return_type': 'void',
1566 'names': ['glXSwapIntervalEXT'],
1567 'arguments': 'Display* dpy, GLXDrawable drawable, int interval', },
1568 { 'return_type': 'void',
1569 'names': ['glXSwapIntervalMESA'],
1570 'arguments': 'unsigned int interval', },
1571 { 'return_type': 'void',
1572 'names': ['glXUseXFont'],
1573 'arguments': 'Font font, int first, int count, int list', },
1574 { 'return_type': 'void',
1575 'names': ['glXWaitGL'],
1576 'arguments': 'void', },
1577 { 'return_type': 'int',
1578 'names': ['glXWaitVideoSyncSGI'],
1579 'arguments': 'int divisor, int remainder, unsigned int* count', },
1580 { 'return_type': 'void',
1581 'names': ['glXWaitX'],
1582 'arguments': 'void', },
1586 [GL_FUNCTIONS
, 'gl', [
1588 'noninclude/GL/glext.h',
1592 # Files below are Chromium-specific and shipped with Chromium sources.
1593 'GL/glextchromium.h',
1594 'GLES2/gl2chromium.h',
1595 'GLES2/gl2extchromium.h'
1597 [OSMESA_FUNCTIONS
, 'osmesa', [], []],
1598 [EGL_FUNCTIONS
, 'egl', [
1600 # Files below are Chromium-specific and shipped with Chromium sources.
1601 'EGL/eglextchromium.h',
1604 'EGL_ANGLE_d3d_share_handle_client_buffer',
1605 'EGL_ANGLE_surface_d3d_texture_2d_share_handle',
1608 [WGL_FUNCTIONS
, 'wgl', ['noninclude/GL/wglext.h'], []],
1609 [GLX_FUNCTIONS
, 'glx', ['GL/glx.h', 'noninclude/GL/glxext.h'], []],
1612 GLES2_HEADERS_WITH_ENUMS
= [
1615 'GLES2/gl2chromium.h',
1616 'GLES2/gl2extchromium.h',
1620 SELF_LOCATION
= os
.path
.dirname(os
.path
.abspath(__file__
))
1622 LICENSE_AND_HEADER
= """\
1623 // Copyright 2014 The Chromium Authors. All rights reserved.
1624 // Use of this source code is governed by a BSD-style license that can be
1625 // found in the LICENSE file.
1627 // This file is auto-generated from
1628 // ui/gl/generate_bindings.py
1629 // It's formatted by clang-format using chromium coding style:
1630 // clang-format -i -style=chromium filename
1635 GLVersion
= namedtuple('GLVersion', 'is_es major_version minor_version')
1637 def GLVersionBindAlways(version
):
1638 return version
.major_version
<= 2
1641 def GetStaticBinding(func
):
1642 """If this function has a name assigned to it that should be bound always,
1643 then return this name.
1645 This will be the case if either a function name is specified
1646 that depends on an extension from UNCONDITIONALLY_BOUND_EXTENSIONS,
1647 or if the GL version it depends on is assumed to be available (e.g. <=2.1).
1648 There can only be one name that satisfies this condition (or the bindings
1649 would be ambiguous)."""
1651 static_bindings
= set([])
1653 for version
in func
['versions']:
1654 if 'extensions' in version
:
1655 extensions
= version
['extensions']
1656 num_unconditional_extensions
= len(
1657 extensions
& UNCONDITIONALLY_BOUND_EXTENSIONS
)
1658 if num_unconditional_extensions
:
1659 static_bindings
.add(version
['name'])
1660 elif 'gl_versions' in version
:
1661 versions
= [v
for v
in version
['gl_versions'] if GLVersionBindAlways(v
)]
1662 # It's only unconditional if it exists in GL and GLES
1663 if len(versions
) == 2:
1664 assert versions
[0].is_es
!= versions
[1].is_es
1665 static_bindings
.add(version
['name'])
1667 static_bindings
.add(version
['name'])
1669 # Avoid ambiguous bindings (static binding with different names)
1670 assert len(static_bindings
) <= 1
1671 if len(static_bindings
):
1672 static_name
= static_bindings
.pop()
1673 # Avoid ambiguous bindings (static and dynamic bindings with
1675 assert len([v
['name'] for v
in func
['versions']
1676 if v
['name'] != static_name
]) == 0, func
1682 def GenerateHeader(file, functions
, set_name
, used_extensions
):
1683 """Generates gl_bindings_autogen_x.h"""
1685 # Write file header.
1686 file.write(LICENSE_AND_HEADER
+
1689 #ifndef UI_GFX_GL_GL_BINDINGS_AUTOGEN_%(name)s_H_
1690 #define UI_GFX_GL_GL_BINDINGS_AUTOGEN_%(name)s_H_
1696 """ % {'name': set_name
.upper()})
1698 # Write typedefs for function pointer types. Always use the GL name for the
1701 for func
in functions
:
1702 file.write('typedef %s (GL_BINDING_CALL *%sProc)(%s);\n' %
1703 (func
['return_type'], func
['known_as'], func
['arguments']))
1705 # Write declarations for booleans indicating which extensions are available.
1707 file.write("struct Extensions%s {\n" % set_name
.upper())
1708 for extension
in sorted(used_extensions
):
1709 file.write(' bool b_%s;\n' % extension
)
1713 # Write Procs struct.
1714 file.write("struct Procs%s {\n" % set_name
.upper())
1715 for func
in functions
:
1716 file.write(' %sProc %sFn;\n' % (func
['known_as'], func
['known_as']))
1722 """class GL_EXPORT %(name)sApi {
1725 virtual ~%(name)sApi();
1727 """ % {'name': set_name
.upper()})
1728 for func
in functions
:
1729 file.write(' virtual %s %sFn(%s) = 0;\n' %
1730 (func
['return_type'], func
['known_as'], func
['arguments']))
1734 file.write( '} // namespace gfx\n')
1736 # Write macros to invoke function pointers. Always use the GL name for the
1739 for func
in functions
:
1740 file.write('#define %s ::gfx::g_current_%s_context->%sFn\n' %
1741 (func
['known_as'], set_name
.lower(), func
['known_as']))
1744 file.write('#endif // UI_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' %
1748 def GenerateAPIHeader(file, functions
, set_name
):
1749 """Generates gl_bindings_api_autogen_x.h"""
1751 # Write file header.
1752 file.write(LICENSE_AND_HEADER
)
1754 # Write API declaration.
1755 for func
in functions
:
1756 file.write(' %s %sFn(%s) override;\n' %
1757 (func
['return_type'], func
['known_as'], func
['arguments']))
1762 def GenerateMockHeader(file, functions
, set_name
):
1763 """Generates gl_mock_autogen_x.h"""
1765 # Write file header.
1766 file.write(LICENSE_AND_HEADER
)
1768 # Write API declaration.
1769 for func
in functions
:
1770 args
= func
['arguments']
1775 arg_count
= func
['arguments'].count(',') + 1
1776 file.write(' MOCK_METHOD%d(%s, %s(%s));\n' %
1777 (arg_count
, func
['known_as'][2:], func
['return_type'], args
))
1782 def GenerateSource(file, functions
, set_name
, used_extensions
, options
):
1783 """Generates gl_bindings_autogen_x.cc"""
1785 set_header_name
= "ui/gl/gl_" + set_name
.lower() + "_api_implementation.h"
1786 include_list
= [ 'base/trace_event/trace_event.h',
1788 'ui/gl/gl_bindings.h',
1789 'ui/gl/gl_context.h',
1790 'ui/gl/gl_implementation.h',
1791 'ui/gl/gl_version_info.h',
1794 includes_string
= "\n".join(["#include \"{0}\"".format(h
)
1795 for h
in sorted(include_list
)])
1797 # Write file header.
1798 file.write(LICENSE_AND_HEADER
+
1806 """ % includes_string
)
1809 file.write('static bool g_debugBindingsInitialized;\n')
1810 file.write('Driver%s g_driver_%s;\n' % (set_name
.upper(), set_name
.lower()))
1813 # Write stub functions that take the place of some functions before a context
1814 # is initialized. This is done to provide clear asserts on debug build and to
1815 # avoid crashing in case of a bug on release build.
1818 for func
in functions
:
1819 static_binding
= GetStaticBinding(func
)
1821 func
['static_binding'] = static_binding
1823 num_dynamic
= num_dynamic
+ 1
1825 print "[%s] %d static bindings, %d dynamic bindings" % (
1826 set_name
, len(functions
) - num_dynamic
, num_dynamic
)
1828 # Write function to initialize the function pointers that are always the same
1829 # and to initialize bindings where choice of the function depends on the
1830 # extension string or the GL version to point to stub functions.
1832 file.write('void Driver%s::InitializeStaticBindings() {\n' %
1835 def WriteFuncBinding(file, known_as
, version_name
):
1837 ' fn.%sFn = reinterpret_cast<%sProc>(GetGLProcAddress("%s"));\n' %
1838 (known_as
, known_as
, version_name
))
1840 for func
in functions
:
1841 if 'static_binding' in func
:
1842 WriteFuncBinding(file, func
['known_as'], func
['static_binding'])
1844 file.write(' fn.%sFn = 0;\n' % func
['known_as'])
1846 if set_name
== 'gl':
1847 # Write the deferred bindings for GL that need a current context and depend
1848 # on GL_VERSION and GL_EXTENSIONS.
1850 file.write("""void DriverGL::InitializeDynamicBindings(GLContext* context) {
1851 DCHECK(context && context->IsCurrent(NULL));
1852 const GLVersionInfo* ver = context->GetVersionInfo();
1853 ALLOW_UNUSED_LOCAL(ver);
1854 std::string extensions = context->GetExtensions() + " ";
1855 ALLOW_UNUSED_LOCAL(extensions);
1859 file.write("""std::string extensions(GetPlatformExtensions());
1861 ALLOW_UNUSED_LOCAL(extensions);
1865 for extension
in sorted(used_extensions
):
1866 # Extra space at the end of the extension name is intentional, it is used
1868 file.write(' ext.b_%s = extensions.find("%s ") != std::string::npos;\n' %
1869 (extension
, extension
))
1871 def GetGLVersionCondition(gl_version
):
1872 if GLVersionBindAlways(gl_version
):
1873 if gl_version
.is_es
:
1876 return '!ver->is_es'
1877 elif gl_version
.is_es
:
1878 return 'ver->IsAtLeastGLES(%du, %du)' % (
1879 gl_version
.major_version
, gl_version
.minor_version
)
1881 return 'ver->IsAtLeastGL(%du, %du)' % (
1882 gl_version
.major_version
, gl_version
.minor_version
)
1884 def GetBindingCondition(version
):
1886 if 'gl_versions' in version
:
1888 [GetGLVersionCondition(v
) for v
in version
['gl_versions']])
1889 if 'extensions' in version
and version
['extensions']:
1891 ['ext.b_%s' % e
for e
in version
['extensions']])
1892 return ' || '.join(conditions
)
1894 def WriteConditionalFuncBinding(file, func
):
1895 assert len(func
['versions']) > 0
1896 known_as
= func
['known_as']
1898 first_version
= True
1899 while i
< len(func
['versions']):
1900 version
= func
['versions'][i
]
1901 cond
= GetBindingCondition(version
)
1903 file.write(' if (%s) {\n ' % cond
)
1905 file.write(' else if (%s) {\n ' % (cond
))
1907 WriteFuncBinding(file, known_as
, version
['name'])
1908 file.write('DCHECK(fn.%sFn);\n' % known_as
)
1911 first_version
= False
1913 for func
in functions
:
1914 if not 'static_binding' in func
:
1916 file.write(' debug_fn.%sFn = 0;\n' % func
['known_as'])
1917 WriteConditionalFuncBinding(file, func
)
1919 # Some new function pointers have been added, so update them in debug bindings
1921 file.write(' if (g_debugBindingsInitialized)\n')
1922 file.write(' InitializeDebugBindings();\n')
1926 # Write logging wrappers for each function.
1927 file.write('extern "C" {\n')
1928 for func
in functions
:
1929 return_type
= func
['return_type']
1930 arguments
= func
['arguments']
1932 file.write('static %s GL_BINDING_CALL Debug_%s(%s) {\n' %
1933 (return_type
, func
['known_as'], arguments
))
1934 argument_names
= re
.sub(
1935 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2', arguments
)
1936 argument_names
= re
.sub(
1937 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2', argument_names
)
1938 log_argument_names
= re
.sub(
1939 r
'const char\* ([a-zA-Z0-9_]+)', r
'CONSTCHAR_\1', arguments
)
1940 log_argument_names
= re
.sub(
1941 r
'(const )?[a-zA-Z0-9_]+\* ([a-zA-Z0-9_]+)',
1942 r
'CONSTVOID_\2', log_argument_names
)
1943 log_argument_names
= re
.sub(
1944 r
'(?<!E)GLenum ([a-zA-Z0-9_]+)', r
'GLenum_\1', log_argument_names
)
1945 log_argument_names
= re
.sub(
1946 r
'(?<!E)GLboolean ([a-zA-Z0-9_]+)', r
'GLboolean_\1', log_argument_names
)
1947 log_argument_names
= re
.sub(
1948 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2',
1950 log_argument_names
= re
.sub(
1951 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2',
1953 log_argument_names
= re
.sub(
1954 r
'CONSTVOID_([a-zA-Z0-9_]+)',
1955 r
'static_cast<const void*>(\1)', log_argument_names
)
1956 log_argument_names
= re
.sub(
1957 r
'CONSTCHAR_([a-zA-Z0-9_]+)', r
'\1', log_argument_names
)
1958 log_argument_names
= re
.sub(
1959 r
'GLenum_([a-zA-Z0-9_]+)', r
'GLEnums::GetStringEnum(\1)',
1961 log_argument_names
= re
.sub(
1962 r
'GLboolean_([a-zA-Z0-9_]+)', r
'GLEnums::GetStringBool(\1)',
1964 log_argument_names
= log_argument_names
.replace(',', ' << ", " <<')
1965 if argument_names
== 'void' or argument_names
== '':
1967 log_argument_names
= ''
1969 log_argument_names
= " << " + log_argument_names
1970 function_name
= func
['known_as']
1971 if return_type
== 'void':
1972 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' %
1973 (function_name
, log_argument_names
))
1974 file.write(' g_driver_%s.debug_fn.%sFn(%s);\n' %
1975 (set_name
.lower(), function_name
, argument_names
))
1976 if 'logging_code' in func
:
1977 file.write("%s\n" % func
['logging_code'])
1978 if options
.generate_dchecks
and set_name
== 'gl':
1980 file.write(' GLenum error = g_driver_gl.debug_fn.glGetErrorFn();\n')
1981 file.write(' DCHECK(error == 0);\n')
1984 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' %
1985 (function_name
, log_argument_names
))
1986 file.write(' %s result = g_driver_%s.debug_fn.%sFn(%s);\n' %
1987 (return_type
, set_name
.lower(), function_name
, argument_names
))
1988 if 'logging_code' in func
:
1989 file.write("%s\n" % func
['logging_code'])
1991 file.write(' GL_SERVICE_LOG("GL_RESULT: " << result);\n')
1992 if options
.generate_dchecks
and set_name
== 'gl':
1994 file.write(' GLenum _error = g_driver_gl.debug_fn.glGetErrorFn();\n')
1995 file.write(' DCHECK(_error == 0);\n')
1997 file.write(' return result;\n')
1999 file.write('} // extern "C"\n')
2001 # Write function to initialize the debug function pointers.
2003 file.write('void Driver%s::InitializeDebugBindings() {\n' %
2005 for func
in functions
:
2006 first_name
= func
['known_as']
2007 file.write(' if (!debug_fn.%sFn) {\n' % first_name
)
2008 file.write(' debug_fn.%sFn = fn.%sFn;\n' % (first_name
, first_name
))
2009 file.write(' fn.%sFn = Debug_%s;\n' % (first_name
, first_name
))
2011 file.write(' g_debugBindingsInitialized = true;\n')
2014 # Write function to clear all function pointers.
2016 file.write("""void Driver%s::ClearBindings() {
2017 memset(this, 0, sizeof(*this));
2019 """ % set_name
.upper())
2021 def MakeArgNames(arguments
):
2022 argument_names
= re
.sub(
2023 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2', arguments
)
2024 argument_names
= re
.sub(
2025 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2', argument_names
)
2026 if argument_names
== 'void' or argument_names
== '':
2028 return argument_names
2030 # Write GLApiBase functions
2031 for func
in functions
:
2032 function_name
= func
['known_as']
2033 return_type
= func
['return_type']
2034 arguments
= func
['arguments']
2036 file.write('%s %sApiBase::%sFn(%s) {\n' %
2037 (return_type
, set_name
.upper(), function_name
, arguments
))
2038 argument_names
= MakeArgNames(arguments
)
2039 if return_type
== 'void':
2040 file.write(' driver_->fn.%sFn(%s);\n' %
2041 (function_name
, argument_names
))
2043 file.write(' return driver_->fn.%sFn(%s);\n' %
2044 (function_name
, argument_names
))
2047 # Write TraceGLApi functions
2048 for func
in functions
:
2049 function_name
= func
['known_as']
2050 return_type
= func
['return_type']
2051 arguments
= func
['arguments']
2053 file.write('%s Trace%sApi::%sFn(%s) {\n' %
2054 (return_type
, set_name
.upper(), function_name
, arguments
))
2055 argument_names
= MakeArgNames(arguments
)
2056 file.write(' TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::%s")\n' %
2058 if return_type
== 'void':
2059 file.write(' %s_api_->%sFn(%s);\n' %
2060 (set_name
.lower(), function_name
, argument_names
))
2062 file.write(' return %s_api_->%sFn(%s);\n' %
2063 (set_name
.lower(), function_name
, argument_names
))
2066 # Write NoContextGLApi functions
2067 if set_name
.upper() == "GL":
2068 for func
in functions
:
2069 function_name
= func
['known_as']
2070 return_type
= func
['return_type']
2071 arguments
= func
['arguments']
2073 file.write('%s NoContextGLApi::%sFn(%s) {\n' %
2074 (return_type
, function_name
, arguments
))
2075 argument_names
= MakeArgNames(arguments
)
2076 no_context_error
= "Trying to call %s() without current GL context" % function_name
2077 file.write(' NOTREACHED() << "%s";\n' % no_context_error
)
2078 file.write(' LOG(ERROR) << "%s";\n' % no_context_error
)
2079 default_value
= { 'GLenum': 'static_cast<GLenum>(0)',
2082 'GLboolean': 'GL_FALSE',
2091 if return_type
.endswith('*'):
2092 file.write(' return NULL;\n')
2093 elif return_type
!= 'void':
2094 file.write(' return %s;\n' % default_value
[return_type
])
2098 file.write('} // namespace gfx\n')
2101 def GetUniquelyNamedFunctions(functions
):
2102 uniquely_named_functions
= {}
2104 for func
in functions
:
2105 for version
in func
['versions']:
2106 uniquely_named_functions
[version
['name']] = ({
2107 'name': version
['name'],
2108 'return_type': func
['return_type'],
2109 'arguments': func
['arguments'],
2110 'known_as': func
['known_as']
2112 return uniquely_named_functions
2115 def GenerateMockBindingsHeader(file, functions
):
2116 """Headers for functions that invoke MockGLInterface members"""
2118 file.write(LICENSE_AND_HEADER
)
2119 uniquely_named_functions
= GetUniquelyNamedFunctions(functions
)
2121 for key
in sorted(uniquely_named_functions
.iterkeys()):
2122 func
= uniquely_named_functions
[key
]
2123 file.write('static %s GL_BINDING_CALL Mock_%s(%s);\n' %
2124 (func
['return_type'], func
['name'], func
['arguments']))
2127 def GenerateMockBindingsSource(file, functions
):
2128 """Generates functions that invoke MockGLInterface members and a
2129 GetGLProcAddress function that returns addresses to those functions."""
2131 file.write(LICENSE_AND_HEADER
+
2136 #include "ui/gl/gl_mock.h"
2140 // This is called mainly to prevent the compiler combining the code of mock
2141 // functions with identical contents, so that their function pointers will be
2143 void MakeFunctionUnique(const char *func_name) {
2144 VLOG(2) << "Calling mock " << func_name;
2148 # Write functions that trampoline into the set MockGLInterface instance.
2149 uniquely_named_functions
= GetUniquelyNamedFunctions(functions
)
2150 sorted_function_names
= sorted(uniquely_named_functions
.iterkeys())
2152 for key
in sorted_function_names
:
2153 func
= uniquely_named_functions
[key
]
2155 file.write('%s GL_BINDING_CALL MockGLInterface::Mock_%s(%s) {\n' %
2156 (func
['return_type'], func
['name'], func
['arguments']))
2157 file.write(' MakeFunctionUnique("%s");\n' % func
['name'])
2158 arg_re
= r
'(const )?[a-zA-Z0-9]+((\s*const\s*)?\*)* ([a-zA-Z0-9]+)'
2159 argument_names
= re
.sub(arg_re
, r
'\4', func
['arguments'])
2160 if argument_names
== 'void':
2162 function_name
= func
['known_as'][2:]
2163 if func
['return_type'] == 'void':
2164 file.write(' interface_->%s(%s);\n' %
2165 (function_name
, argument_names
))
2167 file.write(' return interface_->%s(%s);\n' %
2168 (function_name
, argument_names
))
2171 # Write an 'invalid' function to catch code calling through uninitialized
2172 # function pointers or trying to interpret the return value of
2175 file.write('static void MockInvalidFunction() {\n')
2176 file.write(' NOTREACHED();\n')
2179 # Write a function to lookup a mock GL function based on its name.
2181 file.write('void* GL_BINDING_CALL ' +
2182 'MockGLInterface::GetGLProcAddress(const char* name) {\n')
2183 for key
in sorted_function_names
:
2184 name
= uniquely_named_functions
[key
]['name']
2185 file.write(' if (strcmp(name, "%s") == 0)\n' % name
)
2186 file.write(' return reinterpret_cast<void*>(Mock_%s);\n' % name
)
2187 # Always return a non-NULL pointer like some EGL implementations do.
2188 file.write(' return reinterpret_cast<void*>(&MockInvalidFunction);\n')
2192 file.write('} // namespace gfx\n')
2194 def GenerateEnumUtils(out_file
, input_filenames
):
2195 enum_re
= re
.compile(r
'\#define\s+(GL_[a-zA-Z0-9_]+)\s+([0-9A-Fa-fx]+)')
2197 for fname
in input_filenames
:
2198 lines
= open(fname
).readlines()
2200 m
= enum_re
.match(line
)
2204 if len(value
) <= 10:
2205 if not value
in dict:
2207 # check our own _CHROMIUM macro conflicts with khronos GL headers.
2208 elif dict[value
] != name
and (name
.endswith('_CHROMIUM') or
2209 dict[value
].endswith('_CHROMIUM')):
2210 raise RunTimeError("code collision: %s and %s have the same code %s"
2211 % (dict[value
], name
, value
))
2213 out_file
.write(LICENSE_AND_HEADER
)
2214 out_file
.write("static const GLEnums::EnumToString "
2215 "enum_to_string_table[] = {\n")
2217 out_file
.write(' { %s, "%s", },\n' % (value
, dict[value
]))
2218 out_file
.write("""};
2220 const GLEnums::EnumToString* const GLEnums::enum_to_string_table_ =
2221 enum_to_string_table;
2222 const size_t GLEnums::enum_to_string_table_len_ =
2223 sizeof(enum_to_string_table) / sizeof(enum_to_string_table[0]);
2228 def ParseFunctionsFromHeader(header_file
, extensions
, versions
):
2229 """Parse a C extension header file and return a map from extension names to
2230 a list of functions.
2233 header_file: Line-iterable C header file.
2235 Map of extension name => functions, Map of gl version => functions.
2236 Functions will only be in either one of the two maps.
2238 version_start
= re
.compile(
2239 r
'#ifndef GL_(ES_|)VERSION((?:_[0-9])+)$')
2240 extension_start
= re
.compile(
2241 r
'#ifndef ((?:GL|EGL|WGL|GLX)_[A-Z]+_[a-zA-Z]\w+)')
2242 extension_function
= re
.compile(r
'.+\s+([a-z]+\w+)\s*\(')
2243 typedef
= re
.compile(r
'typedef .*')
2244 macro_start
= re
.compile(r
'^#(if|ifdef|ifndef).*')
2245 macro_end
= re
.compile(r
'^#endif.*')
2247 current_version
= None
2248 current_version_depth
= 0
2249 current_extension
= None
2250 current_extension_depth
= 0
2252 # Pick up all core functions here, since some of them are missing in the
2254 hdr
= os
.path
.basename(header_file
.name
)
2256 current_version
= GLVersion(False, 1, 0)
2259 for line
in header_file
:
2260 version_match
= version_start
.match(line
)
2261 if macro_start
.match(line
):
2265 raise RuntimeError('Nested GL version macro in %s at line %d' % (
2266 header_file
.name
, line_num
))
2267 current_version_depth
= macro_depth
2268 es
= version_match
.group(1)
2269 major_version
, minor_version
=\
2270 version_match
.group(2).lstrip('_').split('_')
2272 if (not is_es
) and (major_version
== '1'):
2274 current_version
= GLVersion(
2275 is_es
, int(major_version
), int(minor_version
))
2276 elif macro_end
.match(line
):
2278 if macro_depth
< current_extension_depth
:
2279 current_extension
= None
2280 if macro_depth
< current_version_depth
:
2281 current_version
= None
2283 match
= extension_start
.match(line
)
2284 if match
and not version_match
:
2285 if current_version
and hdr
!= "gl.h":
2286 raise RuntimeError('Nested GL version macro in %s at line %d' % (
2287 header_file
.name
, line_num
))
2288 current_extension
= match
.group(1)
2289 current_extension_depth
= macro_depth
2291 match
= extension_function
.match(line
)
2292 if match
and not typedef
.match(line
):
2293 if current_extension
:
2294 extensions
[current_extension
].add(match
.group(1))
2295 elif current_version
:
2296 versions
[current_version
].add(match
.group(1))
2297 line_num
= line_num
+ 1
2300 def GetDynamicFunctions(extension_headers
):
2301 """Parse all optional functions from a list of header files.
2304 extension_headers: List of header file names.
2306 Map of extension name => list of functions,
2307 Map of gl version => list of functions.
2309 extensions
= collections
.defaultdict(lambda: set([]))
2310 gl_versions
= collections
.defaultdict(lambda: set([]))
2311 for header
in extension_headers
:
2312 ParseFunctionsFromHeader(open(header
), extensions
, gl_versions
)
2313 return extensions
, gl_versions
2316 def GetFunctionToExtensionsMap(extensions
):
2317 """Construct map from a function names to extensions which define the
2321 extensions: Map of extension name => functions.
2323 Map of function name => extension names.
2325 function_to_extensions
= {}
2326 for extension
, functions
in extensions
.items():
2327 for function
in functions
:
2328 if not function
in function_to_extensions
:
2329 function_to_extensions
[function
] = set([])
2330 function_to_extensions
[function
].add(extension
)
2331 return function_to_extensions
2333 def GetFunctionToGLVersionsMap(gl_versions
):
2334 """Construct map from a function names to GL versions which define the
2338 extensions: Map of gl versions => functions.
2340 Map of function name => gl versions.
2342 function_to_gl_versions
= {}
2343 for gl_version
, functions
in gl_versions
.items():
2344 for function
in functions
:
2345 if not function
in function_to_gl_versions
:
2346 function_to_gl_versions
[function
] = set([])
2347 function_to_gl_versions
[function
].add(gl_version
)
2348 return function_to_gl_versions
2351 def LooksLikeExtensionFunction(function
):
2352 """Heuristic to see if a function name is consistent with extension function
2354 vendor
= re
.match(r
'\w+?([A-Z][A-Z]+)$', function
)
2355 return vendor
is not None and not vendor
.group(1) in ['GL', 'API', 'DC']
2358 def SortVersions(key
):
2359 # Prefer functions from the core for binding
2360 if 'gl_versions' in key
:
2365 def FillExtensionsFromHeaders(functions
, extension_headers
, extra_extensions
):
2366 """Determine which functions belong to extensions based on extension headers,
2367 and fill in this information to the functions table for functions that don't
2368 already have the information.
2371 functions: List of (return type, function versions, arguments).
2372 extension_headers: List of header file names.
2373 extra_extensions: Extensions to add to the list.
2375 Set of used extensions.
2377 # Parse known extensions.
2378 extensions
, gl_versions
= GetDynamicFunctions(extension_headers
)
2379 functions_to_extensions
= GetFunctionToExtensionsMap(extensions
)
2380 functions_to_gl_versions
= GetFunctionToGLVersionsMap(gl_versions
)
2382 # Fill in the extension information.
2383 used_extensions
= set()
2384 used_functions_by_version
= collections
.defaultdict(lambda: set([]))
2385 for func
in functions
:
2386 for version
in func
['versions']:
2387 name
= version
['name']
2389 # There should only be one version entry per name string.
2390 if len([v
for v
in func
['versions'] if v
['name'] == name
]) > 1:
2392 'Duplicate version entries with same name for %s' % name
)
2394 # Make sure we know about all extensions and extension functions.
2395 extensions_from_headers
= set([])
2396 if name
in functions_to_extensions
:
2397 extensions_from_headers
= set(functions_to_extensions
[name
])
2399 explicit_extensions
= set([])
2400 if 'extensions' in version
:
2401 explicit_extensions
= set(version
['extensions'])
2403 in_both
= explicit_extensions
.intersection(extensions_from_headers
)
2405 print "[%s] Specified redundant extensions for binding: %s" % (
2406 name
, ', '.join(in_both
))
2407 diff
= explicit_extensions
- extensions_from_headers
2409 print "[%s] Specified extra extensions for binding: %s" % (
2410 name
, ', '.join(diff
))
2412 all_extensions
= extensions_from_headers
.union(explicit_extensions
)
2413 if len(all_extensions
):
2414 version
['extensions'] = all_extensions
2416 if 'extensions' in version
:
2417 assert len(version
['extensions'])
2418 used_extensions
.update(version
['extensions'])
2420 if not 'extensions' in version
and LooksLikeExtensionFunction(name
):
2421 raise RuntimeError('%s looks like an extension function but does not '
2422 'belong to any of the known extensions.' % name
)
2424 if name
in functions_to_gl_versions
:
2425 assert not 'gl_versions' in version
2426 version
['gl_versions'] = functions_to_gl_versions
[name
]
2427 for v
in version
['gl_versions']:
2428 used_functions_by_version
[v
].add(name
)
2430 func
['versions'] = sorted(func
['versions'], key
=SortVersions
)
2432 # Add extensions that do not have any functions.
2433 used_extensions
.update(extra_extensions
)
2435 # Print out used function count by GL(ES) version.
2436 for v
in sorted([v
for v
in used_functions_by_version
if v
.is_es
]):
2437 print "OpenGL ES %d.%d: %d used functions" % (
2438 v
.major_version
, v
.minor_version
, len(used_functions_by_version
[v
]))
2439 for v
in sorted([v
for v
in used_functions_by_version
if not v
.is_es
]):
2440 print "OpenGL %d.%d: %d used functions" % (
2441 v
.major_version
, v
.minor_version
, len(used_functions_by_version
[v
]))
2443 return used_extensions
2446 def ResolveHeader(header
, header_paths
):
2447 for path
in header_paths
:
2448 result
= os
.path
.join(path
, header
)
2449 if not os
.path
.isabs(path
):
2450 result
= os
.path
.abspath(os
.path
.join(SELF_LOCATION
, result
))
2451 if os
.path
.exists(result
):
2452 # Always use forward slashes as path separators. Otherwise backslashes
2453 # may be incorrectly interpreted as escape characters.
2454 return result
.replace(os
.path
.sep
, '/')
2456 raise Exception('Header %s not found.' % header
)
2460 """This is the main function."""
2462 parser
= optparse
.OptionParser()
2463 parser
.add_option('--inputs', action
='store_true')
2464 parser
.add_option('--verify-order', action
='store_true')
2465 parser
.add_option('--generate-dchecks', action
='store_true',
2466 help='Generates DCHECKs into the logging functions '
2467 'asserting no GL errors (useful for debugging)')
2469 options
, args
= parser
.parse_args(argv
)
2472 for [_
, _
, headers
, _
] in FUNCTION_SETS
:
2473 for header
in headers
:
2474 print ResolveHeader(header
, HEADER_PATHS
)
2477 directory
= SELF_LOCATION
2481 def ClangFormat(filename
):
2482 formatter
= "clang-format"
2483 if platform
.system() == "Windows":
2485 call([formatter
, "-i", "-style=chromium", filename
])
2487 for [functions
, set_name
, extension_headers
, extensions
] in FUNCTION_SETS
:
2488 # Function names can be specified in two ways (list of unique names or list
2489 # of versions with different binding conditions). Fill in the data to the
2490 # versions list in case it is missing, so that can be used from here on:
2491 for func
in functions
:
2492 assert 'versions' in func
or 'names' in func
, 'Function with no names'
2493 if 'versions' not in func
:
2494 func
['versions'] = [{'name': n
} for n
in func
['names']]
2495 # Use the first version's name unless otherwise specified
2496 if 'known_as' not in func
:
2497 func
['known_as'] = func
['versions'][0]['name']
2498 # Make sure that 'names' is not accidentally used instead of 'versions'
2502 # Check function names in each set is sorted in alphabetical order.
2503 for index
in range(len(functions
) - 1):
2504 func_name
= functions
[index
]['known_as']
2505 next_func_name
= functions
[index
+ 1]['known_as']
2506 if func_name
.lower() > next_func_name
.lower():
2508 'function %s is not in alphabetical order' % next_func_name
)
2509 if options
.verify_order
:
2512 extension_headers
= [ResolveHeader(h
, HEADER_PATHS
)
2513 for h
in extension_headers
]
2514 used_extensions
= FillExtensionsFromHeaders(
2515 functions
, extension_headers
, extensions
)
2518 os
.path
.join(directory
, 'gl_bindings_autogen_%s.h' % set_name
), 'wb')
2519 GenerateHeader(header_file
, functions
, set_name
, used_extensions
)
2521 ClangFormat(header_file
.name
)
2524 os
.path
.join(directory
, 'gl_bindings_api_autogen_%s.h' % set_name
),
2526 GenerateAPIHeader(header_file
, functions
, set_name
)
2528 ClangFormat(header_file
.name
)
2531 os
.path
.join(directory
, 'gl_bindings_autogen_%s.cc' % set_name
), 'wb')
2532 GenerateSource(source_file
, functions
, set_name
, used_extensions
, options
)
2534 ClangFormat(source_file
.name
)
2536 if not options
.verify_order
:
2538 os
.path
.join(directory
, 'gl_mock_autogen_gl.h'), 'wb')
2539 GenerateMockHeader(header_file
, GL_FUNCTIONS
, 'gl')
2541 ClangFormat(header_file
.name
)
2543 header_file
= open(os
.path
.join(directory
, 'gl_bindings_autogen_mock.h'),
2545 GenerateMockBindingsHeader(header_file
, GL_FUNCTIONS
)
2547 ClangFormat(header_file
.name
)
2549 source_file
= open(os
.path
.join(directory
, 'gl_bindings_autogen_mock.cc'),
2551 GenerateMockBindingsSource(source_file
, GL_FUNCTIONS
)
2553 ClangFormat(source_file
.name
)
2555 enum_header_filenames
= [ResolveHeader(h
, HEADER_PATHS
)
2556 for h
in GLES2_HEADERS_WITH_ENUMS
]
2557 header_file
= open(os
.path
.join(directory
,
2558 'gl_enums_implementation_autogen.h'),
2560 GenerateEnumUtils(header_file
, enum_header_filenames
)
2562 ClangFormat(header_file
.name
)
2566 if __name__
== '__main__':
2567 sys
.exit(main(sys
.argv
[1:]))