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