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 GLES2 command buffers.""" | 6 """code generator for GLES2 command buffers.""" |
7 | 7 |
8 import itertools | 8 import itertools |
9 import os | 9 import os |
10 import os.path | 10 import os.path |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 # Must match function names specified in "cmd_buffer_functions.txt". | 1232 # Must match function names specified in "cmd_buffer_functions.txt". |
1233 # | 1233 # |
1234 # cmd_comment: A comment added to the cmd format. | 1234 # cmd_comment: A comment added to the cmd format. |
1235 # type: defines which handler will be used to generate code. | 1235 # type: defines which handler will be used to generate code. |
1236 # decoder_func: defines which function to call in the decoder to execute the | 1236 # decoder_func: defines which function to call in the decoder to execute the |
1237 # corresponding GL command. If not specified the GL command will | 1237 # corresponding GL command. If not specified the GL command will |
1238 # be called directly. | 1238 # be called directly. |
1239 # gl_test_func: GL function that is expected to be called when testing. | 1239 # gl_test_func: GL function that is expected to be called when testing. |
1240 # cmd_args: The arguments to use for the command. This overrides generating | 1240 # cmd_args: The arguments to use for the command. This overrides generating |
1241 # them based on the GL function arguments. | 1241 # them based on the GL function arguments. |
1242 # a NonImmediate type is a type that stays a pointer even in | |
1243 # and immediate version of acommand. | |
1244 # gen_cmd: Whether or not this function geneates a command. Default = True. | 1242 # gen_cmd: Whether or not this function geneates a command. Default = True. |
1245 # data_transfer_methods: Array of methods that are used for transfering the | 1243 # data_transfer_methods: Array of methods that are used for transfering the |
1246 # pointer data. Possible values: 'immediate', 'shm', 'bucket'. | 1244 # pointer data. Possible values: 'immediate', 'shm', 'bucket'. |
1247 # The default is 'immediate' if the command has one pointer | 1245 # The default is 'immediate' if the command has one pointer |
1248 # argument, otherwise 'shm'. One command is generated for each | 1246 # argument, otherwise 'shm'. One command is generated for each |
1249 # transfer method. Affects only commands which are not of type | 1247 # transfer method. Affects only commands which are not of type |
1250 # 'HandWritten', 'GETn' or 'GLcharN'. | 1248 # 'HandWritten', 'GETn' or 'GLcharN'. |
1251 # Note: the command arguments that affect this are the final args, | 1249 # Note: the command arguments that affect this are the final args, |
1252 # taking cmd_args override into consideration. | 1250 # taking cmd_args override into consideration. |
1253 # impl_func: Whether or not to generate the GLES2Implementation part of this | 1251 # impl_func: Whether or not to generate the GLES2Implementation part of this |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1702 'uint32_t type', | 1700 'uint32_t type', |
1703 ], | 1701 ], |
1704 }, | 1702 }, |
1705 'GetAttachedShaders': { | 1703 'GetAttachedShaders': { |
1706 'type': 'Custom', | 1704 'type': 'Custom', |
1707 'data_transfer_methods': ['shm'], | 1705 'data_transfer_methods': ['shm'], |
1708 'cmd_args': 'GLidProgram program, void* result, uint32_t result_size', | 1706 'cmd_args': 'GLidProgram program, void* result, uint32_t result_size', |
1709 'result': ['SizedResult<GLuint>'], | 1707 'result': ['SizedResult<GLuint>'], |
1710 }, | 1708 }, |
1711 'GetAttribLocation': { | 1709 'GetAttribLocation': { |
1712 'type': 'HandWritten', | 1710 'type': 'Custom', |
1713 'needs_size': True, | 1711 'data_transfer_methods': ['shm'], |
1714 'cmd_args': | 1712 'cmd_args': |
1715 'GLidProgram program, const char* name, NonImmediate GLint* location', | 1713 'GLidProgram program, uint32_t name_bucket_id, GLint* location', |
1716 'result': ['GLint'], | 1714 'result': ['GLint'], |
1717 'error_return': -1, # http://www.opengl.org/sdk/docs/man/xhtml/glGetAttribLo
cation.xml | 1715 'error_return': -1, # http://www.opengl.org/sdk/docs/man/xhtml/glGetAttribLo
cation.xml |
1718 }, | 1716 }, |
1719 'GetBooleanv': { | 1717 'GetBooleanv': { |
1720 'type': 'GETn', | 1718 'type': 'GETn', |
1721 'result': ['SizedResult<GLboolean>'], | 1719 'result': ['SizedResult<GLboolean>'], |
1722 'decoder_func': 'DoGetBooleanv', | 1720 'decoder_func': 'DoGetBooleanv', |
1723 'gl_test_func': 'glGetBooleanv', | 1721 'gl_test_func': 'glGetBooleanv', |
1724 }, | 1722 }, |
1725 'GetBufferParameteriv': { | 1723 'GetBufferParameteriv': { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1859 'type': 'Custom', | 1857 'type': 'Custom', |
1860 'data_transfer_methods': ['shm'], | 1858 'data_transfer_methods': ['shm'], |
1861 'result': ['SizedResult<GLfloat>'], | 1859 'result': ['SizedResult<GLfloat>'], |
1862 }, | 1860 }, |
1863 'GetUniformiv': { | 1861 'GetUniformiv': { |
1864 'type': 'Custom', | 1862 'type': 'Custom', |
1865 'data_transfer_methods': ['shm'], | 1863 'data_transfer_methods': ['shm'], |
1866 'result': ['SizedResult<GLint>'], | 1864 'result': ['SizedResult<GLint>'], |
1867 }, | 1865 }, |
1868 'GetUniformLocation': { | 1866 'GetUniformLocation': { |
1869 'type': 'HandWritten', | 1867 'type': 'Custom', |
1870 'needs_size': True, | 1868 'data_transfer_methods': ['shm'], |
1871 'cmd_args': | 1869 'cmd_args': |
1872 'GLidProgram program, const char* name, NonImmediate GLint* location', | 1870 'GLidProgram program, uint32_t name_bucket_id, GLint* location', |
1873 'result': ['GLint'], | 1871 'result': ['GLint'], |
1874 'error_return': -1, # http://www.opengl.org/sdk/docs/man/xhtml/glGetUniformL
ocation.xml | 1872 'error_return': -1, # http://www.opengl.org/sdk/docs/man/xhtml/glGetUniformL
ocation.xml |
1875 }, | 1873 }, |
1876 'GetVertexAttribfv': { | 1874 'GetVertexAttribfv': { |
1877 'type': 'GETn', | 1875 'type': 'GETn', |
1878 'result': ['SizedResult<GLfloat>'], | 1876 'result': ['SizedResult<GLfloat>'], |
1879 'impl_decl': False, | 1877 'impl_decl': False, |
1880 'decoder_func': 'DoGetVertexAttribfv', | 1878 'decoder_func': 'DoGetVertexAttribfv', |
1881 'expectation': False, | 1879 'expectation': False, |
1882 'client_test': False, | 1880 'client_test': False, |
(...skipping 4640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6523 'name': self.name, | 6521 'name': self.name, |
6524 }) | 6522 }) |
6525 | 6523 |
6526 def GetValidArg(self, func): | 6524 def GetValidArg(self, func): |
6527 return "kNameBucketId" | 6525 return "kNameBucketId" |
6528 | 6526 |
6529 def GetValidGLArg(self, func): | 6527 def GetValidGLArg(self, func): |
6530 return "_" | 6528 return "_" |
6531 | 6529 |
6532 | 6530 |
6533 class NonImmediatePointerArgument(PointerArgument): | |
6534 """A pointer argument that stays a pointer even in an immediate cmd.""" | |
6535 | |
6536 def __init__(self, name, type): | |
6537 PointerArgument.__init__(self, name, type) | |
6538 | |
6539 def IsPointer(self): | |
6540 """Returns true if argument is a pointer.""" | |
6541 return False | |
6542 | |
6543 def GetImmediateVersion(self): | |
6544 """Overridden from Argument.""" | |
6545 return self | |
6546 | |
6547 | |
6548 class ResourceIdArgument(Argument): | 6531 class ResourceIdArgument(Argument): |
6549 """A class that represents a resource id argument to a function.""" | 6532 """A class that represents a resource id argument to a function.""" |
6550 | 6533 |
6551 def __init__(self, name, type): | 6534 def __init__(self, name, type): |
6552 match = re.match("(GLid\w+)", type) | 6535 match = re.match("(GLid\w+)", type) |
6553 self.resource_type = match.group(1)[4:] | 6536 self.resource_type = match.group(1)[4:] |
6554 type = type.replace(match.group(1), "GLuint") | 6537 type = type.replace(match.group(1), "GLuint") |
6555 Argument.__init__(self, name, type) | 6538 Argument.__init__(self, name, type) |
6556 | 6539 |
6557 def WriteGetCode(self, file): | 6540 def WriteGetCode(self, file): |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7195 self.type_handler.WriteBucketServiceUnitTest(self, file) | 7178 self.type_handler.WriteBucketServiceUnitTest(self, file) |
7196 | 7179 |
7197 | 7180 |
7198 def CreateArg(arg_string): | 7181 def CreateArg(arg_string): |
7199 """Creates an Argument.""" | 7182 """Creates an Argument.""" |
7200 arg_parts = arg_string.split() | 7183 arg_parts = arg_string.split() |
7201 if len(arg_parts) == 1 and arg_parts[0] == 'void': | 7184 if len(arg_parts) == 1 and arg_parts[0] == 'void': |
7202 return None | 7185 return None |
7203 # Is this a pointer argument? | 7186 # Is this a pointer argument? |
7204 elif arg_string.find('*') >= 0: | 7187 elif arg_string.find('*') >= 0: |
7205 if arg_parts[0] == 'NonImmediate': | 7188 return PointerArgument( |
7206 return NonImmediatePointerArgument( | 7189 arg_parts[-1], |
7207 arg_parts[-1], | 7190 " ".join(arg_parts[0:-1])) |
7208 " ".join(arg_parts[1:-1])) | |
7209 else: | |
7210 return PointerArgument( | |
7211 arg_parts[-1], | |
7212 " ".join(arg_parts[0:-1])) | |
7213 # Is this a resource argument? Must come after pointer check. | 7191 # Is this a resource argument? Must come after pointer check. |
7214 elif arg_parts[0].startswith('GLidBind'): | 7192 elif arg_parts[0].startswith('GLidBind'): |
7215 return ResourceIdBindArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 7193 return ResourceIdBindArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
7216 elif arg_parts[0].startswith('GLidZero'): | 7194 elif arg_parts[0].startswith('GLidZero'): |
7217 return ResourceIdZeroArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 7195 return ResourceIdZeroArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
7218 elif arg_parts[0].startswith('GLid'): | 7196 elif arg_parts[0].startswith('GLid'): |
7219 return ResourceIdArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 7197 return ResourceIdArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
7220 elif arg_parts[0].startswith('GLenum') and len(arg_parts[0]) > 6: | 7198 elif arg_parts[0].startswith('GLenum') and len(arg_parts[0]) > 6: |
7221 return EnumArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 7199 return EnumArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
7222 elif arg_parts[0].startswith('GLboolean') and len(arg_parts[0]) > 9: | 7200 elif arg_parts[0].startswith('GLboolean') and len(arg_parts[0]) > 9: |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8363 "ppapi/shared_impl/ppb_opengles2_shared.cc"]) | 8341 "ppapi/shared_impl/ppb_opengles2_shared.cc"]) |
8364 | 8342 |
8365 if gen.errors > 0: | 8343 if gen.errors > 0: |
8366 print "%d errors" % gen.errors | 8344 print "%d errors" % gen.errors |
8367 return 1 | 8345 return 1 |
8368 return 0 | 8346 return 0 |
8369 | 8347 |
8370 | 8348 |
8371 if __name__ == '__main__': | 8349 if __name__ == '__main__': |
8372 sys.exit(main(sys.argv[1:])) | 8350 sys.exit(main(sys.argv[1:])) |
OLD | NEW |