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