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