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