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 """In case there are multiple versions of the same function, one that's listed
15 first takes priority if its conditions are met. If the function is an extension
16 function, finding the extension from the extension string is a condition for
17 binding it. The last version of the function is treated as a fallback option in
18 case no other versions were bound, so a non-null function pointer in the
19 bindings does not guarantee that the function is supported.
21 Function binding conditions can be specified manually by supplying a versions
22 array instead of the names array. Each version has the following keys:
23 name: Mandatory. Name of the function. Multiple versions can have the same
24 name but different conditions.
25 gl_versions: List of GL versions where the function is found.
26 extensions: Extensions where the function is found. If not specified, the
27 extensions are determined based on GL header files.
28 If the function exists in an extension header, you may specify
29 an empty array to prevent making that a condition for binding.
31 By default, the function gets its name from the first name in its names or
32 versions array. This can be overridden by supplying a 'known_as' key.
35 { 'return_type': 'void',
36 'names': ['glActiveTexture'],
37 'arguments': 'GLenum texture', },
38 { 'return_type': 'void',
39 'names': ['glAttachShader'],
40 'arguments': 'GLuint program, GLuint shader', },
41 { 'return_type': 'void',
42 'versions': [{ 'name': 'glBeginQuery',
43 'gl_versions': ['gl3', 'gl4', 'es3'] }],
44 'arguments': 'GLenum target, GLuint id', },
45 { 'return_type': 'void',
46 'names': ['glBeginQueryARB', 'glBeginQueryEXT'],
47 'arguments': 'GLenum target, GLuint id', },
48 { 'return_type': 'void',
49 'versions': [{ 'name': 'glBeginTransformFeedback',
50 'gl_versions': ['gl3', 'gl4', 'es3'] }],
51 'arguments': 'GLenum primitiveMode', },
52 { 'return_type': 'void',
53 'names': ['glBindAttribLocation'],
54 'arguments': 'GLuint program, GLuint index, const char* name', },
55 { 'return_type': 'void',
56 'names': ['glBindBuffer'],
57 'arguments': 'GLenum target, GLuint buffer', },
58 { 'return_type': 'void',
59 'versions': [{ 'name': 'glBindBufferBase',
60 'gl_versions': ['gl3', 'gl4', 'es3'] }],
61 'arguments': 'GLenum target, GLuint index, GLuint buffer', },
62 { 'return_type': 'void',
63 'versions': [{ 'name': 'glBindBufferRange',
64 'gl_versions': ['gl3', 'gl4', 'es3'] }],
65 'arguments': 'GLenum target, GLuint index, GLuint buffer, GLintptr offset, '
67 { 'return_type': 'void',
68 'names': ['glBindFragDataLocation'],
69 'arguments': 'GLuint program, GLuint colorNumber, const char* name', },
70 { 'return_type': 'void',
71 'names': ['glBindFragDataLocationIndexed'],
73 'GLuint program, GLuint colorNumber, GLuint index, const char* name', },
74 { 'return_type': 'void',
75 'names': ['glBindFramebufferEXT', 'glBindFramebuffer'],
76 'arguments': 'GLenum target, GLuint framebuffer', },
77 { 'return_type': 'void',
78 'names': ['glBindRenderbufferEXT', 'glBindRenderbuffer'],
79 'arguments': 'GLenum target, GLuint renderbuffer', },
80 { 'return_type': 'void',
81 'versions': [{ 'name': 'glBindSampler',
82 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.2 or higher.
83 'arguments': 'GLuint unit, GLuint sampler', },
84 { 'return_type': 'void',
85 'names': ['glBindTexture'],
86 'arguments': 'GLenum target, GLuint texture', },
87 { 'return_type': 'void',
88 'versions': [{ 'name': 'glBindTransformFeedback',
89 'gl_versions': ['gl4', 'es3'] }],
90 'arguments': 'GLenum target, GLuint id', },
91 { 'return_type': 'void',
92 'known_as': 'glBindVertexArrayOES',
93 'versions': [{ 'name': 'glBindVertexArray',
94 'gl_versions': ['gl3', 'gl4', 'es3'] },
95 { 'name': 'glBindVertexArray',
96 'extensions': ['GL_ARB_vertex_array_object'] },
97 { 'name': 'glBindVertexArrayOES' },
98 { 'name': 'glBindVertexArrayAPPLE',
99 'extensions': ['GL_APPLE_vertex_array_object'] }],
100 'arguments': 'GLuint array' },
101 { 'return_type': 'void',
102 'known_as': 'glBlendBarrierKHR',
103 'versions': [{ 'name': 'glBlendBarrierNV',
104 'extensions': ['GL_NV_blend_equation_advanced'] },
105 { 'name': 'glBlendBarrierKHR',
106 'extensions': ['GL_KHR_blend_equation_advanced'] }],
107 'arguments': 'void' },
108 { 'return_type': 'void',
109 'names': ['glBlendColor'],
110 'arguments': 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha', },
111 { 'return_type': 'void',
112 'names': ['glBlendEquation'],
113 'arguments': ' GLenum mode ', },
114 { 'return_type': 'void',
115 'names': ['glBlendEquationSeparate'],
116 'arguments': 'GLenum modeRGB, GLenum modeAlpha', },
117 { 'return_type': 'void',
118 'names': ['glBlendFunc'],
119 'arguments': 'GLenum sfactor, GLenum dfactor', },
120 { 'return_type': 'void',
121 'names': ['glBlendFuncSeparate'],
123 'GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha', },
124 { 'return_type': 'void',
125 'names': ['glBlitFramebuffer'],
126 'arguments': 'GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, '
127 'GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, '
128 'GLbitfield mask, GLenum filter', },
129 { 'return_type': 'void',
130 'names': ['glBlitFramebufferANGLE', 'glBlitFramebuffer'],
131 'arguments': 'GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, '
132 'GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, '
133 'GLbitfield mask, GLenum filter', },
134 { 'return_type': 'void',
135 'names': ['glBlitFramebufferEXT', 'glBlitFramebuffer'],
136 'arguments': 'GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, '
137 'GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, '
138 'GLbitfield mask, GLenum filter', },
139 { 'return_type': 'void',
140 'names': ['glBufferData'],
142 'GLenum target, GLsizeiptr size, const void* data, GLenum usage', },
143 { 'return_type': 'void',
144 'names': ['glBufferSubData'],
146 'GLenum target, GLintptr offset, GLsizeiptr size, const void* data', },
147 { 'return_type': 'GLenum',
148 'names': ['glCheckFramebufferStatusEXT',
149 'glCheckFramebufferStatus'],
150 'arguments': 'GLenum target',
152 GL_SERVICE_LOG("GL_RESULT: " << GLES2Util::GetStringEnum(result));
154 { 'return_type': 'void',
155 'names': ['glClear'],
156 'arguments': 'GLbitfield mask', },
157 { 'return_type': 'void',
158 'versions': [{ 'name': 'glClearBufferfi',
159 'gl_versions': ['gl3', 'gl4', 'es3'] }],
160 'arguments': 'GLenum buffer, GLint drawbuffer, const GLfloat depth, '
162 { 'return_type': 'void',
163 'versions': [{ 'name': 'glClearBufferfv',
164 'gl_versions': ['gl3', 'gl4', 'es3'] }],
165 'arguments': 'GLenum buffer, GLint drawbuffer, const GLfloat* value', },
166 { 'return_type': 'void',
167 'versions': [{ 'name': 'glClearBufferiv',
168 'gl_versions': ['gl3', 'gl4', 'es3'] }],
169 'arguments': 'GLenum buffer, GLint drawbuffer, const GLint* value', },
170 { 'return_type': 'void',
171 'versions': [{ 'name': 'glClearBufferuiv',
172 'gl_versions': ['gl3', 'gl4', 'es3'] }],
173 'arguments': 'GLenum buffer, GLint drawbuffer, const GLuint* value', },
174 { 'return_type': 'void',
175 'names': ['glClearColor'],
176 'arguments': 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha', },
177 { 'return_type': 'void',
178 'names': ['glClearDepth'],
179 'arguments': 'GLclampd depth', },
180 { 'return_type': 'void',
181 'names': ['glClearDepthf'],
182 'arguments': 'GLclampf depth', },
183 { 'return_type': 'void',
184 'names': ['glClearStencil'],
185 'arguments': 'GLint s', },
186 { 'return_type': 'GLenum',
187 'names': ['glClientWaitSync'],
188 'arguments': 'GLsync sync, GLbitfield flags, GLuint64 timeout', },
189 { 'return_type': 'void',
190 'names': ['glColorMask'],
192 'GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha', },
193 { 'return_type': 'void',
194 'names': ['glCompileShader'],
195 'arguments': 'GLuint shader', },
196 { 'return_type': 'void',
197 'names': ['glCompressedTexImage2D'],
199 'GLenum target, GLint level, GLenum internalformat, GLsizei width, '
200 'GLsizei height, GLint border, GLsizei imageSize, const void* data', },
201 { 'return_type': 'void',
202 'versions': [{ 'name': 'glCompressedTexImage3D',
203 'gl_versions': ['gl3', 'gl4', 'es3'] }],
205 'GLenum target, GLint level, GLenum internalformat, GLsizei width, '
206 'GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, '
207 'const void* data', },
208 { 'return_type': 'void',
209 'names': ['glCompressedTexSubImage2D'],
211 'GLenum target, GLint level, GLint xoffset, GLint yoffset, '
212 'GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, '
213 'const void* data', },
214 # TODO(zmo): wait for MOCK_METHOD11.
215 # { 'return_type': 'void',
216 # 'versions': [{ 'name': 'glCompressedTexSubImage3D',
217 # 'gl_versions': ['gl3', 'gl4', 'es3'] }],
219 # 'GLenum target, GLint level, GLint xoffset, GLint yoffset, '
220 # 'GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, '
221 # 'GLenum format, GLsizei imageSize, const void* data', },
222 { 'return_type': 'void',
223 'versions': [{ 'name': 'glCopyBufferSubData',
224 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.1 or higher.
226 'GLenum readTarget, GLenum writeTarget, GLintptr readOffset, '
227 'GLintptr writeOffset, GLsizeiptr size', },
228 { 'return_type': 'void',
229 'names': ['glCopyTexImage2D'],
231 'GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, '
232 'GLsizei width, GLsizei height, GLint border', },
233 { 'return_type': 'void',
234 'names': ['glCopyTexSubImage2D'],
236 'GLenum target, GLint level, GLint xoffset, '
237 'GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height', },
238 { 'return_type': 'void',
239 'versions': [{ 'name': 'glCopyTexSubImage3D',
240 'gl_versions': ['gl3', 'gl4', 'es3'] }],
242 'GLenum target, GLint level, GLint xoffset, GLint yoffset, '
243 'GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height', },
244 { 'return_type': 'GLuint',
245 'names': ['glCreateProgram'],
246 'arguments': 'void', },
247 { 'return_type': 'GLuint',
248 'names': ['glCreateShader'],
249 'arguments': 'GLenum type', },
250 { 'return_type': 'void',
251 'names': ['glCullFace'],
252 'arguments': 'GLenum mode', },
253 { 'return_type': 'void',
254 'names': ['glDeleteBuffersARB', 'glDeleteBuffers'],
255 'arguments': 'GLsizei n, const GLuint* buffers', },
256 { 'return_type': 'void',
257 'known_as': 'glDeleteFencesAPPLE',
258 'versions': [{ 'name': 'glDeleteFencesAPPLE',
259 'extensions': ['GL_APPLE_fence'] }],
260 'arguments': 'GLsizei n, const GLuint* fences', },
261 { 'return_type': 'void',
262 'names': ['glDeleteFencesNV'],
263 'arguments': 'GLsizei n, const GLuint* fences', },
264 { 'return_type': 'void',
265 'names': ['glDeleteFramebuffersEXT', 'glDeleteFramebuffers'],
266 'arguments': 'GLsizei n, const GLuint* framebuffers', },
267 { 'return_type': 'void',
268 'names': ['glDeleteProgram'],
269 'arguments': 'GLuint program', },
270 { 'return_type': 'void',
271 'versions': [{ 'name': 'glDeleteQueries',
272 'gl_versions': ['gl3', 'gl4', 'es3'] }],
273 'arguments': 'GLsizei n, const GLuint* ids', },
274 { 'return_type': 'void',
275 'names': ['glDeleteQueriesARB', 'glDeleteQueriesEXT'],
276 'arguments': 'GLsizei n, const GLuint* ids', },
277 { 'return_type': 'void',
278 'names': ['glDeleteRenderbuffersEXT', 'glDeleteRenderbuffers'],
279 'arguments': 'GLsizei n, const GLuint* renderbuffers', },
280 { 'return_type': 'void',
281 'versions': [{ 'name': 'glDeleteSamplers',
282 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.2 or higher.
283 'arguments': 'GLsizei n, const GLuint* samplers', },
284 { 'return_type': 'void',
285 'names': ['glDeleteShader'],
286 'arguments': 'GLuint shader', },
287 { 'return_type': 'void',
288 'names': ['glDeleteSync'],
289 'arguments': 'GLsync sync', },
290 { 'return_type': 'void',
291 'names': ['glDeleteTextures'],
292 'arguments': 'GLsizei n, const GLuint* textures', },
293 { 'return_type': 'void',
294 'versions': [{ 'name': 'glDeleteTransformFeedbacks',
295 'gl_versions': ['gl4', 'es3'] }],
296 'arguments': 'GLsizei n, const GLuint* ids', },
297 { 'return_type': 'void',
298 'known_as': 'glDeleteVertexArraysOES',
299 'versions': [{ 'name': 'glDeleteVertexArrays',
300 'gl_versions': ['gl3', 'gl4', 'es3'] },
301 { 'name': 'glDeleteVertexArrays',
302 'extensions': ['GL_ARB_vertex_array_object'] },
303 { 'name': 'glDeleteVertexArraysOES' },
304 { 'name': 'glDeleteVertexArraysAPPLE',
305 'extensions': ['GL_APPLE_vertex_array_object'] }],
306 'arguments': 'GLsizei n, const GLuint* arrays' },
307 { 'return_type': 'void',
308 'names': ['glDepthFunc'],
309 'arguments': 'GLenum func', },
310 { 'return_type': 'void',
311 'names': ['glDepthMask'],
312 'arguments': 'GLboolean flag', },
313 { 'return_type': 'void',
314 'names': ['glDepthRange'],
315 'arguments': 'GLclampd zNear, GLclampd zFar', },
316 { 'return_type': 'void',
317 'names': ['glDepthRangef'],
318 'arguments': 'GLclampf zNear, GLclampf zFar', },
319 { 'return_type': 'void',
320 'names': ['glDetachShader'],
321 'arguments': 'GLuint program, GLuint shader', },
322 { 'return_type': 'void',
323 'names': ['glDisable'],
324 'arguments': 'GLenum cap', },
325 { 'return_type': 'void',
326 'names': ['glDisableVertexAttribArray'],
327 'arguments': 'GLuint index', },
328 { 'return_type': 'void',
329 'known_as': 'glDiscardFramebufferEXT',
330 'versions': [{ 'name': 'glInvalidateFramebuffer',
331 'gl_versions': ['es3'],
333 { 'name': 'glDiscardFramebufferEXT',
334 'gl_versions': ['es1', 'es2'] }],
335 'arguments': 'GLenum target, GLsizei numAttachments, '
336 'const GLenum* attachments' },
337 { 'return_type': 'void',
338 'names': ['glDrawArrays'],
339 'arguments': 'GLenum mode, GLint first, GLsizei count', },
340 { 'return_type': 'void',
341 'known_as': 'glDrawArraysInstancedANGLE',
342 'names': ['glDrawArraysInstancedARB', 'glDrawArraysInstancedANGLE',
343 'glDrawArraysInstanced'],
344 'arguments': 'GLenum mode, GLint first, GLsizei count, GLsizei primcount', },
345 { 'return_type': 'void',
346 'names': ['glDrawBuffer'],
347 'arguments': 'GLenum mode', },
348 { 'return_type': 'void',
349 'names': ['glDrawBuffersARB', 'glDrawBuffersEXT', 'glDrawBuffers'],
350 'arguments': 'GLsizei n, const GLenum* bufs', },
351 { 'return_type': 'void',
352 'names': ['glDrawElements'],
354 'GLenum mode, GLsizei count, GLenum type, const void* indices', },
355 { 'return_type': 'void',
356 'known_as': 'glDrawElementsInstancedANGLE',
357 'names': ['glDrawElementsInstancedARB', 'glDrawElementsInstancedANGLE',
358 'glDrawElementsInstanced'],
360 'GLenum mode, GLsizei count, GLenum type, const void* indices, '
361 'GLsizei primcount', },
362 { 'return_type': 'void',
363 'versions': [{ 'name': 'glDrawRangeElements',
364 'gl_versions': ['gl3', 'gl4', 'es3'] }],
365 'arguments': 'GLenum mode, GLuint start, GLuint end, GLsizei count, '
366 'GLenum type, const void* indices', },
367 { 'return_type': 'void',
368 'names': ['glEGLImageTargetRenderbufferStorageOES'],
369 'arguments': 'GLenum target, GLeglImageOES image', },
370 { 'return_type': 'void',
371 'names': ['glEGLImageTargetTexture2DOES'],
372 'arguments': 'GLenum target, GLeglImageOES image', },
373 { 'return_type': 'void',
374 'names': ['glEnable'],
375 'arguments': 'GLenum cap', },
376 { 'return_type': 'void',
377 'names': ['glEnableVertexAttribArray'],
378 'arguments': 'GLuint index', },
379 { 'return_type': 'void',
380 'versions': [{ 'name': 'glEndQuery',
381 'gl_versions': ['gl3', 'gl4', 'es3'] }],
382 'arguments': 'GLenum target', },
383 { 'return_type': 'void',
384 'names': ['glEndQueryARB', 'glEndQueryEXT'],
385 'arguments': 'GLenum target', },
386 { 'return_type': 'void',
387 'versions': [{ 'name': 'glEndTransformFeedback',
388 'gl_versions': ['gl3', 'gl4', 'es3'] }],
389 'arguments': 'void', },
390 { 'return_type': 'GLsync',
391 'names': ['glFenceSync'],
392 'arguments': 'GLenum condition, GLbitfield flags', },
393 { 'return_type': 'void',
394 'names': ['glFinish'],
395 'arguments': 'void', },
396 { 'return_type': 'void',
397 'known_as': 'glFinishFenceAPPLE',
398 'versions': [{ 'name': 'glFinishFenceAPPLE',
399 'extensions': ['GL_APPLE_fence'] }],
400 'arguments': 'GLuint fence', },
401 { 'return_type': 'void',
402 'names': ['glFinishFenceNV'],
403 'arguments': 'GLuint fence', },
404 { 'return_type': 'void',
405 'names': ['glFlush'],
406 'arguments': 'void', },
407 { 'return_type': 'void',
408 'names': ['glFlushMappedBufferRange'],
409 'arguments': 'GLenum target, GLintptr offset, GLsizeiptr length', },
410 { 'return_type': 'void',
411 'names': ['glFramebufferRenderbufferEXT', 'glFramebufferRenderbuffer'],
413 'GLenum target, GLenum attachment, GLenum renderbuffertarget, '
414 'GLuint renderbuffer', },
415 { 'return_type': 'void',
416 'names': ['glFramebufferTexture2DEXT', 'glFramebufferTexture2D'],
418 'GLenum target, GLenum attachment, GLenum textarget, GLuint texture, '
420 { 'return_type': 'void',
421 'names': ['glFramebufferTexture2DMultisampleEXT'],
423 'GLenum target, GLenum attachment, GLenum textarget, GLuint texture, '
424 'GLint level, GLsizei samples', },
425 { 'return_type': 'void',
426 'names': ['glFramebufferTexture2DMultisampleIMG'],
428 'GLenum target, GLenum attachment, GLenum textarget, GLuint texture, '
429 'GLint level, GLsizei samples', },
430 { 'return_type': 'void',
431 'versions': [{ 'name': 'glFramebufferTextureLayer',
432 'gl_versions': ['gl3', 'gl4', 'es3'] }],
433 'arguments': 'GLenum target, GLenum attachment, GLuint texture, GLint level, '
435 { 'return_type': 'void',
436 'names': ['glFrontFace'],
437 'arguments': 'GLenum mode', },
438 { 'return_type': 'void',
439 'names': ['glGenBuffersARB', 'glGenBuffers'],
440 'arguments': 'GLsizei n, GLuint* buffers', },
441 { 'return_type': 'void',
442 'names': ['glGenerateMipmapEXT', 'glGenerateMipmap'],
443 'arguments': 'GLenum target', },
444 { 'return_type': 'void',
445 'known_as': 'glGenFencesAPPLE',
446 'versions': [{ 'name': 'glGenFencesAPPLE',
447 'extensions': ['GL_APPLE_fence'] }],
448 'arguments': 'GLsizei n, GLuint* fences', },
449 { 'return_type': 'void',
450 'names': ['glGenFencesNV'],
451 'arguments': 'GLsizei n, GLuint* fences', },
452 { 'return_type': 'void',
453 'names': ['glGenFramebuffersEXT', 'glGenFramebuffers'],
454 'arguments': 'GLsizei n, GLuint* framebuffers', },
455 { 'return_type': 'void',
456 'versions': [{ 'name': 'glGenQueries',
457 'gl_versions': ['gl3', 'gl4', 'es3'] }],
458 'arguments': 'GLsizei n, GLuint* ids', },
459 { 'return_type': 'void',
460 'names': ['glGenQueriesARB', 'glGenQueriesEXT'],
461 'arguments': 'GLsizei n, GLuint* ids', },
462 { 'return_type': 'void',
463 'names': ['glGenRenderbuffersEXT', 'glGenRenderbuffers'],
464 'arguments': 'GLsizei n, GLuint* renderbuffers', },
465 { 'return_type': 'void',
466 'versions': [{ 'name': 'glGenSamplers',
467 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.2 or higher.
468 'arguments': 'GLsizei n, GLuint* samplers', },
469 { 'return_type': 'void',
470 'names': ['glGenTextures'],
471 'arguments': 'GLsizei n, GLuint* textures', },
472 { 'return_type': 'void',
473 'versions': [{ 'name': 'glGenTransformFeedbacks',
474 'gl_versions': ['gl4', 'es3'] }],
475 'arguments': 'GLsizei n, GLuint* ids', },
476 { 'return_type': 'void',
477 'known_as': 'glGenVertexArraysOES',
478 'versions': [{ 'name': 'glGenVertexArrays',
479 'gl_versions': ['gl3', 'gl4', 'es3'] },
480 { 'name': 'glGenVertexArrays',
481 'extensions': ['GL_ARB_vertex_array_object'] },
482 { 'name': 'glGenVertexArraysOES' },
483 { 'name': 'glGenVertexArraysAPPLE',
484 'extensions': ['GL_APPLE_vertex_array_object'] }],
485 'arguments': 'GLsizei n, GLuint* arrays', },
486 { 'return_type': 'void',
487 'names': ['glGetActiveAttrib'],
489 'GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, '
490 'GLint* size, GLenum* type, char* name', },
491 { 'return_type': 'void',
492 'names': ['glGetActiveUniform'],
494 'GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, '
495 'GLint* size, GLenum* type, char* name', },
496 { 'return_type': 'void',
497 'versions': [{ 'name': 'glGetActiveUniformBlockiv',
498 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.1 or higher.
499 'arguments': 'GLuint program, GLuint uniformBlockIndex, GLenum pname, '
501 { 'return_type': 'void',
502 'versions': [{ 'name': 'glGetActiveUniformBlockName',
503 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.1 or higher.
504 'arguments': 'GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, '
505 'GLsizei* length, char* uniformBlockName', },
506 { 'return_type': 'void',
507 'versions': [{ 'name': 'glGetActiveUniformsiv',
508 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.1 or higher.
509 'arguments': 'GLuint program, GLsizei uniformCount, '
510 'const GLuint* uniformIndices, GLenum pname, GLint* params', },
511 { 'return_type': 'void',
512 'names': ['glGetAttachedShaders'],
514 'GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders', },
515 { 'return_type': 'GLint',
516 'names': ['glGetAttribLocation'],
517 'arguments': 'GLuint program, const char* name', },
518 { 'return_type': 'void',
519 'names': ['glGetBooleanv'],
520 'arguments': 'GLenum pname, GLboolean* params', },
521 { 'return_type': 'void',
522 'names': ['glGetBufferParameteriv'],
523 'arguments': 'GLenum target, GLenum pname, GLint* params', },
524 { 'return_type': 'GLenum',
525 'names': ['glGetError'],
528 GL_SERVICE_LOG("GL_RESULT: " << GLES2Util::GetStringError(result));
530 { 'return_type': 'void',
531 'names': ['glGetFenceivNV'],
532 'arguments': 'GLuint fence, GLenum pname, GLint* params', },
533 { 'return_type': 'void',
534 'names': ['glGetFloatv'],
535 'arguments': 'GLenum pname, GLfloat* params', },
536 { 'return_type': 'GLint',
537 'versions': [{ 'name': 'glGetFragDataLocation',
538 'gl_versions': ['gl3', 'gl4', 'es3'] }],
539 'arguments': 'GLuint program, const char* name', },
540 { 'return_type': 'void',
541 'names': ['glGetFramebufferAttachmentParameterivEXT',
542 'glGetFramebufferAttachmentParameteriv'],
543 'arguments': 'GLenum target, '
544 'GLenum attachment, GLenum pname, GLint* params', },
545 { 'return_type': 'GLenum',
546 'names': ['glGetGraphicsResetStatusARB',
547 'glGetGraphicsResetStatusKHR',
548 'glGetGraphicsResetStatusEXT',
549 'glGetGraphicsResetStatus'],
550 'arguments': 'void', },
551 { 'return_type': 'void',
552 'versions': [{ 'name': 'glGetInteger64i_v',
553 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.2 or higher.
554 'arguments': 'GLenum target, GLuint index, GLint64* data', },
555 { 'return_type': 'void',
556 'names': ['glGetInteger64v'],
557 'arguments': 'GLenum pname, GLint64* params', },
558 { 'return_type': 'void',
559 'versions': [{ 'name': 'glGetIntegeri_v',
560 'gl_versions': ['gl3', 'gl4', 'es3'] }],
561 'arguments': 'GLenum target, GLuint index, GLint* data', },
562 { 'return_type': 'void',
563 'names': ['glGetIntegerv'],
564 'arguments': 'GLenum pname, GLint* params', },
565 { 'return_type': 'void',
566 'versions': [{ 'name': 'glGetInternalformativ',
567 'gl_versions': ['gl4', 'es3'] }], # GL 4.2 or higher.
568 'arguments': 'GLenum target, GLenum internalformat, GLenum pname, '
569 'GLsizei bufSize, GLint* params', },
570 { 'return_type': 'void',
571 'known_as': 'glGetProgramBinary',
572 'versions': [{ 'name': 'glGetProgramBinaryOES' },
573 { 'name': 'glGetProgramBinary',
574 'extensions': ['GL_ARB_get_program_binary'] },
575 { 'name': 'glGetProgramBinary' }],
576 'arguments': 'GLuint program, GLsizei bufSize, GLsizei* length, '
577 'GLenum* binaryFormat, GLvoid* binary' },
578 { 'return_type': 'void',
579 'names': ['glGetProgramInfoLog'],
581 'GLuint program, GLsizei bufsize, GLsizei* length, char* infolog', },
582 { 'return_type': 'void',
583 'names': ['glGetProgramiv'],
584 'arguments': 'GLuint program, GLenum pname, GLint* params', },
585 { 'return_type': 'void',
586 'versions': [{ 'name': 'glGetQueryiv',
587 'gl_versions': ['gl3', 'gl4', 'es3'] }],
588 'arguments': 'GLenum target, GLenum pname, GLint* params', },
589 { 'return_type': 'void',
590 'names': ['glGetQueryivARB', 'glGetQueryivEXT'],
591 'arguments': 'GLenum target, GLenum pname, GLint* params', },
592 { 'return_type': 'void',
593 'names': ['glGetQueryObjecti64v'],
594 'arguments': 'GLuint id, GLenum pname, GLint64* params', },
595 { 'return_type': 'void',
596 'versions': [{ 'name': 'glGetQueryObjectiv',
597 'gl_versions': ['gl3', 'gl4', 'es3'] }],
598 'arguments': 'GLuint id, GLenum pname, GLint* params', },
599 { 'return_type': 'void',
600 'names': ['glGetQueryObjectivARB', 'glGetQueryObjectivEXT'],
601 'arguments': 'GLuint id, GLenum pname, GLint* params', },
602 { 'return_type': 'void',
603 'names': ['glGetQueryObjectui64v', 'glGetQueryObjectui64vEXT'],
604 'arguments': 'GLuint id, GLenum pname, GLuint64* params', },
605 { 'return_type': 'void',
606 'versions': [{ 'name': 'glGetQueryObjectuiv',
607 'gl_versions': ['gl3', 'gl4', 'es3'] }],
608 'arguments': 'GLuint id, GLenum pname, GLuint* params', },
609 { 'return_type': 'void',
610 'names': ['glGetQueryObjectuivARB', 'glGetQueryObjectuivEXT'],
611 'arguments': 'GLuint id, GLenum pname, GLuint* params', },
612 { 'return_type': 'void',
613 'names': ['glGetRenderbufferParameterivEXT', 'glGetRenderbufferParameteriv'],
614 'arguments': 'GLenum target, GLenum pname, GLint* params', },
615 { 'return_type': 'void',
616 'versions': [{ 'name': 'glGetSamplerParameterfv',
617 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.2 or higher.
618 'arguments': 'GLuint sampler, GLenum pname, GLfloat* params', },
619 { 'return_type': 'void',
620 'versions': [{ 'name': 'glGetSamplerParameteriv',
621 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.2 or higher.
622 'arguments': 'GLuint sampler, GLenum pname, GLint* params', },
623 { 'return_type': 'void',
624 'names': ['glGetShaderInfoLog'],
626 'GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog', },
627 { 'return_type': 'void',
628 'names': ['glGetShaderiv'],
629 'arguments': 'GLuint shader, GLenum pname, GLint* params', },
630 { 'return_type': 'void',
631 'names': ['glGetShaderPrecisionFormat'],
632 'arguments': 'GLenum shadertype, GLenum precisiontype, '
633 'GLint* range, GLint* precision', },
634 { 'return_type': 'void',
635 'names': ['glGetShaderSource'],
637 'GLuint shader, GLsizei bufsize, GLsizei* length, char* source', },
638 { 'return_type': 'const GLubyte*',
639 'names': ['glGetString'],
640 'arguments': 'GLenum name', },
641 { 'return_type': 'void',
642 'names': ['glGetSynciv'],
644 'GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length,'
646 { 'return_type': 'void',
647 'names': ['glGetTexLevelParameterfv'],
648 'arguments': 'GLenum target, GLint level, GLenum pname, GLfloat* params', },
649 { 'return_type': 'void',
650 'names': ['glGetTexLevelParameteriv'],
651 'arguments': 'GLenum target, GLint level, GLenum pname, GLint* params', },
652 { 'return_type': 'void',
653 'names': ['glGetTexParameterfv'],
654 'arguments': 'GLenum target, GLenum pname, GLfloat* params', },
655 { 'return_type': 'void',
656 'names': ['glGetTexParameteriv'],
657 'arguments': 'GLenum target, GLenum pname, GLint* params', },
658 { 'return_type': 'void',
659 'versions': [{ 'name': 'glGetTransformFeedbackVarying',
660 'gl_versions': ['gl3', 'gl4', 'es3'] }],
661 'arguments': 'GLuint program, GLuint index, GLsizei bufSize, '
662 'GLsizei* length, GLenum* type, char* name', },
663 { 'return_type': 'void',
664 'names': ['glGetTranslatedShaderSourceANGLE'],
666 'GLuint shader, GLsizei bufsize, GLsizei* length, char* source', },
667 { 'return_type': 'GLuint',
668 'versions': [{ 'name': 'glGetUniformBlockIndex',
669 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.1 or higher.
670 'arguments': 'GLuint program, const char* uniformBlockName', },
671 { 'return_type': 'void',
672 'names': ['glGetUniformfv'],
673 'arguments': 'GLuint program, GLint location, GLfloat* params', },
674 { 'return_type': 'void',
675 'versions': [{ 'name': 'glGetUniformIndices',
676 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.1 or higher.
677 'arguments': 'GLuint program, GLsizei uniformCount, '
678 'const char* const* uniformNames, GLuint* uniformIndices', },
679 { 'return_type': 'void',
680 'names': ['glGetUniformiv'],
681 'arguments': 'GLuint program, GLint location, GLint* params', },
682 { 'return_type': 'GLint',
683 'names': ['glGetUniformLocation'],
684 'arguments': 'GLuint program, const char* name', },
685 { 'return_type': 'void',
686 'names': ['glGetVertexAttribfv'],
687 'arguments': 'GLuint index, GLenum pname, GLfloat* params', },
688 { 'return_type': 'void',
689 'names': ['glGetVertexAttribiv'],
690 'arguments': 'GLuint index, GLenum pname, GLint* params', },
691 { 'return_type': 'void',
692 'names': ['glGetVertexAttribPointerv'],
693 'arguments': 'GLuint index, GLenum pname, void** pointer', },
694 { 'return_type': 'void',
696 'arguments': 'GLenum target, GLenum mode', },
697 { 'return_type': 'void',
698 'names': ['glInsertEventMarkerEXT'],
699 'arguments': 'GLsizei length, const char* marker', },
700 { 'return_type': 'void',
701 'versions': [{ 'name': 'glInvalidateSubFramebuffer',
702 'gl_versions': ['gl4', 'es3'] }], # GL 4.3 or higher.
704 'GLenum target, GLsizei numAttachments, const GLenum* attachments, '
705 'GLint x, GLint y, GLint width, GLint height', },
706 { 'return_type': 'GLboolean',
707 'names': ['glIsBuffer'],
708 'arguments': 'GLuint buffer', },
709 { 'return_type': 'GLboolean',
710 'names': ['glIsEnabled'],
711 'arguments': 'GLenum cap', },
712 { 'return_type': 'GLboolean',
713 'known_as': 'glIsFenceAPPLE',
714 'versions': [{ 'name': 'glIsFenceAPPLE',
715 'extensions': ['GL_APPLE_fence'] }],
716 'arguments': 'GLuint fence', },
717 { 'return_type': 'GLboolean',
718 'names': ['glIsFenceNV'],
719 'arguments': 'GLuint fence', },
720 { 'return_type': 'GLboolean',
721 'names': ['glIsFramebufferEXT', 'glIsFramebuffer'],
722 'arguments': 'GLuint framebuffer', },
723 { 'return_type': 'GLboolean',
724 'names': ['glIsProgram'],
725 'arguments': 'GLuint program', },
726 { 'return_type': 'GLboolean',
727 'versions': [{ 'name': 'glIsQuery',
728 'gl_versions': ['gl3', 'gl4', 'es3'] }],
729 'arguments': 'GLuint query', },
730 { 'return_type': 'GLboolean',
731 'names': ['glIsQueryARB', 'glIsQueryEXT'],
732 'arguments': 'GLuint query', },
733 { 'return_type': 'GLboolean',
734 'names': ['glIsRenderbufferEXT', 'glIsRenderbuffer'],
735 'arguments': 'GLuint renderbuffer', },
736 { 'return_type': 'GLboolean',
737 'versions': [{ 'name': 'glIsSampler',
738 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.2 or higher.
739 'arguments': 'GLuint sampler', },
740 { 'return_type': 'GLboolean',
741 'names': ['glIsShader'],
742 'arguments': 'GLuint shader', },
743 { 'return_type': 'GLboolean',
744 'names': ['glIsSync'],
745 'arguments': 'GLsync sync', },
746 { 'return_type': 'GLboolean',
747 'names': ['glIsTexture'],
748 'arguments': 'GLuint texture', },
749 { 'return_type': 'GLboolean',
750 'versions': [{ 'name': 'glIsTransformFeedback',
751 'gl_versions': ['gl4', 'es3'] }],
752 'arguments': 'GLuint id', },
753 { 'return_type': 'GLboolean',
754 'known_as': 'glIsVertexArrayOES',
755 'versions': [{ 'name': 'glIsVertexArray',
756 'gl_versions': ['gl3', 'gl4', 'es3'] },
757 { 'name': 'glIsVertexArray',
758 'extensions': ['GL_ARB_vertex_array_object'] },
759 { 'name': 'glIsVertexArrayOES' },
760 { 'name': 'glIsVertexArrayAPPLE',
761 'extensions': ['GL_APPLE_vertex_array_object'] }],
762 'arguments': 'GLuint array' },
763 { 'return_type': 'void',
764 'names': ['glLineWidth'],
765 'arguments': 'GLfloat width', },
766 { 'return_type': 'void',
767 'names': ['glLinkProgram'],
768 'arguments': 'GLuint program', },
769 { 'return_type': 'void*',
770 'known_as': 'glMapBuffer',
771 'names': ['glMapBufferOES', 'glMapBuffer'],
772 'arguments': 'GLenum target, GLenum access', },
773 { 'return_type': 'void*',
774 'known_as': 'glMapBufferRange',
775 'versions': [{ 'name': 'glMapBufferRange',
776 'gl_versions': ['gl3', 'gl4', 'es3'] },
777 { 'name': 'glMapBufferRange',
778 'extensions': ['GL_ARB_map_buffer_range'] },
779 { 'name': 'glMapBufferRangeEXT',
780 'extensions': ['GL_EXT_map_buffer_range'] }],
782 'GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access', },
783 { 'return_type': 'void',
784 'known_as': 'glMatrixLoadfEXT',
785 'versions': [{ 'name': 'glMatrixLoadfEXT',
786 'gl_versions': ['gl4'],
787 'extensions': ['GL_EXT_direct_state_access'] },
788 { 'name': 'glMatrixLoadfEXT',
789 'gl_versions': ['es3'],
790 'extensions': ['GL_NV_path_rendering'] }],
791 'arguments': 'GLenum matrixMode, const GLfloat* m' },
792 { 'return_type': 'void',
793 'known_as': 'glMatrixLoadIdentityEXT',
794 'versions': [{ 'name': 'glMatrixLoadIdentityEXT',
795 'gl_versions': ['gl4'],
796 'extensions': ['GL_EXT_direct_state_access'] },
797 { 'name': 'glMatrixLoadIdentityEXT',
798 'gl_versions': ['es3'],
799 'extensions': ['GL_NV_path_rendering'] }],
800 'arguments': 'GLenum matrixMode' },
801 { 'return_type': 'void',
802 'versions': [{ 'name': 'glPauseTransformFeedback',
803 'gl_versions': ['gl4', 'es3'] }],
804 'arguments': 'void', },
805 { 'return_type': 'void',
806 'names': ['glPixelStorei'],
807 'arguments': 'GLenum pname, GLint param', },
808 { 'return_type': 'void',
809 'names': ['glPointParameteri'],
810 'arguments': 'GLenum pname, GLint param', },
811 { 'return_type': 'void',
812 'names': ['glPolygonOffset'],
813 'arguments': 'GLfloat factor, GLfloat units', },
814 { 'return_type': 'void',
815 'names': ['glPopGroupMarkerEXT'],
816 'arguments': 'void', },
817 { 'return_type': 'void',
818 'known_as': 'glProgramBinary',
819 'versions': [{ 'name': 'glProgramBinaryOES' },
820 { 'name': 'glProgramBinary',
821 'extensions': ['GL_ARB_get_program_binary'] },
822 { 'name': 'glProgramBinary' }],
823 'arguments': 'GLuint program, GLenum binaryFormat, '
824 'const GLvoid* binary, GLsizei length' },
825 { 'return_type': 'void',
826 'versions': [{ 'name': 'glProgramParameteri',
827 'extensions': ['GL_ARB_get_program_binary'] },
828 { 'name': 'glProgramParameteri' }],
829 'arguments': 'GLuint program, GLenum pname, GLint value' },
830 { 'return_type': 'void',
831 'names': ['glPushGroupMarkerEXT'],
832 'arguments': 'GLsizei length, const char* marker', },
833 { 'return_type': 'void',
834 'names': ['glQueryCounter', 'glQueryCounterEXT'],
835 'arguments': 'GLuint id, GLenum target', },
836 { 'return_type': 'void',
837 'names': ['glReadBuffer'],
838 'arguments': 'GLenum src', },
839 { 'return_type': 'void',
840 'names': ['glReadPixels'],
842 'GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, '
843 'GLenum type, void* pixels', },
844 { 'return_type': 'void',
845 'names': ['glReleaseShaderCompiler'],
846 'arguments': 'void', },
847 # Multisampling API is different in different GL versions, some require an
848 # explicit resolve step for renderbuffers and/or FBO texture attachments and
849 # some do not. Multiple alternatives might be present in a single
850 # implementation, which require different use of the API and may have
851 # different performance (explicit resolve performing worse, for example).
852 # So even though the function signature is the same across versions, we split
853 # their definitions so that the function to use can be chosen correctly at a
855 # TODO(oetuaho@nvidia.com): Some of these might still be possible to combine.
856 # This could also fix weirdness in the mock bindings that's caused by the same
857 # function name appearing multiple times.
858 # This is the ES3 function, which requires explicit resolve:
859 { 'return_type': 'void',
860 'names': ['glRenderbufferStorageEXT', 'glRenderbufferStorage'],
862 'GLenum target, GLenum internalformat, GLsizei width, GLsizei height', },
863 { 'return_type': 'void',
864 'names': ['glRenderbufferStorageMultisample'],
865 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, '
866 'GLsizei width, GLsizei height', },
867 { 'return_type': 'void',
868 'names': ['glRenderbufferStorageMultisampleANGLE',
869 'glRenderbufferStorageMultisample'],
870 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, '
871 'GLsizei width, GLsizei height', },
872 # In desktop GL, EXT and core versions both have an explicit resolve step,
873 # though desktop core GL implicitly resolves when drawing to a window.
874 # TODO(oetuaho@nvidia.com): Right now this function also doubles as ES2 EXT
875 # function, which has implicit resolve, and for which the fallback is wrong.
877 { 'return_type': 'void',
878 'names': ['glRenderbufferStorageMultisampleEXT',
879 'glRenderbufferStorageMultisample'],
880 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, '
881 'GLsizei width, GLsizei height', },
882 { 'return_type': 'void',
883 'names': ['glRenderbufferStorageMultisampleIMG'],
884 'arguments': 'GLenum target, GLsizei samples, GLenum internalformat, '
885 'GLsizei width, GLsizei height', },
886 { 'return_type': 'void',
887 'versions': [{ 'name': 'glResumeTransformFeedback',
888 'gl_versions': ['gl4', 'es3'] }],
889 'arguments': 'void', },
890 { 'return_type': 'void',
891 'names': ['glSampleCoverage'],
892 'arguments': 'GLclampf value, GLboolean invert', },
893 { 'return_type': 'void',
894 'versions': [{ 'name': 'glSamplerParameterf',
895 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.2 or higher.
896 'arguments': 'GLuint sampler, GLenum pname, GLfloat param', },
897 { 'return_type': 'void',
898 'versions': [{ 'name': 'glSamplerParameterfv',
899 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.2 or higher.
900 'arguments': 'GLuint sampler, GLenum pname, const GLfloat* params', },
901 { 'return_type': 'void',
902 'versions': [{ 'name': 'glSamplerParameteri',
903 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.2 or higher.
904 'arguments': 'GLuint sampler, GLenum pname, GLint param', },
905 { 'return_type': 'void',
906 'versions': [{ 'name': 'glSamplerParameteriv',
907 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.2 or higher.
908 'arguments': 'GLuint sampler, GLenum pname, const GLint* params', },
909 { 'return_type': 'void',
910 'names': ['glScissor'],
911 'arguments': 'GLint x, GLint y, GLsizei width, GLsizei height', },
912 { 'return_type': 'void',
913 'known_as': 'glSetFenceAPPLE',
914 'versions': [{ 'name': 'glSetFenceAPPLE',
915 'extensions': ['GL_APPLE_fence'] }],
916 'arguments': 'GLuint fence', },
917 { 'return_type': 'void',
918 'names': ['glSetFenceNV'],
919 'arguments': 'GLuint fence, GLenum condition', },
920 { 'return_type': 'void',
921 'names': ['glShaderBinary'],
922 'arguments': 'GLsizei n, const GLuint* shaders, GLenum binaryformat, '
923 'const void* binary, GLsizei length', },
924 { 'return_type': 'void',
925 'names': ['glShaderSource'],
926 'arguments': 'GLuint shader, GLsizei count, const char* const* str, '
927 'const GLint* length',
929 GL_SERVICE_LOG_CODE_BLOCK({
930 for (GLsizei ii = 0; ii < count; ++ii) {
932 if (length && length[ii] >= 0) {
933 std::string source(str[ii], length[ii]);
934 GL_SERVICE_LOG(" " << ii << ": ---\\n" << source << "\\n---");
936 GL_SERVICE_LOG(" " << ii << ": ---\\n" << str[ii] << "\\n---");
939 GL_SERVICE_LOG(" " << ii << ": NULL");
944 { 'return_type': 'void',
945 'names': ['glStencilFunc'],
946 'arguments': 'GLenum func, GLint ref, GLuint mask', },
947 { 'return_type': 'void',
948 'names': ['glStencilFuncSeparate'],
949 'arguments': 'GLenum face, GLenum func, GLint ref, GLuint mask', },
950 { 'return_type': 'void',
951 'names': ['glStencilMask'],
952 'arguments': 'GLuint mask', },
953 { 'return_type': 'void',
954 'names': ['glStencilMaskSeparate'],
955 'arguments': 'GLenum face, GLuint mask', },
956 { 'return_type': 'void',
957 'names': ['glStencilOp'],
958 'arguments': 'GLenum fail, GLenum zfail, GLenum zpass', },
959 { 'return_type': 'void',
960 'names': ['glStencilOpSeparate'],
961 'arguments': 'GLenum face, GLenum fail, GLenum zfail, GLenum zpass', },
962 { 'return_type': 'GLboolean',
963 'known_as': 'glTestFenceAPPLE',
964 'versions': [{ 'name': 'glTestFenceAPPLE',
965 'extensions': ['GL_APPLE_fence'] }],
966 'arguments': 'GLuint fence', },
967 { 'return_type': 'GLboolean',
968 'names': ['glTestFenceNV'],
969 'arguments': 'GLuint fence', },
970 { 'return_type': 'void',
971 'names': ['glTexImage2D'],
973 'GLenum target, GLint level, GLint internalformat, GLsizei width, '
974 'GLsizei height, GLint border, GLenum format, GLenum type, '
975 'const void* pixels', },
976 { 'return_type': 'void',
977 'versions': [{ 'name': 'glTexImage3D',
978 'gl_versions': ['gl3', 'gl4', 'es3'] }],
980 'GLenum target, GLint level, GLint internalformat, GLsizei width, '
981 'GLsizei height, GLsizei depth, GLint border, GLenum format, '
982 'GLenum type, const void* pixels', },
983 { 'return_type': 'void',
984 'names': ['glTexParameterf'],
985 'arguments': 'GLenum target, GLenum pname, GLfloat param', },
986 { 'return_type': 'void',
987 'names': ['glTexParameterfv'],
988 'arguments': 'GLenum target, GLenum pname, const GLfloat* params', },
989 { 'return_type': 'void',
990 'names': ['glTexParameteri'],
991 'arguments': 'GLenum target, GLenum pname, GLint param', },
992 { 'return_type': 'void',
993 'names': ['glTexParameteriv'],
994 'arguments': 'GLenum target, GLenum pname, const GLint* params', },
995 { 'return_type': 'void',
996 'known_as': 'glTexStorage2DEXT',
997 'versions': [{ 'name': 'glTexStorage2D',
998 'gl_versions': ['es3'] },
999 { 'name': 'glTexStorage2D',
1000 'extensions': ['GL_ARB_texture_storage'] },
1001 { 'name': 'glTexStorage2DEXT',
1002 'extensions': ['GL_EXT_texture_storage'] }],
1003 'arguments': 'GLenum target, GLsizei levels, GLenum internalformat, '
1004 'GLsizei width, GLsizei height', },
1005 { 'return_type': 'void',
1006 'versions': [{ 'name': 'glTexStorage3D',
1007 'gl_versions': ['gl4', 'es3'] }], # GL 4.2 or higher.
1008 'arguments': 'GLenum target, GLsizei levels, GLenum internalformat, '
1009 'GLsizei width, GLsizei height, GLsizei depth', },
1010 { 'return_type': 'void',
1011 'names': ['glTexSubImage2D'],
1013 'GLenum target, GLint level, GLint xoffset, GLint yoffset, '
1014 'GLsizei width, GLsizei height, GLenum format, GLenum type, '
1015 'const void* pixels', },
1016 # TODO(zmo): wait for MOCK_METHOD11.
1017 # { 'return_type': 'void',
1018 # 'versions': [{ 'name': 'glTexSubImage3D',
1019 # 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1021 # 'GLenum target, GLint level, GLint xoffset, GLint yoffset, '
1022 # 'GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, '
1023 # 'GLenum format, GLenum type, const void* pixels', },
1024 { 'return_type': 'void',
1025 'versions': [{ 'name': 'glTransformFeedbackVaryings',
1026 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1027 'arguments': 'GLuint program, GLsizei count, const char* const* varyings, '
1028 'GLenum bufferMode', },
1029 { 'return_type': 'void',
1030 'names': ['glUniform1f'],
1031 'arguments': 'GLint location, GLfloat x', },
1032 { 'return_type': 'void',
1033 'names': ['glUniform1fv'],
1034 'arguments': 'GLint location, GLsizei count, const GLfloat* v', },
1035 { 'return_type': 'void',
1036 'names': ['glUniform1i'],
1037 'arguments': 'GLint location, GLint x', },
1038 { 'return_type': 'void',
1039 'names': ['glUniform1iv'],
1040 'arguments': 'GLint location, GLsizei count, const GLint* v', },
1041 { 'return_type': 'void',
1042 'versions': [{ 'name': 'glUniform1ui',
1043 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1044 'arguments': 'GLint location, GLuint v0', },
1045 { 'return_type': 'void',
1046 'versions': [{ 'name': 'glUniform1uiv',
1047 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1048 'arguments': 'GLint location, GLsizei count, const GLuint* v', },
1049 { 'return_type': 'void',
1050 'names': ['glUniform2f'],
1051 'arguments': 'GLint location, GLfloat x, GLfloat y', },
1052 { 'return_type': 'void',
1053 'names': ['glUniform2fv'],
1054 'arguments': 'GLint location, GLsizei count, const GLfloat* v', },
1055 { 'return_type': 'void',
1056 'names': ['glUniform2i'],
1057 'arguments': 'GLint location, GLint x, GLint y', },
1058 { 'return_type': 'void',
1059 'names': ['glUniform2iv'],
1060 'arguments': 'GLint location, GLsizei count, const GLint* v', },
1061 { 'return_type': 'void',
1062 'versions': [{ 'name': 'glUniform2ui',
1063 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1064 'arguments': 'GLint location, GLuint v0, GLuint v1', },
1065 { 'return_type': 'void',
1066 'versions': [{ 'name': 'glUniform2uiv',
1067 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1068 'arguments': 'GLint location, GLsizei count, const GLuint* v', },
1069 { 'return_type': 'void',
1070 'names': ['glUniform3f'],
1071 'arguments': 'GLint location, GLfloat x, GLfloat y, GLfloat z', },
1072 { 'return_type': 'void',
1073 'names': ['glUniform3fv'],
1074 'arguments': 'GLint location, GLsizei count, const GLfloat* v', },
1075 { 'return_type': 'void',
1076 'names': ['glUniform3i'],
1077 'arguments': 'GLint location, GLint x, GLint y, GLint z', },
1078 { 'return_type': 'void',
1079 'names': ['glUniform3iv'],
1080 'arguments': 'GLint location, GLsizei count, const GLint* v', },
1081 { 'return_type': 'void',
1082 'versions': [{ 'name': 'glUniform3ui',
1083 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1084 'arguments': 'GLint location, GLuint v0, GLuint v1, GLuint v2', },
1085 { 'return_type': 'void',
1086 'versions': [{ 'name': 'glUniform3uiv',
1087 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1088 'arguments': 'GLint location, GLsizei count, const GLuint* v', },
1089 { 'return_type': 'void',
1090 'names': ['glUniform4f'],
1091 'arguments': 'GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w', },
1092 { 'return_type': 'void',
1093 'names': ['glUniform4fv'],
1094 'arguments': 'GLint location, GLsizei count, const GLfloat* v', },
1095 { 'return_type': 'void',
1096 'names': ['glUniform4i'],
1097 'arguments': 'GLint location, GLint x, GLint y, GLint z, GLint w', },
1098 { 'return_type': 'void',
1099 'names': ['glUniform4iv'],
1100 'arguments': 'GLint location, GLsizei count, const GLint* v', },
1101 { 'return_type': 'void',
1102 'versions': [{ 'name': 'glUniform4ui',
1103 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1104 'arguments': 'GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3', },
1105 { 'return_type': 'void',
1106 'versions': [{ 'name': 'glUniform4uiv',
1107 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1108 'arguments': 'GLint location, GLsizei count, const GLuint* v', },
1109 { 'return_type': 'void',
1110 'versions': [{ 'name': 'glUniformBlockBinding',
1111 'gl_versions': ['gl3', 'gl4', 'es3'] }], # GL 3.1 or higher.
1112 'arguments': 'GLuint program, GLuint uniformBlockIndex, '
1113 'GLuint uniformBlockBinding', },
1114 { 'return_type': 'void',
1115 'names': ['glUniformMatrix2fv'],
1116 'arguments': 'GLint location, GLsizei count, '
1117 'GLboolean transpose, const GLfloat* value', },
1118 { 'return_type': 'void',
1119 'versions': [{ 'name': 'glUniformMatrix2x3fv',
1120 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1121 'arguments': 'GLint location, GLsizei count, '
1122 'GLboolean transpose, const GLfloat* value', },
1123 { 'return_type': 'void',
1124 'versions': [{ 'name': 'glUniformMatrix2x4fv',
1125 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1126 'arguments': 'GLint location, GLsizei count, '
1127 'GLboolean transpose, const GLfloat* value', },
1128 { 'return_type': 'void',
1129 'names': ['glUniformMatrix3fv'],
1130 'arguments': 'GLint location, GLsizei count, '
1131 'GLboolean transpose, const GLfloat* value', },
1132 { 'return_type': 'void',
1133 'versions': [{ 'name': 'glUniformMatrix3x2fv',
1134 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1135 'arguments': 'GLint location, GLsizei count, '
1136 'GLboolean transpose, const GLfloat* value', },
1137 { 'return_type': 'void',
1138 'versions': [{ 'name': 'glUniformMatrix3x4fv',
1139 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1140 'arguments': 'GLint location, GLsizei count, '
1141 'GLboolean transpose, const GLfloat* value', },
1142 { 'return_type': 'void',
1143 'names': ['glUniformMatrix4fv'],
1144 'arguments': 'GLint location, GLsizei count, '
1145 'GLboolean transpose, const GLfloat* value', },
1146 { 'return_type': 'void',
1147 'versions': [{ 'name': 'glUniformMatrix4x2fv',
1148 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1149 'arguments': 'GLint location, GLsizei count, '
1150 'GLboolean transpose, const GLfloat* value', },
1151 { 'return_type': 'void',
1152 'versions': [{ 'name': 'glUniformMatrix4x3fv',
1153 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1154 'arguments': 'GLint location, GLsizei count, '
1155 'GLboolean transpose, const GLfloat* value', },
1156 { 'return_type': 'GLboolean',
1157 'known_as': 'glUnmapBuffer',
1158 'names': ['glUnmapBufferOES', 'glUnmapBuffer'],
1159 'arguments': 'GLenum target', },
1160 { 'return_type': 'void',
1161 'names': ['glUseProgram'],
1162 'arguments': 'GLuint program', },
1163 { 'return_type': 'void',
1164 'names': ['glValidateProgram'],
1165 'arguments': 'GLuint program', },
1166 { 'return_type': 'void',
1167 'names': ['glVertexAttrib1f'],
1168 'arguments': 'GLuint indx, GLfloat x', },
1169 { 'return_type': 'void',
1170 'names': ['glVertexAttrib1fv'],
1171 'arguments': 'GLuint indx, const GLfloat* values', },
1172 { 'return_type': 'void',
1173 'names': ['glVertexAttrib2f'],
1174 'arguments': 'GLuint indx, GLfloat x, GLfloat y', },
1175 { 'return_type': 'void',
1176 'names': ['glVertexAttrib2fv'],
1177 'arguments': 'GLuint indx, const GLfloat* values', },
1178 { 'return_type': 'void',
1179 'names': ['glVertexAttrib3f'],
1180 'arguments': 'GLuint indx, GLfloat x, GLfloat y, GLfloat z', },
1181 { 'return_type': 'void',
1182 'names': ['glVertexAttrib3fv'],
1183 'arguments': 'GLuint indx, const GLfloat* values', },
1184 { 'return_type': 'void',
1185 'names': ['glVertexAttrib4f'],
1186 'arguments': 'GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w', },
1187 { 'return_type': 'void',
1188 'names': ['glVertexAttrib4fv'],
1189 'arguments': 'GLuint indx, const GLfloat* values', },
1190 { 'return_type': 'void',
1191 'known_as': 'glVertexAttribDivisorANGLE',
1192 'names': ['glVertexAttribDivisorARB', 'glVertexAttribDivisorANGLE',
1193 'glVertexAttribDivisor'],
1195 'GLuint index, GLuint divisor', },
1196 { 'return_type': 'void',
1197 'versions': [{ 'name': 'glVertexAttribI4i',
1198 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1199 'arguments': 'GLuint indx, GLint x, GLint y, GLint z, GLint w', },
1200 { 'return_type': 'void',
1201 'versions': [{ 'name': 'glVertexAttribI4iv',
1202 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1203 'arguments': 'GLuint indx, const GLint* values', },
1204 { 'return_type': 'void',
1205 'versions': [{ 'name': 'glVertexAttribI4ui',
1206 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1207 'arguments': 'GLuint indx, GLuint x, GLuint y, GLuint z, GLuint w', },
1208 { 'return_type': 'void',
1209 'versions': [{ 'name': 'glVertexAttribI4uiv',
1210 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1211 'arguments': 'GLuint indx, const GLuint* values', },
1212 { 'return_type': 'void',
1213 'versions': [{ 'name': 'glVertexAttribIPointer',
1214 'gl_versions': ['gl3', 'gl4', 'es3'] }],
1215 'arguments': 'GLuint indx, GLint size, GLenum type, GLsizei stride, '
1216 'const void* ptr', },
1217 { 'return_type': 'void',
1218 'names': ['glVertexAttribPointer'],
1219 'arguments': 'GLuint indx, GLint size, GLenum type, GLboolean normalized, '
1220 'GLsizei stride, const void* ptr', },
1221 { 'return_type': 'void',
1222 'names': ['glViewport'],
1223 'arguments': 'GLint x, GLint y, GLsizei width, GLsizei height', },
1224 { 'return_type': 'GLenum',
1225 'names': ['glWaitSync'],
1227 'GLsync sync, GLbitfield flags, GLuint64 timeout', },
1230 OSMESA_FUNCTIONS
= [
1231 { 'return_type': 'void',
1232 'names': ['OSMesaColorClamp'],
1233 'arguments': 'GLboolean enable', },
1234 { 'return_type': 'OSMesaContext',
1235 'names': ['OSMesaCreateContext'],
1236 'arguments': 'GLenum format, OSMesaContext sharelist', },
1237 { 'return_type': 'OSMesaContext',
1238 'names': ['OSMesaCreateContextExt'],
1240 'GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, '
1241 'OSMesaContext sharelist', },
1242 { 'return_type': 'void',
1243 'names': ['OSMesaDestroyContext'],
1244 'arguments': 'OSMesaContext ctx', },
1245 { 'return_type': 'GLboolean',
1246 'names': ['OSMesaGetColorBuffer'],
1247 'arguments': 'OSMesaContext c, GLint* width, GLint* height, GLint* format, '
1249 { 'return_type': 'OSMesaContext',
1250 'names': ['OSMesaGetCurrentContext'],
1251 'arguments': 'void', },
1252 { 'return_type': 'GLboolean',
1253 'names': ['OSMesaGetDepthBuffer'],
1255 'OSMesaContext c, GLint* width, GLint* height, GLint* bytesPerValue, '
1257 { 'return_type': 'void',
1258 'names': ['OSMesaGetIntegerv'],
1259 'arguments': 'GLint pname, GLint* value', },
1260 { 'return_type': 'OSMESAproc',
1261 'names': ['OSMesaGetProcAddress'],
1262 'arguments': 'const char* funcName', },
1263 { 'return_type': 'GLboolean',
1264 'names': ['OSMesaMakeCurrent'],
1265 'arguments': 'OSMesaContext ctx, void* buffer, GLenum type, GLsizei width, '
1266 'GLsizei height', },
1267 { 'return_type': 'void',
1268 'names': ['OSMesaPixelStore'],
1269 'arguments': 'GLint pname, GLint value', },
1273 { 'return_type': 'EGLBoolean',
1274 'names': ['eglBindAPI'],
1275 'arguments': 'EGLenum api', },
1276 { 'return_type': 'EGLBoolean',
1277 'names': ['eglBindTexImage'],
1278 'arguments': 'EGLDisplay dpy, EGLSurface surface, EGLint buffer', },
1279 { 'return_type': 'EGLBoolean',
1280 'names': ['eglChooseConfig'],
1281 'arguments': 'EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, '
1282 'EGLint config_size, EGLint* num_config', },
1283 { 'return_type': 'EGLint',
1284 'versions': [{ 'name': 'eglClientWaitSyncKHR',
1285 'extensions': ['EGL_KHR_fence_sync'] }],
1286 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, '
1287 'EGLTimeKHR timeout' },
1288 { 'return_type': 'EGLBoolean',
1289 'names': ['eglCopyBuffers'],
1291 'EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target', },
1292 { 'return_type': 'EGLContext',
1293 'names': ['eglCreateContext'],
1294 'arguments': 'EGLDisplay dpy, EGLConfig config, EGLContext share_context, '
1295 'const EGLint* attrib_list', },
1296 { 'return_type': 'EGLImageKHR',
1297 'versions': [{ 'name': 'eglCreateImageKHR',
1299 ['EGL_KHR_image_base', 'EGL_KHR_gl_texture_2D_image'] }],
1301 'EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, '
1302 'const EGLint* attrib_list' },
1303 { 'return_type': 'EGLSurface',
1304 'names': ['eglCreatePbufferFromClientBuffer'],
1306 'EGLDisplay dpy, EGLenum buftype, void* buffer, EGLConfig config, '
1307 'const EGLint* attrib_list', },
1308 { 'return_type': 'EGLSurface',
1309 'names': ['eglCreatePbufferSurface'],
1310 'arguments': 'EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list', },
1311 { 'return_type': 'EGLSurface',
1312 'names': ['eglCreatePixmapSurface'],
1313 'arguments': 'EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, '
1314 'const EGLint* attrib_list', },
1315 { 'return_type': 'EGLSyncKHR',
1316 'versions': [{ 'name': 'eglCreateSyncKHR',
1317 'extensions': ['EGL_KHR_fence_sync'] }],
1318 'arguments': 'EGLDisplay dpy, EGLenum type, const EGLint* attrib_list' },
1319 { 'return_type': 'EGLSurface',
1320 'names': ['eglCreateWindowSurface'],
1321 'arguments': 'EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, '
1322 'const EGLint* attrib_list', },
1323 { 'return_type': 'EGLBoolean',
1324 'names': ['eglDestroyContext'],
1325 'arguments': 'EGLDisplay dpy, EGLContext ctx', },
1326 { 'return_type': 'EGLBoolean',
1327 'versions': [{ 'name' : 'eglDestroyImageKHR',
1328 'extensions': ['EGL_KHR_image_base'] }],
1329 'arguments': 'EGLDisplay dpy, EGLImageKHR image' },
1330 { 'return_type': 'EGLBoolean',
1331 'names': ['eglDestroySurface'],
1332 'arguments': 'EGLDisplay dpy, EGLSurface surface', },
1333 { 'return_type': 'EGLBoolean',
1334 'versions': [{ 'name': 'eglDestroySyncKHR',
1335 'extensions': ['EGL_KHR_fence_sync'] }],
1336 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync' },
1337 { 'return_type': 'EGLBoolean',
1338 'names': ['eglGetConfigAttrib'],
1340 'EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value', },
1341 { 'return_type': 'EGLBoolean',
1342 'names': ['eglGetConfigs'],
1343 'arguments': 'EGLDisplay dpy, EGLConfig* configs, EGLint config_size, '
1344 'EGLint* num_config', },
1345 { 'return_type': 'EGLContext',
1346 'names': ['eglGetCurrentContext'],
1347 'arguments': 'void', },
1348 { 'return_type': 'EGLDisplay',
1349 'names': ['eglGetCurrentDisplay'],
1350 'arguments': 'void', },
1351 { 'return_type': 'EGLSurface',
1352 'names': ['eglGetCurrentSurface'],
1353 'arguments': 'EGLint readdraw', },
1354 { 'return_type': 'EGLDisplay',
1355 'names': ['eglGetDisplay'],
1356 'arguments': 'EGLNativeDisplayType display_id', },
1357 { 'return_type': 'EGLint',
1358 'names': ['eglGetError'],
1359 'arguments': 'void', },
1360 { 'return_type': 'EGLDisplay',
1361 'known_as': 'eglGetPlatformDisplayEXT',
1362 'versions': [{ 'name': 'eglGetPlatformDisplayEXT',
1363 'extensions': ['EGL_ANGLE_platform_angle'] }],
1364 'arguments': 'EGLenum platform, void* native_display, '
1365 'const EGLint* attrib_list', },
1366 { 'return_type': '__eglMustCastToProperFunctionPointerType',
1367 'names': ['eglGetProcAddress'],
1368 'arguments': 'const char* procname', },
1369 { 'return_type': 'EGLBoolean',
1370 'versions': [{ 'name': 'eglGetSyncAttribKHR',
1371 'extensions': ['EGL_KHR_fence_sync'] }],
1372 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, '
1374 { 'return_type': 'EGLBoolean',
1375 'names': ['eglGetSyncValuesCHROMIUM'],
1377 'EGLDisplay dpy, EGLSurface surface, '
1378 'EGLuint64CHROMIUM* ust, EGLuint64CHROMIUM* msc, '
1379 'EGLuint64CHROMIUM* sbc', },
1380 { 'return_type': 'EGLBoolean',
1381 'names': ['eglInitialize'],
1382 'arguments': 'EGLDisplay dpy, EGLint* major, EGLint* minor', },
1383 { 'return_type': 'EGLBoolean',
1384 'names': ['eglMakeCurrent'],
1386 'EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx', },
1387 { 'return_type': 'EGLBoolean',
1388 'names': ['eglPostSubBufferNV'],
1389 'arguments': 'EGLDisplay dpy, EGLSurface surface, '
1390 'EGLint x, EGLint y, EGLint width, EGLint height', },
1391 { 'return_type': 'EGLenum',
1392 'names': ['eglQueryAPI'],
1393 'arguments': 'void', },
1394 { 'return_type': 'EGLBoolean',
1395 'names': ['eglQueryContext'],
1397 'EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value', },
1398 { 'return_type': 'const char*',
1399 'names': ['eglQueryString'],
1400 'arguments': 'EGLDisplay dpy, EGLint name', },
1401 { 'return_type': 'EGLBoolean',
1402 'names': ['eglQuerySurface'],
1404 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value', },
1405 { 'return_type': 'EGLBoolean',
1406 'names': ['eglQuerySurfacePointerANGLE'],
1408 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value', },
1409 { 'return_type': 'EGLBoolean',
1410 'names': ['eglReleaseTexImage'],
1411 'arguments': 'EGLDisplay dpy, EGLSurface surface, EGLint buffer', },
1412 { 'return_type': 'EGLBoolean',
1413 'names': ['eglReleaseThread'],
1414 'arguments': 'void', },
1415 { 'return_type': 'EGLBoolean',
1416 'names': ['eglSurfaceAttrib'],
1418 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value', },
1419 { 'return_type': 'EGLBoolean',
1420 'names': ['eglSwapBuffers'],
1421 'arguments': 'EGLDisplay dpy, EGLSurface surface', },
1422 { 'return_type': 'EGLBoolean',
1423 'names': ['eglSwapInterval'],
1424 'arguments': 'EGLDisplay dpy, EGLint interval', },
1425 { 'return_type': 'EGLBoolean',
1426 'names': ['eglTerminate'],
1427 'arguments': 'EGLDisplay dpy', },
1428 { 'return_type': 'EGLBoolean',
1429 'names': ['eglWaitClient'],
1430 'arguments': 'void', },
1431 { 'return_type': 'EGLBoolean',
1432 'names': ['eglWaitGL'],
1433 'arguments': 'void', },
1434 { 'return_type': 'EGLBoolean',
1435 'names': ['eglWaitNative'],
1436 'arguments': 'EGLint engine', },
1437 { 'return_type': 'EGLint',
1438 'versions': [{ 'name': 'eglWaitSyncKHR',
1439 'extensions': ['EGL_KHR_fence_sync', 'EGL_KHR_wait_sync'] }],
1440 'arguments': 'EGLDisplay dpy, EGLSyncKHR sync, EGLint flags' },
1444 { 'return_type': 'BOOL',
1445 'names': ['wglChoosePixelFormatARB'],
1447 'HDC dc, const int* int_attrib_list, const float* float_attrib_list, '
1448 'UINT max_formats, int* formats, UINT* num_formats', },
1449 { 'return_type': 'BOOL',
1450 'names': ['wglCopyContext'],
1451 'arguments': 'HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask', },
1452 { 'return_type': 'HGLRC',
1453 'names': ['wglCreateContext'],
1454 'arguments': 'HDC hdc', },
1455 { 'return_type': 'HGLRC',
1456 'names': ['wglCreateLayerContext'],
1457 'arguments': 'HDC hdc, int iLayerPlane', },
1458 { 'return_type': 'HPBUFFERARB',
1459 'names': ['wglCreatePbufferARB'],
1460 'arguments': 'HDC hDC, int iPixelFormat, int iWidth, int iHeight, '
1461 'const int* piAttribList', },
1462 { 'return_type': 'BOOL',
1463 'names': ['wglDeleteContext'],
1464 'arguments': 'HGLRC hglrc', },
1465 { 'return_type': 'BOOL',
1466 'names': ['wglDestroyPbufferARB'],
1467 'arguments': 'HPBUFFERARB hPbuffer', },
1468 { 'return_type': 'HGLRC',
1469 'names': ['wglGetCurrentContext'],
1471 { 'return_type': 'HDC',
1472 'names': ['wglGetCurrentDC'],
1474 { 'return_type': 'const char*',
1475 'names': ['wglGetExtensionsStringARB'],
1476 'arguments': 'HDC hDC', },
1477 { 'return_type': 'const char*',
1478 'names': ['wglGetExtensionsStringEXT'],
1480 { 'return_type': 'HDC',
1481 'names': ['wglGetPbufferDCARB'],
1482 'arguments': 'HPBUFFERARB hPbuffer', },
1483 { 'return_type': 'BOOL',
1484 'names': ['wglMakeCurrent'],
1485 'arguments': 'HDC hdc, HGLRC hglrc', },
1486 { 'return_type': 'BOOL',
1487 'names': ['wglQueryPbufferARB'],
1488 'arguments': 'HPBUFFERARB hPbuffer, int iAttribute, int* piValue', },
1489 { 'return_type': 'int',
1490 'names': ['wglReleasePbufferDCARB'],
1491 'arguments': 'HPBUFFERARB hPbuffer, HDC hDC', },
1492 { 'return_type': 'BOOL',
1493 'names': ['wglShareLists'],
1494 'arguments': 'HGLRC hglrc1, HGLRC hglrc2', },
1495 { 'return_type': 'BOOL',
1496 'names': ['wglSwapIntervalEXT'],
1497 'arguments': 'int interval', },
1498 { 'return_type': 'BOOL',
1499 'names': ['wglSwapLayerBuffers'],
1500 'arguments': 'HDC hdc, UINT fuPlanes', },
1504 { 'return_type': 'void',
1505 'names': ['glXBindTexImageEXT'],
1507 'Display* dpy, GLXDrawable drawable, int buffer, int* attribList', },
1508 { 'return_type': 'GLXFBConfig*',
1509 'names': ['glXChooseFBConfig'],
1511 'Display* dpy, int screen, const int* attribList, int* nitems', },
1512 { 'return_type': 'XVisualInfo*',
1513 'names': ['glXChooseVisual'],
1514 'arguments': 'Display* dpy, int screen, int* attribList', },
1515 { 'return_type': 'void',
1516 'names': ['glXCopyContext'],
1518 'Display* dpy, GLXContext src, GLXContext dst, unsigned long mask', },
1519 { 'return_type': 'void',
1520 'names': ['glXCopySubBufferMESA'],
1521 'arguments': 'Display* dpy, GLXDrawable drawable, '
1522 'int x, int y, int width, int height', },
1523 { 'return_type': 'GLXContext',
1524 'names': ['glXCreateContext'],
1526 'Display* dpy, XVisualInfo* vis, GLXContext shareList, int direct', },
1527 { 'return_type': 'GLXContext',
1528 'names': ['glXCreateContextAttribsARB'],
1530 'Display* dpy, GLXFBConfig config, GLXContext share_context, int direct, '
1531 'const int* attrib_list', },
1532 { 'return_type': 'GLXPixmap',
1533 'names': ['glXCreateGLXPixmap'],
1534 'arguments': 'Display* dpy, XVisualInfo* visual, Pixmap pixmap', },
1535 { 'return_type': 'GLXContext',
1536 'names': ['glXCreateNewContext'],
1537 'arguments': 'Display* dpy, GLXFBConfig config, int renderType, '
1538 'GLXContext shareList, int direct', },
1539 { 'return_type': 'GLXPbuffer',
1540 'names': ['glXCreatePbuffer'],
1541 'arguments': 'Display* dpy, GLXFBConfig config, const int* attribList', },
1542 { 'return_type': 'GLXPixmap',
1543 'names': ['glXCreatePixmap'],
1544 'arguments': 'Display* dpy, GLXFBConfig config, '
1545 'Pixmap pixmap, const int* attribList', },
1546 { 'return_type': 'GLXWindow',
1547 'names': ['glXCreateWindow'],
1549 'Display* dpy, GLXFBConfig config, Window win, const int* attribList', },
1550 { 'return_type': 'void',
1551 'names': ['glXDestroyContext'],
1552 'arguments': 'Display* dpy, GLXContext ctx', },
1553 { 'return_type': 'void',
1554 'names': ['glXDestroyGLXPixmap'],
1555 'arguments': 'Display* dpy, GLXPixmap pixmap', },
1556 { 'return_type': 'void',
1557 'names': ['glXDestroyPbuffer'],
1558 'arguments': 'Display* dpy, GLXPbuffer pbuf', },
1559 { 'return_type': 'void',
1560 'names': ['glXDestroyPixmap'],
1561 'arguments': 'Display* dpy, GLXPixmap pixmap', },
1562 { 'return_type': 'void',
1563 'names': ['glXDestroyWindow'],
1564 'arguments': 'Display* dpy, GLXWindow window', },
1565 { 'return_type': 'const char*',
1566 'names': ['glXGetClientString'],
1567 'arguments': 'Display* dpy, int name', },
1568 { 'return_type': 'int',
1569 'names': ['glXGetConfig'],
1570 'arguments': 'Display* dpy, XVisualInfo* visual, int attrib, int* value', },
1571 { 'return_type': 'GLXContext',
1572 'names': ['glXGetCurrentContext'],
1573 'arguments': 'void', },
1574 { 'return_type': 'Display*',
1575 'names': ['glXGetCurrentDisplay'],
1576 'arguments': 'void', },
1577 { 'return_type': 'GLXDrawable',
1578 'names': ['glXGetCurrentDrawable'],
1579 'arguments': 'void', },
1580 { 'return_type': 'GLXDrawable',
1581 'names': ['glXGetCurrentReadDrawable'],
1582 'arguments': 'void', },
1583 { 'return_type': 'int',
1584 'names': ['glXGetFBConfigAttrib'],
1585 'arguments': 'Display* dpy, GLXFBConfig config, int attribute, int* value', },
1586 { 'return_type': 'GLXFBConfig',
1587 'names': ['glXGetFBConfigFromVisualSGIX'],
1588 'arguments': 'Display* dpy, XVisualInfo* visualInfo', },
1589 { 'return_type': 'GLXFBConfig*',
1590 'names': ['glXGetFBConfigs'],
1591 'arguments': 'Display* dpy, int screen, int* nelements', },
1592 { 'return_type': 'bool',
1593 'names': ['glXGetMscRateOML'],
1595 'Display* dpy, GLXDrawable drawable, int32* numerator, '
1596 'int32* denominator' },
1597 { 'return_type': 'void',
1598 'names': ['glXGetSelectedEvent'],
1599 'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long* mask', },
1600 { 'return_type': 'bool',
1601 'names': ['glXGetSyncValuesOML'],
1603 'Display* dpy, GLXDrawable drawable, int64* ust, int64* msc, '
1605 { 'return_type': 'XVisualInfo*',
1606 'names': ['glXGetVisualFromFBConfig'],
1607 'arguments': 'Display* dpy, GLXFBConfig config', },
1608 { 'return_type': 'int',
1609 'names': ['glXIsDirect'],
1610 'arguments': 'Display* dpy, GLXContext ctx', },
1611 { 'return_type': 'int',
1612 'names': ['glXMakeContextCurrent'],
1614 'Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx', },
1615 { 'return_type': 'int',
1616 'names': ['glXMakeCurrent'],
1617 'arguments': 'Display* dpy, GLXDrawable drawable, GLXContext ctx', },
1618 { 'return_type': 'int',
1619 'names': ['glXQueryContext'],
1620 'arguments': 'Display* dpy, GLXContext ctx, int attribute, int* value', },
1621 { 'return_type': 'void',
1622 'names': ['glXQueryDrawable'],
1624 'Display* dpy, GLXDrawable draw, int attribute, unsigned int* value', },
1625 { 'return_type': 'int',
1626 'names': ['glXQueryExtension'],
1627 'arguments': 'Display* dpy, int* errorb, int* event', },
1628 { 'return_type': 'const char*',
1629 'names': ['glXQueryExtensionsString'],
1630 'arguments': 'Display* dpy, int screen', },
1631 { 'return_type': 'const char*',
1632 'names': ['glXQueryServerString'],
1633 'arguments': 'Display* dpy, int screen, int name', },
1634 { 'return_type': 'int',
1635 'names': ['glXQueryVersion'],
1636 'arguments': 'Display* dpy, int* maj, int* min', },
1637 { 'return_type': 'void',
1638 'names': ['glXReleaseTexImageEXT'],
1639 'arguments': 'Display* dpy, GLXDrawable drawable, int buffer', },
1640 { 'return_type': 'void',
1641 'names': ['glXSelectEvent'],
1642 'arguments': 'Display* dpy, GLXDrawable drawable, unsigned long mask', },
1643 { 'return_type': 'void',
1644 'names': ['glXSwapBuffers'],
1645 'arguments': 'Display* dpy, GLXDrawable drawable', },
1646 { 'return_type': 'void',
1647 'names': ['glXSwapIntervalEXT'],
1648 'arguments': 'Display* dpy, GLXDrawable drawable, int interval', },
1649 { 'return_type': 'void',
1650 'names': ['glXSwapIntervalMESA'],
1651 'arguments': 'unsigned int interval', },
1652 { 'return_type': 'void',
1653 'names': ['glXUseXFont'],
1654 'arguments': 'Font font, int first, int count, int list', },
1655 { 'return_type': 'void',
1656 'names': ['glXWaitGL'],
1657 'arguments': 'void', },
1658 { 'return_type': 'int',
1659 'names': ['glXWaitVideoSyncSGI'],
1660 'arguments': 'int divisor, int remainder, unsigned int* count', },
1661 { 'return_type': 'void',
1662 'names': ['glXWaitX'],
1663 'arguments': 'void', },
1667 [GL_FUNCTIONS
, 'gl', [
1670 # Files below are Chromium-specific and shipped with Chromium sources.
1671 'GL/glextchromium.h',
1672 'GLES2/gl2chromium.h',
1673 'GLES2/gl2extchromium.h'
1675 [OSMESA_FUNCTIONS
, 'osmesa', [], []],
1676 [EGL_FUNCTIONS
, 'egl', [
1678 # Files below are Chromium-specific and shipped with Chromium sources.
1679 'EGL/eglextchromium.h',
1682 'EGL_ANGLE_d3d_share_handle_client_buffer',
1683 'EGL_ANGLE_surface_d3d_texture_2d_share_handle',
1686 [WGL_FUNCTIONS
, 'wgl', ['GL/wglext.h'], []],
1687 [GLX_FUNCTIONS
, 'glx', ['GL/glx.h', 'GL/glxext.h'], []],
1691 def GenerateHeader(file, functions
, set_name
, used_extensions
):
1692 """Generates gl_bindings_autogen_x.h"""
1694 # Write file header.
1696 """// Copyright (c) 2012 The Chromium Authors. All rights reserved.
1697 // Use of this source code is governed by a BSD-style license that can be
1698 // found in the LICENSE file.
1700 // This file is automatically generated.
1702 #ifndef UI_GFX_GL_GL_BINDINGS_AUTOGEN_%(name)s_H_
1703 #define UI_GFX_GL_GL_BINDINGS_AUTOGEN_%(name)s_H_
1709 """ % {'name': set_name
.upper()})
1711 # Write typedefs for function pointer types. Always use the GL name for the
1714 for func
in functions
:
1715 file.write('typedef %s (GL_BINDING_CALL *%sProc)(%s);\n' %
1716 (func
['return_type'], func
['known_as'], func
['arguments']))
1718 # Write declarations for booleans indicating which extensions are available.
1720 file.write("struct Extensions%s {\n" % set_name
.upper())
1721 for extension
in sorted(used_extensions
):
1722 file.write(' bool b_%s;\n' % extension
)
1726 # Write Procs struct.
1727 file.write("struct Procs%s {\n" % set_name
.upper())
1728 for func
in functions
:
1729 file.write(' %sProc %sFn;\n' % (func
['known_as'], func
['known_as']))
1735 """class GL_EXPORT %(name)sApi {
1738 virtual ~%(name)sApi();
1740 """ % {'name': set_name
.upper()})
1741 for func
in functions
:
1742 file.write(' virtual %s %sFn(%s) = 0;\n' %
1743 (func
['return_type'], func
['known_as'], func
['arguments']))
1747 file.write( '} // namespace gfx\n')
1749 # Write macros to invoke function pointers. Always use the GL name for the
1752 for func
in functions
:
1753 file.write('#define %s ::gfx::g_current_%s_context->%sFn\n' %
1754 (func
['known_as'], set_name
.lower(), func
['known_as']))
1757 file.write('#endif // UI_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' %
1761 def GenerateAPIHeader(file, functions
, set_name
):
1762 """Generates gl_bindings_api_autogen_x.h"""
1764 # Write file header.
1766 """// Copyright (c) 2012 The Chromium Authors. All rights reserved.
1767 // Use of this source code is governed by a BSD-style license that can be
1768 // found in the LICENSE file.
1770 // This file is automatically generated.
1772 """ % {'name': set_name
.upper()})
1774 # Write API declaration.
1775 for func
in functions
:
1776 file.write(' virtual %s %sFn(%s) override;\n' %
1777 (func
['return_type'], func
['known_as'], func
['arguments']))
1782 def GenerateMockHeader(file, functions
, set_name
):
1783 """Generates gl_mock_autogen_x.h"""
1785 # Write file header.
1787 """// Copyright (c) 2012 The Chromium Authors. All rights reserved.
1788 // Use of this source code is governed by a BSD-style license that can be
1789 // found in the LICENSE file.
1791 // This file is automatically generated.
1793 """ % {'name': set_name
.upper()})
1795 # Write API declaration.
1796 for func
in functions
:
1797 args
= func
['arguments']
1802 arg_count
= func
['arguments'].count(',') + 1
1803 file.write(' MOCK_METHOD%d(%s, %s(%s));\n' %
1804 (arg_count
, func
['known_as'][2:], func
['return_type'], args
))
1809 def GenerateSource(file, functions
, set_name
, used_extensions
):
1810 """Generates gl_bindings_autogen_x.cc"""
1812 # Write file header.
1814 """// Copyright (c) 2011 The Chromium Authors. All rights reserved.
1815 // Use of this source code is governed by a BSD-style license that can be
1816 // found in the LICENSE file.
1818 // This file is automatically generated.
1821 #include "base/debug/trace_event.h"
1822 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
1823 #include "ui/gl/gl_bindings.h"
1824 #include "ui/gl/gl_context.h"
1825 #include "ui/gl/gl_implementation.h"
1826 #include "ui/gl/gl_version_info.h"
1827 #include "ui/gl/gl_%s_api_implementation.h"
1829 using gpu::gles2::GLES2Util;
1832 """ % set_name
.lower())
1835 file.write('static bool g_debugBindingsInitialized;\n')
1836 file.write('Driver%s g_driver_%s;\n' % (set_name
.upper(), set_name
.lower()))
1839 # Write stub functions that take the place of some functions before a context
1840 # is initialized. This is done to provide clear asserts on debug build and to
1841 # avoid crashing in case of a bug on release build.
1843 for func
in functions
:
1844 unique_names
= set([version
['name'] for version
in func
['versions']])
1845 if len(unique_names
) > 1:
1846 file.write('%s %sNotBound(%s) {\n' %
1847 (func
['return_type'], func
['known_as'], func
['arguments']))
1848 file.write(' NOTREACHED();\n')
1849 return_type
= func
['return_type'].lower()
1850 # Returning 0 works for booleans, integers and pointers.
1851 if return_type
!= 'void':
1852 file.write(' return 0;\n')
1855 # Write function to initialize the function pointers that are always the same
1856 # and to initialize bindings where choice of the function depends on the
1857 # extension string or the GL version to point to stub functions.
1859 file.write('void Driver%s::InitializeStaticBindings() {\n' %
1862 def WriteFuncBinding(file, known_as
, version_name
):
1864 ' fn.%sFn = reinterpret_cast<%sProc>(GetGLProcAddress("%s"));\n' %
1865 (known_as
, known_as
, version_name
))
1867 for func
in functions
:
1868 unique_names
= set([version
['name'] for version
in func
['versions']])
1869 if len(unique_names
) == 1:
1870 WriteFuncBinding(file, func
['known_as'], func
['known_as'])
1872 file.write(' fn.%sFn = reinterpret_cast<%sProc>(%sNotBound);\n' %
1873 (func
['known_as'], func
['known_as'], func
['known_as']))
1878 # Write function to initialize bindings where choice of the function depends
1879 # on the extension string or the GL version.
1880 file.write("""void Driver%s::InitializeDynamicBindings(GLContext* context) {
1881 DCHECK(context && context->IsCurrent(NULL));
1882 const GLVersionInfo* ver = context->GetVersionInfo();
1883 ALLOW_UNUSED_LOCAL(ver);
1884 std::string extensions = context->GetExtensions() + " ";
1885 ALLOW_UNUSED_LOCAL(extensions);
1887 """ % set_name
.upper())
1888 for extension
in sorted(used_extensions
):
1889 # Extra space at the end of the extension name is intentional, it is used
1891 file.write(' ext.b_%s = extensions.find("%s ") != std::string::npos;\n' %
1892 (extension
, extension
))
1896 return '(%s)' % cond
1901 return '(%s)' % cond
1904 def VersionCondition(version
):
1906 if 'gl_versions' in version
:
1907 gl_versions
= version
['gl_versions']
1908 version_cond
= ' || '.join(['ver->is_%s' % gl
for gl
in gl_versions
])
1909 conditions
.append(WrapOr(version_cond
))
1910 if 'extensions' in version
and version
['extensions']:
1911 ext_cond
= ' || '.join(['ext.b_%s' % e
for e
in version
['extensions']])
1912 conditions
.append(WrapOr(ext_cond
))
1913 return ' && '.join(conditions
)
1915 def WriteConditionalFuncBinding(file, func
):
1916 # Functions with only one version are always bound unconditionally
1917 assert len(func
['versions']) > 1
1918 known_as
= func
['known_as']
1920 first_version
= True
1921 while i
< len(func
['versions']):
1922 version
= func
['versions'][i
]
1923 cond
= VersionCondition(version
)
1924 combined_conditions
= [WrapAnd(cond
)]
1925 last_version
= i
+ 1 == len(func
['versions'])
1926 while not last_version
and \
1927 func
['versions'][i
+ 1]['name'] == version
['name']:
1929 combinable_cond
= VersionCondition(func
['versions'][i
])
1930 combined_conditions
.append(WrapAnd(combinable_cond
))
1931 last_version
= i
+ 1 == len(func
['versions'])
1932 if len(combined_conditions
) > 1:
1933 if [1 for cond
in combined_conditions
if cond
== '']:
1936 cond
= ' || '.join(combined_conditions
)
1937 # Don't make the last possible binding conditional on anything else but
1938 # that the function isn't already bound to avoid verbose specification
1939 # of functions which have both ARB and core versions with the same name,
1940 # and to be able to bind to mock extension functions in unit tests which
1941 # call InitializeDynamicGLBindings with a stub context that doesn't have
1942 # extensions in its extension string.
1943 # TODO(oetuaho@nvidia.com): Get rid of the fallback.
1944 # http://crbug.com/325668
1945 if cond
!= '' and not last_version
:
1946 if not first_version
:
1947 file.write(' if (!fn.%sFn && (%s))\n ' % (known_as
, cond
))
1949 file.write(' if (%s)\n ' % cond
)
1950 elif not first_version
:
1951 file.write(' if (!fn.%sFn)\n ' % known_as
)
1952 WriteFuncBinding(file, known_as
, version
['name'])
1954 first_version
= False
1956 for func
in functions
:
1957 unique_names
= set([version
['name'] for version
in func
['versions']])
1958 if len(unique_names
) > 1:
1960 file.write(' fn.%sFn = 0;\n' % func
['known_as'])
1961 file.write(' debug_fn.%sFn = 0;\n' % func
['known_as'])
1962 WriteConditionalFuncBinding(file, func
)
1964 # Some new function pointers have been added, so update them in debug bindings
1966 file.write(' if (g_debugBindingsInitialized)\n')
1967 file.write(' InitializeDebugBindings();\n')
1971 # Write logging wrappers for each function.
1972 file.write('extern "C" {\n')
1973 for func
in functions
:
1974 return_type
= func
['return_type']
1975 arguments
= func
['arguments']
1977 file.write('static %s GL_BINDING_CALL Debug_%s(%s) {\n' %
1978 (return_type
, func
['known_as'], arguments
))
1979 argument_names
= re
.sub(
1980 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2', arguments
)
1981 argument_names
= re
.sub(
1982 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2', argument_names
)
1983 log_argument_names
= re
.sub(
1984 r
'const char\* ([a-zA-Z0-9_]+)', r
'CONSTCHAR_\1', arguments
)
1985 log_argument_names
= re
.sub(
1986 r
'(const )?[a-zA-Z0-9_]+\* ([a-zA-Z0-9_]+)',
1987 r
'CONSTVOID_\2', log_argument_names
)
1988 log_argument_names
= re
.sub(
1989 r
'(?<!E)GLenum ([a-zA-Z0-9_]+)', r
'GLenum_\1', log_argument_names
)
1990 log_argument_names
= re
.sub(
1991 r
'(?<!E)GLboolean ([a-zA-Z0-9_]+)', r
'GLboolean_\1', log_argument_names
)
1992 log_argument_names
= re
.sub(
1993 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2',
1995 log_argument_names
= re
.sub(
1996 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2',
1998 log_argument_names
= re
.sub(
1999 r
'CONSTVOID_([a-zA-Z0-9_]+)',
2000 r
'static_cast<const void*>(\1)', log_argument_names
)
2001 log_argument_names
= re
.sub(
2002 r
'CONSTCHAR_([a-zA-Z0-9_]+)', r
'\1', log_argument_names
)
2003 log_argument_names
= re
.sub(
2004 r
'GLenum_([a-zA-Z0-9_]+)', r
'GLES2Util::GetStringEnum(\1)',
2006 log_argument_names
= re
.sub(
2007 r
'GLboolean_([a-zA-Z0-9_]+)', r
'GLES2Util::GetStringBool(\1)',
2009 log_argument_names
= log_argument_names
.replace(',', ' << ", " <<')
2010 if argument_names
== 'void' or argument_names
== '':
2012 log_argument_names
= ''
2014 log_argument_names
= " << " + log_argument_names
2015 function_name
= func
['known_as']
2016 if return_type
== 'void':
2017 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' %
2018 (function_name
, log_argument_names
))
2019 file.write(' g_driver_%s.debug_fn.%sFn(%s);\n' %
2020 (set_name
.lower(), function_name
, argument_names
))
2021 if 'logging_code' in func
:
2022 file.write("%s\n" % func
['logging_code'])
2024 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' %
2025 (function_name
, log_argument_names
))
2026 file.write(' %s result = g_driver_%s.debug_fn.%sFn(%s);\n' %
2027 (return_type
, set_name
.lower(), function_name
, argument_names
))
2028 if 'logging_code' in func
:
2029 file.write("%s\n" % func
['logging_code'])
2031 file.write(' GL_SERVICE_LOG("GL_RESULT: " << result);\n')
2032 file.write(' return result;\n')
2034 file.write('} // extern "C"\n')
2036 # Write function to initialize the debug function pointers.
2038 file.write('void Driver%s::InitializeDebugBindings() {\n' %
2040 for func
in functions
:
2041 first_name
= func
['known_as']
2042 file.write(' if (!debug_fn.%sFn) {\n' % first_name
)
2043 file.write(' debug_fn.%sFn = fn.%sFn;\n' % (first_name
, first_name
))
2044 file.write(' fn.%sFn = Debug_%s;\n' % (first_name
, first_name
))
2046 file.write(' g_debugBindingsInitialized = true;\n')
2049 # Write function to clear all function pointers.
2051 file.write("""void Driver%s::ClearBindings() {
2052 memset(this, 0, sizeof(*this));
2054 """ % set_name
.upper())
2056 def MakeArgNames(arguments
):
2057 argument_names
= re
.sub(
2058 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2', arguments
)
2059 argument_names
= re
.sub(
2060 r
'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r
'\2', argument_names
)
2061 if argument_names
== 'void' or argument_names
== '':
2063 return argument_names
2065 # Write GLApiBase functions
2066 for func
in functions
:
2067 function_name
= func
['known_as']
2068 return_type
= func
['return_type']
2069 arguments
= func
['arguments']
2071 file.write('%s %sApiBase::%sFn(%s) {\n' %
2072 (return_type
, set_name
.upper(), function_name
, arguments
))
2073 argument_names
= MakeArgNames(arguments
)
2074 if return_type
== 'void':
2075 file.write(' driver_->fn.%sFn(%s);\n' %
2076 (function_name
, argument_names
))
2078 file.write(' return driver_->fn.%sFn(%s);\n' %
2079 (function_name
, argument_names
))
2082 # Write TraceGLApi functions
2083 for func
in functions
:
2084 function_name
= func
['known_as']
2085 return_type
= func
['return_type']
2086 arguments
= func
['arguments']
2088 file.write('%s Trace%sApi::%sFn(%s) {\n' %
2089 (return_type
, set_name
.upper(), function_name
, arguments
))
2090 argument_names
= MakeArgNames(arguments
)
2091 file.write(' TRACE_EVENT_BINARY_EFFICIENT0("gpu", "TraceGLAPI::%s")\n' %
2093 if return_type
== 'void':
2094 file.write(' %s_api_->%sFn(%s);\n' %
2095 (set_name
.lower(), function_name
, argument_names
))
2097 file.write(' return %s_api_->%sFn(%s);\n' %
2098 (set_name
.lower(), function_name
, argument_names
))
2101 # Write NoContextGLApi functions
2102 if set_name
.upper() == "GL":
2103 for func
in functions
:
2104 function_name
= func
['known_as']
2105 return_type
= func
['return_type']
2106 arguments
= func
['arguments']
2108 file.write('%s NoContextGLApi::%sFn(%s) {\n' %
2109 (return_type
, function_name
, arguments
))
2110 argument_names
= MakeArgNames(arguments
)
2111 no_context_error
= "Trying to call %s() without current GL context" % function_name
2112 file.write(' NOTREACHED() << "%s";\n' % no_context_error
)
2113 file.write(' LOG(ERROR) << "%s";\n' % no_context_error
)
2114 default_value
= { 'GLenum': 'static_cast<GLenum>(0)',
2117 'GLboolean': 'GL_FALSE',
2126 if return_type
.endswith('*'):
2127 file.write(' return NULL;\n')
2128 elif return_type
!= 'void':
2129 file.write(' return %s;\n' % default_value
[return_type
])
2133 file.write('} // namespace gfx\n')
2136 def GetUniquelyNamedFunctions(functions
):
2137 uniquely_named_functions
= {}
2139 for func
in functions
:
2140 for version
in func
['versions']:
2141 uniquely_named_functions
[version
['name']] = ({
2142 'name': version
['name'],
2143 'return_type': func
['return_type'],
2144 'arguments': func
['arguments'],
2145 'known_as': func
['known_as']
2147 return uniquely_named_functions
2150 def GenerateMockBindingsHeader(file, functions
):
2151 """Headers for functions that invoke MockGLInterface members"""
2154 """// Copyright (c) 2014 The Chromium Authors. All rights reserved.
2155 // Use of this source code is governed by a BSD-style license that can be
2156 // found in the LICENSE file.
2158 // This file is automatically generated.
2161 uniquely_named_functions
= GetUniquelyNamedFunctions(functions
)
2163 for key
in sorted(uniquely_named_functions
.iterkeys()):
2164 func
= uniquely_named_functions
[key
]
2165 file.write('static %s GL_BINDING_CALL Mock_%s(%s);\n' %
2166 (func
['return_type'], func
['name'], func
['arguments']))
2169 def GenerateMockBindingsSource(file, functions
):
2170 """Generates functions that invoke MockGLInterface members and a
2171 GetGLProcAddress function that returns addresses to those functions."""
2174 """// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2175 // Use of this source code is governed by a BSD-style license that can be
2176 // found in the LICENSE file.
2178 // This file is automatically generated.
2182 #include "ui/gl/gl_mock.h"
2186 // This is called mainly to prevent the compiler combining the code of mock
2187 // functions with identical contents, so that their function pointers will be
2189 void MakeFunctionUnique(const char *func_name) {
2190 VLOG(2) << "Calling mock " << func_name;
2194 # Write functions that trampoline into the set MockGLInterface instance.
2195 uniquely_named_functions
= GetUniquelyNamedFunctions(functions
)
2196 sorted_function_names
= sorted(uniquely_named_functions
.iterkeys())
2198 for key
in sorted_function_names
:
2199 func
= uniquely_named_functions
[key
]
2201 file.write('%s GL_BINDING_CALL MockGLInterface::Mock_%s(%s) {\n' %
2202 (func
['return_type'], func
['name'], func
['arguments']))
2203 file.write(' MakeFunctionUnique("%s");\n' % func
['name'])
2204 arg_re
= r
'(const )?[a-zA-Z0-9]+((\s*const\s*)?\*)* ([a-zA-Z0-9]+)'
2205 argument_names
= re
.sub(arg_re
, r
'\4', func
['arguments'])
2206 if argument_names
== 'void':
2208 function_name
= func
['known_as'][2:]
2209 if func
['return_type'] == 'void':
2210 file.write(' interface_->%s(%s);\n' %
2211 (function_name
, argument_names
))
2213 file.write(' return interface_->%s(%s);\n' %
2214 (function_name
, argument_names
))
2217 # Write an 'invalid' function to catch code calling through uninitialized
2218 # function pointers or trying to interpret the return value of
2221 file.write('static void MockInvalidFunction() {\n')
2222 file.write(' NOTREACHED();\n')
2225 # Write a function to lookup a mock GL function based on its name.
2227 file.write('void* GL_BINDING_CALL ' +
2228 'MockGLInterface::GetGLProcAddress(const char* name) {\n')
2229 for key
in sorted_function_names
:
2230 name
= uniquely_named_functions
[key
]['name']
2231 file.write(' if (strcmp(name, "%s") == 0)\n' % name
)
2232 file.write(' return reinterpret_cast<void*>(Mock_%s);\n' % name
)
2233 # Always return a non-NULL pointer like some EGL implementations do.
2234 file.write(' return reinterpret_cast<void*>(&MockInvalidFunction);\n')
2238 file.write('} // namespace gfx\n')
2241 def ParseExtensionFunctionsFromHeader(header_file
):
2242 """Parse a C extension header file and return a map from extension names to
2243 a list of functions.
2246 header_file: Line-iterable C header file.
2248 Map of extension name => functions.
2250 extension_start
= re
.compile(
2251 r
'#ifndef ((?:GL|EGL|WGL|GLX)_[A-Z]+_[a-zA-Z]\w+)')
2252 extension_function
= re
.compile(r
'.+\s+([a-z]+\w+)\s*\(')
2253 typedef
= re
.compile(r
'typedef .*')
2254 macro_start
= re
.compile(r
'^#(if|ifdef|ifndef).*')
2255 macro_end
= re
.compile(r
'^#endif.*')
2257 current_extension
= None
2258 current_extension_depth
= 0
2259 extensions
= collections
.defaultdict(lambda: [])
2260 for line
in header_file
:
2261 if macro_start
.match(line
):
2263 elif macro_end
.match(line
):
2265 if macro_depth
< current_extension_depth
:
2266 current_extension
= None
2267 match
= extension_start
.match(line
)
2269 current_extension
= match
.group(1)
2270 current_extension_depth
= macro_depth
2271 assert current_extension
not in extensions
, \
2272 "Duplicate extension: " + current_extension
2273 match
= extension_function
.match(line
)
2274 if match
and current_extension
and not typedef
.match(line
):
2275 extensions
[current_extension
].append(match
.group(1))
2279 def GetExtensionFunctions(extension_headers
):
2280 """Parse extension functions from a list of header files.
2283 extension_headers: List of header file names.
2285 Map of extension name => list of functions.
2288 for header
in extension_headers
:
2289 extensions
.update(ParseExtensionFunctionsFromHeader(open(header
)))
2293 def GetFunctionToExtensionMap(extensions
):
2294 """Construct map from a function names to extensions which define the
2298 extensions: Map of extension name => functions.
2300 Map of function name => extension name.
2302 function_to_extensions
= {}
2303 for extension
, functions
in extensions
.items():
2304 for function
in functions
:
2305 if not function
in function_to_extensions
:
2306 function_to_extensions
[function
] = []
2307 function_to_extensions
[function
].append(extension
)
2308 return function_to_extensions
2311 def LooksLikeExtensionFunction(function
):
2312 """Heuristic to see if a function name is consistent with extension function
2314 vendor
= re
.match(r
'\w+?([A-Z][A-Z]+)$', function
)
2315 return vendor
is not None and not vendor
.group(1) in ['GL', 'API', 'DC']
2318 def FillExtensionsFromHeaders(functions
, extension_headers
, extra_extensions
):
2319 """Determine which functions belong to extensions based on extension headers,
2320 and fill in this information to the functions table for functions that don't
2321 already have the information.
2324 functions: List of (return type, function versions, arguments).
2325 extension_headers: List of header file names.
2326 extra_extensions: Extensions to add to the list.
2328 Set of used extensions.
2330 # Parse known extensions.
2331 extensions
= GetExtensionFunctions(extension_headers
)
2332 functions_to_extensions
= GetFunctionToExtensionMap(extensions
)
2334 # Fill in the extension information.
2335 used_extensions
= set()
2336 for func
in functions
:
2337 for version
in func
['versions']:
2338 name
= version
['name']
2339 # Make sure we know about all extensions and extension functions.
2340 if 'extensions' in version
:
2341 used_extensions
.update(version
['extensions'])
2342 elif name
in functions_to_extensions
:
2343 # If there are multiple versions with the same name, assume that they
2344 # already have all the correct conditions, we can't just blindly add
2345 # the same extension conditions to all of them
2346 if len([v
for v
in func
['versions'] if v
['name'] == name
]) == 1:
2347 version
['extensions'] = functions_to_extensions
[name
]
2348 used_extensions
.update(version
['extensions'])
2349 elif LooksLikeExtensionFunction(name
):
2350 raise RuntimeError('%s looks like an extension function but does not '
2351 'belong to any of the known extensions.' % name
)
2353 # Add extensions that do not have any functions.
2354 used_extensions
.update(extra_extensions
)
2356 return used_extensions
2359 def ResolveHeader(header
, header_paths
):
2360 paths
= header_paths
.split(':')
2363 result
= os
.path
.join(path
, header
)
2364 if not os
.path
.isabs(path
):
2365 result
= os
.path
.relpath(os
.path
.join(os
.getcwd(), result
), os
.getcwd())
2366 if os
.path
.exists(result
):
2367 # Always use forward slashes as path separators. Otherwise backslashes
2368 # may be incorrectly interpreted as escape characters.
2369 return result
.replace(os
.path
.sep
, '/')
2371 raise Exception('Header %s not found.' % header
)
2375 """This is the main function."""
2377 parser
= optparse
.OptionParser()
2378 parser
.add_option('--inputs', action
='store_true')
2379 parser
.add_option('--header-paths')
2380 parser
.add_option('--verify-order', action
='store_true')
2382 options
, args
= parser
.parse_args(argv
)
2385 for [_
, _
, headers
, _
] in FUNCTION_SETS
:
2386 for header
in headers
:
2387 print ResolveHeader(header
, options
.header_paths
)
2394 for [functions
, set_name
, extension_headers
, extensions
] in FUNCTION_SETS
:
2395 # Function names can be specified in two ways (list of unique names or list
2396 # of versions with different binding conditions). Fill in the data to the
2397 # versions list in case it is missing, so that can be used from here on:
2398 for func
in functions
:
2399 assert 'versions' in func
or 'names' in func
, 'Function with no names'
2400 if 'versions' not in func
:
2401 func
['versions'] = [{'name': n
} for n
in func
['names']]
2402 # Use the first version's name unless otherwise specified
2403 if 'known_as' not in func
:
2404 func
['known_as'] = func
['versions'][0]['name']
2405 # Make sure that 'names' is not accidentally used instead of 'versions'
2409 # Check function names in each set is sorted in alphabetical order.
2410 for index
in range(len(functions
) - 1):
2411 func_name
= functions
[index
]['known_as']
2412 next_func_name
= functions
[index
+ 1]['known_as']
2413 if func_name
.lower() > next_func_name
.lower():
2415 'function %s is not in alphabetical order' % next_func_name
)
2416 if options
.verify_order
:
2419 extension_headers
= [ResolveHeader(h
, options
.header_paths
)
2420 for h
in extension_headers
]
2421 used_extensions
= FillExtensionsFromHeaders(
2422 functions
, extension_headers
, extensions
)
2425 os
.path
.join(directory
, 'gl_bindings_autogen_%s.h' % set_name
), 'wb')
2426 GenerateHeader(header_file
, functions
, set_name
, used_extensions
)
2430 os
.path
.join(directory
, 'gl_bindings_api_autogen_%s.h' % set_name
),
2432 GenerateAPIHeader(header_file
, functions
, set_name
)
2436 os
.path
.join(directory
, 'gl_bindings_autogen_%s.cc' % set_name
), 'wb')
2437 GenerateSource(source_file
, functions
, set_name
, used_extensions
)
2440 if not options
.verify_order
:
2442 os
.path
.join(directory
, 'gl_mock_autogen_gl.h'), 'wb')
2443 GenerateMockHeader(header_file
, GL_FUNCTIONS
, 'gl')
2446 header_file
= open(os
.path
.join(directory
, 'gl_bindings_autogen_mock.h'),
2448 GenerateMockBindingsHeader(header_file
, GL_FUNCTIONS
)
2451 source_file
= open(os
.path
.join(directory
, 'gl_bindings_autogen_mock.cc'),
2453 GenerateMockBindingsSource(source_file
, GL_FUNCTIONS
)
2458 if __name__
== '__main__':
2459 sys
.exit(main(sys
.argv
[1:]))