OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """code generator for GLES2 command buffers.""" | 7 """code generator for GLES2 command buffers.""" |
8 | 8 |
9 import os | 9 import os |
10 import os.path | 10 import os.path |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 'decoder_func': 'DoCheckFramebufferStatus', | 1127 'decoder_func': 'DoCheckFramebufferStatus', |
1128 'gl_test_func': 'glCheckFramebufferStatusEXT', | 1128 'gl_test_func': 'glCheckFramebufferStatusEXT', |
1129 'result': ['GLenum'], | 1129 'result': ['GLenum'], |
1130 }, | 1130 }, |
1131 'Clear': {'decoder_func': 'DoClear'}, | 1131 'Clear': {'decoder_func': 'DoClear'}, |
1132 'ClearColor': {'decoder_func': 'DoClearColor'}, | 1132 'ClearColor': {'decoder_func': 'DoClearColor'}, |
1133 'ClearDepthf': { | 1133 'ClearDepthf': { |
1134 'decoder_func': 'DoClearDepthf', | 1134 'decoder_func': 'DoClearDepthf', |
1135 'gl_test_func': 'glClearDepth', | 1135 'gl_test_func': 'glClearDepth', |
1136 }, | 1136 }, |
1137 'ColorMask': {'decoder_func': 'DoColorMask', 'expectation': False}, | 1137 'ColorMask': {'decoder_func': 'DoColorMask'}, |
1138 'ClearStencil': {'decoder_func': 'DoClearStencil'}, | 1138 'ClearStencil': {'decoder_func': 'DoClearStencil'}, |
1139 'CommandBufferEnableCHROMIUM': { | 1139 'CommandBufferEnableCHROMIUM': { |
1140 'type': 'Custom', | 1140 'type': 'Custom', |
1141 'immediate': False, | 1141 'immediate': False, |
1142 'decoder_func': 'DoCommandBufferEnableCHROMIUM', | 1142 'decoder_func': 'DoCommandBufferEnableCHROMIUM', |
1143 'expectation': False, | 1143 'expectation': False, |
1144 'cmd_args': 'GLuint bucket_id, GLint* result', | 1144 'cmd_args': 'GLuint bucket_id, GLint* result', |
1145 'result': ['GLint'], | 1145 'result': ['GLint'], |
1146 'extension': True, | 1146 'extension': True, |
1147 'chromium': True, | 1147 'chromium': True, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 'type': 'Custom', | 1185 'type': 'Custom', |
1186 'decoder_func': 'DoDeleteSharedIdsCHROMIUM', | 1186 'decoder_func': 'DoDeleteSharedIdsCHROMIUM', |
1187 'impl_func': False, | 1187 'impl_func': False, |
1188 'expectation': False, | 1188 'expectation': False, |
1189 'immediate': False, | 1189 'immediate': False, |
1190 'extension': True, | 1190 'extension': True, |
1191 'chromium': True, | 1191 'chromium': True, |
1192 }, | 1192 }, |
1193 'DeleteTextures': {'type': 'DELn'}, | 1193 'DeleteTextures': {'type': 'DELn'}, |
1194 'DepthRangef': {'decoder_func': 'glDepthRange'}, | 1194 'DepthRangef': {'decoder_func': 'glDepthRange'}, |
1195 'DepthMask': {'decoder_func': 'DoDepthMask', 'expectation': False}, | 1195 'DepthMask': {'decoder_func': 'DoDepthMask'}, |
1196 'DetachShader': {'decoder_func': 'DoDetachShader'}, | 1196 'DetachShader': {'decoder_func': 'DoDetachShader'}, |
1197 'Disable': { | 1197 'Disable': { |
1198 'decoder_func': 'DoDisable', | 1198 'decoder_func': 'DoDisable', |
1199 }, | 1199 }, |
1200 'DisableVertexAttribArray': { | 1200 'DisableVertexAttribArray': { |
1201 'decoder_func': 'DoDisableVertexAttribArray', | 1201 'decoder_func': 'DoDisableVertexAttribArray', |
1202 'impl_decl': False, | 1202 'impl_decl': False, |
1203 }, | 1203 }, |
1204 'DrawArrays': { | 1204 'DrawArrays': { |
1205 'decoder_func': 'DoDrawArrays', | 1205 'decoder_func': 'DoDrawArrays', |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 }, | 1500 }, |
1501 'ShaderBinary': {'type': 'Custom'}, | 1501 'ShaderBinary': {'type': 'Custom'}, |
1502 'ShaderSource': { | 1502 'ShaderSource': { |
1503 'type': 'Manual', | 1503 'type': 'Manual', |
1504 'immediate': True, | 1504 'immediate': True, |
1505 'bucket': True, | 1505 'bucket': True, |
1506 'needs_size': True, | 1506 'needs_size': True, |
1507 'cmd_args': | 1507 'cmd_args': |
1508 'GLuint shader, const char* data', | 1508 'GLuint shader, const char* data', |
1509 }, | 1509 }, |
1510 'StencilMask': {'decoder_func': 'DoStencilMask', 'expectation': False}, | 1510 'StencilMask': {'decoder_func': 'DoStencilMask'}, |
1511 'StencilMaskSeparate': { | 1511 'StencilMaskSeparate': {'decoder_func': 'DoStencilMaskSeparate'}, |
1512 'decoder_func': 'DoStencilMaskSeparate', | |
1513 'expectation': False, | |
1514 }, | |
1515 'SwapBuffers': { | 1512 'SwapBuffers': { |
1516 'type': 'Custom', | 1513 'type': 'Custom', |
1517 'impl_func': False, | 1514 'impl_func': False, |
1518 'unit_test': False, | 1515 'unit_test': False, |
1519 'extension': True, | 1516 'extension': True, |
1520 }, | 1517 }, |
1521 'TexImage2D': {'type': 'Manual', 'immediate': True}, | 1518 'TexImage2D': {'type': 'Manual', 'immediate': True}, |
1522 'TexParameterf': { | 1519 'TexParameterf': { |
1523 'decoder_func': 'DoTexParameterf', | 1520 'decoder_func': 'DoTexParameterf', |
1524 'valid_args': { | 1521 'valid_args': { |
(...skipping 2742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4267 pass | 4264 pass |
4268 | 4265 |
4269 def GetImmediateVersion(self): | 4266 def GetImmediateVersion(self): |
4270 """Gets the immediate version of this argument.""" | 4267 """Gets the immediate version of this argument.""" |
4271 return self | 4268 return self |
4272 | 4269 |
4273 def GetBucketVersion(self): | 4270 def GetBucketVersion(self): |
4274 """Gets the bucket version of this argument.""" | 4271 """Gets the bucket version of this argument.""" |
4275 return self | 4272 return self |
4276 | 4273 |
4277 | |
4278 class BoolArgument(Argument): | |
4279 """class for GLboolean""" | |
4280 | |
4281 def __init__(self, name, type): | |
4282 Argument.__init__(self, name, 'GLboolean') | |
4283 | |
4284 def GetValidArg(self, func, offset, index): | |
4285 """Gets a valid value for this argument.""" | |
4286 return 'true' | |
4287 | |
4288 def GetValidGLArg(self, func, offset, index): | |
4289 """Gets a valid GL value for this argument.""" | |
4290 return 'true' | |
4291 | |
4292 | |
4293 class DataSizeArgument(Argument): | 4274 class DataSizeArgument(Argument): |
4294 """class for data_size which Bucket commands do not need.""" | 4275 """class for data_size which Bucket commands do not need.""" |
4295 | 4276 |
4296 def __init__(self, name): | 4277 def __init__(self, name): |
4297 Argument.__init__(self, name, "uint32") | 4278 Argument.__init__(self, name, "uint32") |
4298 | 4279 |
4299 def GetBucketVersion(self): | 4280 def GetBucketVersion(self): |
4300 return None | 4281 return None |
4301 | 4282 |
4302 | 4283 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4347 """overridden from SizeArgument.""" | 4328 """overridden from SizeArgument.""" |
4348 pass | 4329 pass |
4349 #file.Write(" if (%s < 0) {\n" % self.name) | 4330 #file.Write(" if (%s < 0) {\n" % self.name) |
4350 #file.Write(" SetGLError(GL_INVALID_VALUE, \"gl%s: %s < 0\");\n" % | 4331 #file.Write(" SetGLError(GL_INVALID_VALUE, \"gl%s: %s < 0\");\n" % |
4351 # (func.original_name, self.name)) | 4332 # (func.original_name, self.name)) |
4352 #file.Write(" return error::kNoError;\n") | 4333 #file.Write(" return error::kNoError;\n") |
4353 #file.Write(" }\n") | 4334 #file.Write(" }\n") |
4354 | 4335 |
4355 | 4336 |
4356 class EnumBaseArgument(Argument): | 4337 class EnumBaseArgument(Argument): |
4357 """Base class for EnumArgument, IntArgument and ValidatedBoolArgument""" | 4338 """Base class for EnumArgument, IntArgument and BoolArgument""" |
4358 | 4339 |
4359 def __init__(self, name, gl_type, type, gl_error): | 4340 def __init__(self, name, gl_type, type, gl_error): |
4360 Argument.__init__(self, name, gl_type) | 4341 Argument.__init__(self, name, gl_type) |
4361 | 4342 |
4362 self.local_type = type | 4343 self.local_type = type |
4363 self.gl_error = gl_error | 4344 self.gl_error = gl_error |
4364 name = type[len(gl_type):] | 4345 name = type[len(gl_type):] |
4365 self.type_name = name | 4346 self.type_name = name |
4366 self.enum_info = _ENUM_LISTS[name] | 4347 self.enum_info = _ENUM_LISTS[name] |
4367 | 4348 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4417 """A class for a GLint argument that can only except specific values. | 4398 """A class for a GLint argument that can only except specific values. |
4418 | 4399 |
4419 For example glTexImage2D takes a GLint for its internalformat | 4400 For example glTexImage2D takes a GLint for its internalformat |
4420 argument instead of a GLenum. | 4401 argument instead of a GLenum. |
4421 """ | 4402 """ |
4422 | 4403 |
4423 def __init__(self, name, type): | 4404 def __init__(self, name, type): |
4424 EnumBaseArgument.__init__(self, name, "GLint", type, "GL_INVALID_VALUE") | 4405 EnumBaseArgument.__init__(self, name, "GLint", type, "GL_INVALID_VALUE") |
4425 | 4406 |
4426 | 4407 |
4427 class ValidatedBoolArgument(EnumBaseArgument): | 4408 class BoolArgument(EnumBaseArgument): |
4428 """A class for a GLboolean argument that can only except specific values. | 4409 """A class for a GLboolean argument that can only except specific values. |
4429 | 4410 |
4430 For example glUniformMatrix takes a GLboolean for it's transpose but it | 4411 For example glUniformMatrix takes a GLboolean for it's transpose but it |
4431 must be false. | 4412 must be false. |
4432 """ | 4413 """ |
4433 | 4414 |
4434 def __init__(self, name, type): | 4415 def __init__(self, name, type): |
4435 EnumBaseArgument.__init__(self, name, "GLboolean", type, "GL_INVALID_VALUE") | 4416 EnumBaseArgument.__init__(self, name, "GLboolean", type, "GL_INVALID_VALUE") |
4436 | 4417 |
4437 | 4418 |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5071 # Is this a resource argument? Must come after pointer check. | 5052 # Is this a resource argument? Must come after pointer check. |
5072 elif arg_parts[0].startswith('GLidBind'): | 5053 elif arg_parts[0].startswith('GLidBind'): |
5073 return ResourceIdBindArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 5054 return ResourceIdBindArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
5074 elif arg_parts[0].startswith('GLidZero'): | 5055 elif arg_parts[0].startswith('GLidZero'): |
5075 return ResourceIdZeroArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 5056 return ResourceIdZeroArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
5076 elif arg_parts[0].startswith('GLid'): | 5057 elif arg_parts[0].startswith('GLid'): |
5077 return ResourceIdArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 5058 return ResourceIdArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
5078 elif arg_parts[0].startswith('GLenum') and len(arg_parts[0]) > 6: | 5059 elif arg_parts[0].startswith('GLenum') and len(arg_parts[0]) > 6: |
5079 return EnumArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 5060 return EnumArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
5080 elif arg_parts[0].startswith('GLboolean') and len(arg_parts[0]) > 9: | 5061 elif arg_parts[0].startswith('GLboolean') and len(arg_parts[0]) > 9: |
5081 return ValidatedBoolArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | |
5082 elif arg_parts[0].startswith('GLboolean'): | |
5083 return BoolArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 5062 return BoolArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
5084 elif (arg_parts[0].startswith('GLint') and len(arg_parts[0]) > 5 and | 5063 elif (arg_parts[0].startswith('GLint') and len(arg_parts[0]) > 5 and |
5085 not arg_parts[0].startswith('GLintptr')): | 5064 not arg_parts[0].startswith('GLintptr')): |
5086 return IntArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) | 5065 return IntArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) |
5087 elif (arg_parts[0].startswith('GLsizeiNotNegative') or | 5066 elif (arg_parts[0].startswith('GLsizeiNotNegative') or |
5088 arg_parts[0].startswith('GLintptrNotNegative')): | 5067 arg_parts[0].startswith('GLintptrNotNegative')): |
5089 return SizeNotNegativeArgument(arg_parts[-1], | 5068 return SizeNotNegativeArgument(arg_parts[-1], |
5090 " ".join(arg_parts[0:-1]), | 5069 " ".join(arg_parts[0:-1]), |
5091 arg_parts[0][0:-11]) | 5070 arg_parts[0][0:-11]) |
5092 elif arg_parts[0].startswith('GLsize'): | 5071 elif arg_parts[0].startswith('GLsize'): |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5811 | 5790 |
5812 if options.generate_docs: | 5791 if options.generate_docs: |
5813 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") | 5792 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") |
5814 | 5793 |
5815 if gen.errors > 0: | 5794 if gen.errors > 0: |
5816 print "%d errors" % gen.errors | 5795 print "%d errors" % gen.errors |
5817 sys.exit(1) | 5796 sys.exit(1) |
5818 | 5797 |
5819 if __name__ == '__main__': | 5798 if __name__ == '__main__': |
5820 main(sys.argv[1:]) | 5799 main(sys.argv[1:]) |
OLD | NEW |