OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """code generator for GL/GLES extension wrangler.""" | 6 """code generator for GL/GLES extension wrangler.""" |
7 | 7 |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import collections | 10 import collections |
(...skipping 18 matching lines...) Expand all Loading... |
29 'GL_CHROMIUM_egl_khr_fence_sync_hack', # crbug.com/504758 | 29 'GL_CHROMIUM_egl_khr_fence_sync_hack', # crbug.com/504758 |
30 ]) | 30 ]) |
31 | 31 |
32 """Function binding conditions can be specified manually by supplying a versions | 32 """Function binding conditions can be specified manually by supplying a versions |
33 array instead of the names array. Each version has the following keys: | 33 array instead of the names array. Each version has the following keys: |
34 name: Mandatory. Name of the function. Multiple versions can have the same | 34 name: Mandatory. Name of the function. Multiple versions can have the same |
35 name but different conditions. | 35 name but different conditions. |
36 extensions: Extra Extensions for which the function is bound. Only needed | 36 extensions: Extra Extensions for which the function is bound. Only needed |
37 in some cases where the extension cannot be parsed from the | 37 in some cases where the extension cannot be parsed from the |
38 headers. | 38 headers. |
39 | 39 is_optional: True if the GetProcAddress can return NULL for the |
| 40 function. This may happen for example when functions |
| 41 are added to a new version of an extension, but the |
| 42 extension string is not modified. |
40 By default, the function gets its name from the first name in its names or | 43 By default, the function gets its name from the first name in its names or |
41 versions array. This can be overridden by supplying a 'known_as' key. | 44 versions array. This can be overridden by supplying a 'known_as' key. |
| 45 |
42 """ | 46 """ |
43 GL_FUNCTIONS = [ | 47 GL_FUNCTIONS = [ |
44 { 'return_type': 'void', | 48 { 'return_type': 'void', |
45 'names': ['glActiveTexture'], | 49 'names': ['glActiveTexture'], |
46 'arguments': 'GLenum texture', }, | 50 'arguments': 'GLenum texture', }, |
47 { 'return_type': 'void', | 51 { 'return_type': 'void', |
48 'names': ['glAttachShader'], | 52 'names': ['glAttachShader'], |
49 'arguments': 'GLuint program, GLuint shader', }, | 53 'arguments': 'GLuint program, GLuint shader', }, |
50 { 'return_type': 'void', | 54 { 'return_type': 'void', |
51 'versions': [{ 'name': 'glBeginQuery' }, | 55 'versions': [{ 'name': 'glBeginQuery' }, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 { 'return_type': 'void', | 232 { 'return_type': 'void', |
229 'names': ['glCopyTexSubImage2D'], | 233 'names': ['glCopyTexSubImage2D'], |
230 'arguments': | 234 'arguments': |
231 'GLenum target, GLint level, GLint xoffset, ' | 235 'GLenum target, GLint level, GLint xoffset, ' |
232 'GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height', }, | 236 'GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height', }, |
233 { 'return_type': 'void', | 237 { 'return_type': 'void', |
234 'versions': [{ 'name': 'glCopyTexSubImage3D' }], | 238 'versions': [{ 'name': 'glCopyTexSubImage3D' }], |
235 'arguments': | 239 'arguments': |
236 'GLenum target, GLint level, GLint xoffset, GLint yoffset, ' | 240 'GLenum target, GLint level, GLint xoffset, GLint yoffset, ' |
237 'GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height', }, | 241 'GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height', }, |
| 242 { 'return_type': 'void', |
| 243 'names': ['glCoverFillPathNV'], |
| 244 'arguments': 'GLuint path, GLenum coverMode' }, |
| 245 { 'return_type': 'void', |
| 246 'names': ['glCoverStrokePathNV'], |
| 247 'arguments': 'GLuint name, GLenum coverMode' }, |
238 { 'return_type': 'GLuint', | 248 { 'return_type': 'GLuint', |
239 'names': ['glCreateProgram'], | 249 'names': ['glCreateProgram'], |
240 'arguments': 'void', }, | 250 'arguments': 'void', }, |
241 { 'return_type': 'GLuint', | 251 { 'return_type': 'GLuint', |
242 'names': ['glCreateShader'], | 252 'names': ['glCreateShader'], |
243 'arguments': 'GLenum type', }, | 253 'arguments': 'GLenum type', }, |
244 { 'return_type': 'void', | 254 { 'return_type': 'void', |
245 'names': ['glCullFace'], | 255 'names': ['glCullFace'], |
246 'arguments': 'GLenum mode', }, | 256 'arguments': 'GLenum mode', }, |
247 { 'return_type': 'void', | 257 { 'return_type': 'void', |
248 'names': ['glDeleteBuffers'], | 258 'names': ['glDeleteBuffers'], |
249 'known_as': 'glDeleteBuffersARB', | 259 'known_as': 'glDeleteBuffersARB', |
250 'arguments': 'GLsizei n, const GLuint* buffers', }, | 260 'arguments': 'GLsizei n, const GLuint* buffers', }, |
251 { 'return_type': 'void', | 261 { 'return_type': 'void', |
252 'known_as': 'glDeleteFencesAPPLE', | 262 'known_as': 'glDeleteFencesAPPLE', |
253 'versions': [{ 'name': 'glDeleteFencesAPPLE', | 263 'versions': [{ 'name': 'glDeleteFencesAPPLE', |
254 'extensions': ['GL_APPLE_fence'] }], | 264 'extensions': ['GL_APPLE_fence'] }], |
255 'arguments': 'GLsizei n, const GLuint* fences', }, | 265 'arguments': 'GLsizei n, const GLuint* fences', }, |
256 { 'return_type': 'void', | 266 { 'return_type': 'void', |
257 'names': ['glDeleteFencesNV'], | 267 'names': ['glDeleteFencesNV'], |
258 'arguments': 'GLsizei n, const GLuint* fences', }, | 268 'arguments': 'GLsizei n, const GLuint* fences', }, |
259 { 'return_type': 'void', | 269 { 'return_type': 'void', |
260 'names': ['glDeleteFramebuffersEXT', 'glDeleteFramebuffers'], | 270 'names': ['glDeleteFramebuffersEXT', 'glDeleteFramebuffers'], |
261 'arguments': 'GLsizei n, const GLuint* framebuffers', }, | 271 'arguments': 'GLsizei n, const GLuint* framebuffers', }, |
262 { 'return_type': 'void', | 272 { 'return_type': 'void', |
| 273 'names': ['glDeletePathsNV'], |
| 274 'arguments': 'GLuint path, GLsizei range' }, |
| 275 { 'return_type': 'void', |
263 'names': ['glDeleteProgram'], | 276 'names': ['glDeleteProgram'], |
264 'arguments': 'GLuint program', }, | 277 'arguments': 'GLuint program', }, |
265 { 'return_type': 'void', | 278 { 'return_type': 'void', |
266 'versions': [{ 'name': 'glDeleteQueries' }, | 279 'versions': [{ 'name': 'glDeleteQueries' }, |
267 { 'name': 'glDeleteQueriesARB'}, | 280 { 'name': 'glDeleteQueriesARB'}, |
268 { 'name': 'glDeleteQueriesEXT', | 281 { 'name': 'glDeleteQueriesEXT', |
269 'extensions': ['GL_EXT_occlusion_query_boolean'] }], | 282 'extensions': ['GL_EXT_occlusion_query_boolean'] }], |
270 'arguments': 'GLsizei n, const GLuint* ids', }, | 283 'arguments': 'GLsizei n, const GLuint* ids', }, |
271 { 'return_type': 'void', | 284 { 'return_type': 'void', |
272 'names': ['glDeleteRenderbuffersEXT', 'glDeleteRenderbuffers'], | 285 'names': ['glDeleteRenderbuffersEXT', 'glDeleteRenderbuffers'], |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 'known_as': 'glGenFencesAPPLE', | 444 'known_as': 'glGenFencesAPPLE', |
432 'versions': [{ 'name': 'glGenFencesAPPLE', | 445 'versions': [{ 'name': 'glGenFencesAPPLE', |
433 'extensions': ['GL_APPLE_fence'] }], | 446 'extensions': ['GL_APPLE_fence'] }], |
434 'arguments': 'GLsizei n, GLuint* fences', }, | 447 'arguments': 'GLsizei n, GLuint* fences', }, |
435 { 'return_type': 'void', | 448 { 'return_type': 'void', |
436 'names': ['glGenFencesNV'], | 449 'names': ['glGenFencesNV'], |
437 'arguments': 'GLsizei n, GLuint* fences', }, | 450 'arguments': 'GLsizei n, GLuint* fences', }, |
438 { 'return_type': 'void', | 451 { 'return_type': 'void', |
439 'names': ['glGenFramebuffersEXT', 'glGenFramebuffers'], | 452 'names': ['glGenFramebuffersEXT', 'glGenFramebuffers'], |
440 'arguments': 'GLsizei n, GLuint* framebuffers', }, | 453 'arguments': 'GLsizei n, GLuint* framebuffers', }, |
| 454 { 'return_type': 'GLuint', |
| 455 'names': ['glGenPathsNV'], |
| 456 'arguments': 'GLsizei range' }, |
441 { 'return_type': 'void', | 457 { 'return_type': 'void', |
442 'versions': [{ 'name': 'glGenQueries' }, | 458 'versions': [{ 'name': 'glGenQueries' }, |
443 { 'name': 'glGenQueriesARB', }, | 459 { 'name': 'glGenQueriesARB', }, |
444 { 'name' : 'glGenQueriesEXT', | 460 { 'name' : 'glGenQueriesEXT', |
445 'extensions': ['GL_EXT_occlusion_query_boolean'] }], | 461 'extensions': ['GL_EXT_occlusion_query_boolean'] }], |
446 'arguments': 'GLsizei n, GLuint* ids', }, | 462 'arguments': 'GLsizei n, GLuint* ids', }, |
447 { 'return_type': 'void', | 463 { 'return_type': 'void', |
448 'names': ['glGenRenderbuffersEXT', 'glGenRenderbuffers'], | 464 'names': ['glGenRenderbuffersEXT', 'glGenRenderbuffers'], |
449 'arguments': 'GLsizei n, GLuint* renderbuffers', }, | 465 'arguments': 'GLsizei n, GLuint* renderbuffers', }, |
450 { 'return_type': 'void', | 466 { 'return_type': 'void', |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 'versions': [{ 'name': 'glIsFenceAPPLE', | 714 'versions': [{ 'name': 'glIsFenceAPPLE', |
699 'extensions': ['GL_APPLE_fence'] }], | 715 'extensions': ['GL_APPLE_fence'] }], |
700 'arguments': 'GLuint fence', }, | 716 'arguments': 'GLuint fence', }, |
701 { 'return_type': 'GLboolean', | 717 { 'return_type': 'GLboolean', |
702 'names': ['glIsFenceNV'], | 718 'names': ['glIsFenceNV'], |
703 'arguments': 'GLuint fence', }, | 719 'arguments': 'GLuint fence', }, |
704 { 'return_type': 'GLboolean', | 720 { 'return_type': 'GLboolean', |
705 'names': ['glIsFramebufferEXT', 'glIsFramebuffer'], | 721 'names': ['glIsFramebufferEXT', 'glIsFramebuffer'], |
706 'arguments': 'GLuint framebuffer', }, | 722 'arguments': 'GLuint framebuffer', }, |
707 { 'return_type': 'GLboolean', | 723 { 'return_type': 'GLboolean', |
| 724 'names': ['glIsPathNV'], |
| 725 'arguments': 'GLuint path' }, |
| 726 { 'return_type': 'GLboolean', |
708 'names': ['glIsProgram'], | 727 'names': ['glIsProgram'], |
709 'arguments': 'GLuint program', }, | 728 'arguments': 'GLuint program', }, |
710 { 'return_type': 'GLboolean', | 729 { 'return_type': 'GLboolean', |
711 'versions': [{ 'name': 'glIsQuery' }, | 730 'versions': [{ 'name': 'glIsQuery' }, |
712 { 'name': 'glIsQueryARB' }, | 731 { 'name': 'glIsQueryARB' }, |
713 { 'name': 'glIsQueryEXT', | 732 { 'name': 'glIsQueryEXT', |
714 'extensions': ['GL_EXT_occlusion_query_boolean'] }], | 733 'extensions': ['GL_EXT_occlusion_query_boolean'] }], |
715 'arguments': 'GLuint query', }, | 734 'arguments': 'GLuint query', }, |
716 { 'return_type': 'GLboolean', | 735 { 'return_type': 'GLboolean', |
717 'names': ['glIsRenderbufferEXT', 'glIsRenderbuffer'], | 736 'names': ['glIsRenderbufferEXT', 'glIsRenderbuffer'], |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 'extensions': ['GL_EXT_direct_state_access', | 783 'extensions': ['GL_EXT_direct_state_access', |
765 'GL_NV_path_rendering'] }], | 784 'GL_NV_path_rendering'] }], |
766 'arguments': 'GLenum matrixMode, const GLfloat* m' }, | 785 'arguments': 'GLenum matrixMode, const GLfloat* m' }, |
767 { 'return_type': 'void', | 786 { 'return_type': 'void', |
768 'known_as': 'glMatrixLoadIdentityEXT', | 787 'known_as': 'glMatrixLoadIdentityEXT', |
769 'versions': [{ 'name': 'glMatrixLoadIdentityEXT', | 788 'versions': [{ 'name': 'glMatrixLoadIdentityEXT', |
770 'extensions': ['GL_EXT_direct_state_access', | 789 'extensions': ['GL_EXT_direct_state_access', |
771 'GL_NV_path_rendering'] },], | 790 'GL_NV_path_rendering'] },], |
772 'arguments': 'GLenum matrixMode' }, | 791 'arguments': 'GLenum matrixMode' }, |
773 { 'return_type': 'void', | 792 { 'return_type': 'void', |
| 793 'names': ['glPathCommandsNV'], |
| 794 'arguments': 'GLuint path, GLsizei numCommands, const GLubyte* commands, ' |
| 795 'GLsizei numCoords, GLenum coordType, const GLvoid* coords' }, |
| 796 { 'return_type': 'void', |
| 797 'names': ['glPathParameterfNV'], |
| 798 'arguments': 'GLuint path, GLenum pname, GLfloat value' }, |
| 799 { 'return_type': 'void', |
| 800 'names': ['glPathParameteriNV'], |
| 801 'arguments': 'GLuint path, GLenum pname, GLint value' }, |
| 802 { 'return_type': 'void', |
| 803 'names': ['glPathStencilFuncNV'], |
| 804 'arguments': 'GLenum func, GLint ref, GLuint mask' }, |
| 805 { 'return_type': 'void', |
774 'versions': [{ 'name': 'glPauseTransformFeedback' }], | 806 'versions': [{ 'name': 'glPauseTransformFeedback' }], |
775 'arguments': 'void', }, | 807 'arguments': 'void', }, |
776 { 'return_type': 'void', | 808 { 'return_type': 'void', |
777 'names': ['glPixelStorei'], | 809 'names': ['glPixelStorei'], |
778 'arguments': 'GLenum pname, GLint param', }, | 810 'arguments': 'GLenum pname, GLint param', }, |
779 { 'return_type': 'void', | 811 { 'return_type': 'void', |
780 'names': ['glPointParameteri'], | 812 'names': ['glPointParameteri'], |
781 'arguments': 'GLenum pname, GLint param', }, | 813 'arguments': 'GLenum pname, GLint param', }, |
782 { 'return_type': 'void', | 814 { 'return_type': 'void', |
783 'names': ['glPolygonOffset'], | 815 'names': ['glPolygonOffset'], |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 } else { | 914 } else { |
883 GL_SERVICE_LOG(" " << ii << ": ---\\n" << str[ii] << "\\n---"); | 915 GL_SERVICE_LOG(" " << ii << ": ---\\n" << str[ii] << "\\n---"); |
884 } | 916 } |
885 } else { | 917 } else { |
886 GL_SERVICE_LOG(" " << ii << ": NULL"); | 918 GL_SERVICE_LOG(" " << ii << ": NULL"); |
887 } | 919 } |
888 } | 920 } |
889 }); | 921 }); |
890 """, }, | 922 """, }, |
891 { 'return_type': 'void', | 923 { 'return_type': 'void', |
| 924 'names': ['glStencilFillPathNV'], |
| 925 'arguments': 'GLuint path, GLenum fillMode, GLuint mask' }, |
| 926 { 'return_type': 'void', |
892 'names': ['glStencilFunc'], | 927 'names': ['glStencilFunc'], |
893 'arguments': 'GLenum func, GLint ref, GLuint mask', }, | 928 'arguments': 'GLenum func, GLint ref, GLuint mask', }, |
894 { 'return_type': 'void', | 929 { 'return_type': 'void', |
895 'names': ['glStencilFuncSeparate'], | 930 'names': ['glStencilFuncSeparate'], |
896 'arguments': 'GLenum face, GLenum func, GLint ref, GLuint mask', }, | 931 'arguments': 'GLenum face, GLenum func, GLint ref, GLuint mask', }, |
897 { 'return_type': 'void', | 932 { 'return_type': 'void', |
898 'names': ['glStencilMask'], | 933 'names': ['glStencilMask'], |
899 'arguments': 'GLuint mask', }, | 934 'arguments': 'GLuint mask', }, |
900 { 'return_type': 'void', | 935 { 'return_type': 'void', |
901 'names': ['glStencilMaskSeparate'], | 936 'names': ['glStencilMaskSeparate'], |
902 'arguments': 'GLenum face, GLuint mask', }, | 937 'arguments': 'GLenum face, GLuint mask', }, |
903 { 'return_type': 'void', | 938 { 'return_type': 'void', |
904 'names': ['glStencilOp'], | 939 'names': ['glStencilOp'], |
905 'arguments': 'GLenum fail, GLenum zfail, GLenum zpass', }, | 940 'arguments': 'GLenum fail, GLenum zfail, GLenum zpass', }, |
906 { 'return_type': 'void', | 941 { 'return_type': 'void', |
907 'names': ['glStencilOpSeparate'], | 942 'names': ['glStencilOpSeparate'], |
908 'arguments': 'GLenum face, GLenum fail, GLenum zfail, GLenum zpass', }, | 943 'arguments': 'GLenum face, GLenum fail, GLenum zfail, GLenum zpass', }, |
| 944 { 'return_type': 'void', |
| 945 'names': ['glStencilStrokePathNV'], |
| 946 'arguments': 'GLuint path, GLint reference, GLuint mask' }, |
| 947 { 'return_type': 'void', |
| 948 'names': ['glStencilThenCoverFillPathNV'], |
| 949 'arguments': 'GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode', |
| 950 'is_optional': True, }, |
| 951 { 'return_type': 'void', |
| 952 'names': ['glStencilThenCoverStrokePathNV'], |
| 953 'arguments': 'GLuint path, GLint reference, GLuint mask, GLenum coverMode', |
| 954 'is_optional': True, }, |
909 { 'return_type': 'GLboolean', | 955 { 'return_type': 'GLboolean', |
910 'known_as': 'glTestFenceAPPLE', | 956 'known_as': 'glTestFenceAPPLE', |
911 'versions': [{ 'name': 'glTestFenceAPPLE', | 957 'versions': [{ 'name': 'glTestFenceAPPLE', |
912 'extensions': ['GL_APPLE_fence'] }], | 958 'extensions': ['GL_APPLE_fence'] }], |
913 'arguments': 'GLuint fence', }, | 959 'arguments': 'GLuint fence', }, |
914 { 'return_type': 'GLboolean', | 960 { 'return_type': 'GLboolean', |
915 'names': ['glTestFenceNV'], | 961 'names': ['glTestFenceNV'], |
916 'arguments': 'GLuint fence', }, | 962 'arguments': 'GLuint fence', }, |
917 { 'return_type': 'void', | 963 { 'return_type': 'void', |
918 'names': ['glTexImage2D'], | 964 'names': ['glTexImage2D'], |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 first_version = True | 1944 first_version = True |
1899 while i < len(func['versions']): | 1945 while i < len(func['versions']): |
1900 version = func['versions'][i] | 1946 version = func['versions'][i] |
1901 cond = GetBindingCondition(version) | 1947 cond = GetBindingCondition(version) |
1902 if first_version: | 1948 if first_version: |
1903 file.write(' if (%s) {\n ' % cond) | 1949 file.write(' if (%s) {\n ' % cond) |
1904 else: | 1950 else: |
1905 file.write(' else if (%s) {\n ' % (cond)) | 1951 file.write(' else if (%s) {\n ' % (cond)) |
1906 | 1952 |
1907 WriteFuncBinding(file, known_as, version['name']) | 1953 WriteFuncBinding(file, known_as, version['name']) |
1908 file.write('DCHECK(fn.%sFn);\n' % known_as) | 1954 if not 'is_optional' in func or not func['is_optional']: |
| 1955 file.write('DCHECK(fn.%sFn);\n' % known_as) |
1909 file.write('}\n') | 1956 file.write('}\n') |
1910 i += 1 | 1957 i += 1 |
1911 first_version = False | 1958 first_version = False |
1912 | 1959 |
1913 # TODO(jmadill): make more robust | 1960 # TODO(jmadill): make more robust |
1914 def IsClientExtensionFunc(func): | 1961 def IsClientExtensionFunc(func): |
1915 assert len(func['versions']) > 0 | 1962 assert len(func['versions']) > 0 |
1916 if 'client_extensions' in func['versions'][0]: | 1963 if 'client_extensions' in func['versions'][0]: |
1917 assert len(func['versions']) == 1 | 1964 assert len(func['versions']) == 1 |
1918 return True | 1965 return True |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2632 'gl_enums_implementation_autogen.h'), | 2679 'gl_enums_implementation_autogen.h'), |
2633 'wb') | 2680 'wb') |
2634 GenerateEnumUtils(header_file, enum_header_filenames) | 2681 GenerateEnumUtils(header_file, enum_header_filenames) |
2635 header_file.close() | 2682 header_file.close() |
2636 ClangFormat(header_file.name) | 2683 ClangFormat(header_file.name) |
2637 return 0 | 2684 return 0 |
2638 | 2685 |
2639 | 2686 |
2640 if __name__ == '__main__': | 2687 if __name__ == '__main__': |
2641 sys.exit(main(sys.argv[1:])) | 2688 sys.exit(main(sys.argv[1:])) |
OLD | NEW |