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 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2226 '1', | 2226 '1', |
2227 '2', | 2227 '2', |
2228 '3', | 2228 '3', |
2229 '4', | 2229 '4', |
2230 ], | 2230 ], |
2231 'invalid': [ | 2231 'invalid': [ |
2232 '0', | 2232 '0', |
2233 '5', | 2233 '5', |
2234 ], | 2234 ], |
2235 }, | 2235 }, |
2236 'FalseOnly': { | |
2237 'type': 'GLboolean', | |
2238 'is_complete': True, | |
2239 'valid': [ | |
2240 'false', | |
2241 ], | |
2242 'invalid': [ | |
2243 'true', | |
2244 ], | |
2245 }, | |
2246 'ResetStatus': { | 2236 'ResetStatus': { |
2247 'type': 'GLenum', | 2237 'type': 'GLenum', |
2248 'is_complete': True, | 2238 'is_complete': True, |
2249 'valid': [ | 2239 'valid': [ |
2250 'GL_GUILTY_CONTEXT_RESET_ARB', | 2240 'GL_GUILTY_CONTEXT_RESET_ARB', |
2251 'GL_INNOCENT_CONTEXT_RESET_ARB', | 2241 'GL_INNOCENT_CONTEXT_RESET_ARB', |
2252 'GL_UNKNOWN_CONTEXT_RESET_ARB', | 2242 'GL_UNKNOWN_CONTEXT_RESET_ARB', |
2253 ], | 2243 ], |
2254 }, | 2244 }, |
2255 'SyncCondition': { | 2245 'SyncCondition': { |
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3854 'type': 'PUTn', | 3844 'type': 'PUTn', |
3855 'count': 4, | 3845 'count': 4, |
3856 'decoder_func': 'DoUniform4uiv', | 3846 'decoder_func': 'DoUniform4uiv', |
3857 'unit_test': False, | 3847 'unit_test': False, |
3858 'unsafe': True, | 3848 'unsafe': True, |
3859 }, | 3849 }, |
3860 'UniformMatrix2fv': { | 3850 'UniformMatrix2fv': { |
3861 'type': 'PUTn', | 3851 'type': 'PUTn', |
3862 'count': 4, | 3852 'count': 4, |
3863 'decoder_func': 'DoUniformMatrix2fv', | 3853 'decoder_func': 'DoUniformMatrix2fv', |
| 3854 'unit_test': False, |
3864 }, | 3855 }, |
3865 'UniformMatrix2x3fv': { | 3856 'UniformMatrix2x3fv': { |
3866 'type': 'PUTn', | 3857 'type': 'PUTn', |
3867 'count': 6, | 3858 'count': 6, |
3868 'decoder_func': 'DoUniformMatrix2x3fv', | 3859 'decoder_func': 'DoUniformMatrix2x3fv', |
3869 'unsafe': True, | 3860 'unsafe': True, |
3870 }, | 3861 }, |
3871 'UniformMatrix2x4fv': { | 3862 'UniformMatrix2x4fv': { |
3872 'type': 'PUTn', | 3863 'type': 'PUTn', |
3873 'count': 8, | 3864 'count': 8, |
3874 'decoder_func': 'DoUniformMatrix2x4fv', | 3865 'decoder_func': 'DoUniformMatrix2x4fv', |
3875 'unsafe': True, | 3866 'unsafe': True, |
3876 }, | 3867 }, |
3877 'UniformMatrix3fv': { | 3868 'UniformMatrix3fv': { |
3878 'type': 'PUTn', | 3869 'type': 'PUTn', |
3879 'count': 9, | 3870 'count': 9, |
3880 'decoder_func': 'DoUniformMatrix3fv', | 3871 'decoder_func': 'DoUniformMatrix3fv', |
| 3872 'unit_test': False, |
3881 }, | 3873 }, |
3882 'UniformMatrix3x2fv': { | 3874 'UniformMatrix3x2fv': { |
3883 'type': 'PUTn', | 3875 'type': 'PUTn', |
3884 'count': 6, | 3876 'count': 6, |
3885 'decoder_func': 'DoUniformMatrix3x2fv', | 3877 'decoder_func': 'DoUniformMatrix3x2fv', |
3886 'unsafe': True, | 3878 'unsafe': True, |
3887 }, | 3879 }, |
3888 'UniformMatrix3x4fv': { | 3880 'UniformMatrix3x4fv': { |
3889 'type': 'PUTn', | 3881 'type': 'PUTn', |
3890 'count': 12, | 3882 'count': 12, |
3891 'decoder_func': 'DoUniformMatrix3x4fv', | 3883 'decoder_func': 'DoUniformMatrix3x4fv', |
3892 'unsafe': True, | 3884 'unsafe': True, |
3893 }, | 3885 }, |
3894 'UniformMatrix4fv': { | 3886 'UniformMatrix4fv': { |
3895 'type': 'PUTn', | 3887 'type': 'PUTn', |
3896 'count': 16, | 3888 'count': 16, |
3897 'decoder_func': 'DoUniformMatrix4fv', | 3889 'decoder_func': 'DoUniformMatrix4fv', |
| 3890 'unit_test': False, |
3898 }, | 3891 }, |
3899 'UniformMatrix4x2fv': { | 3892 'UniformMatrix4x2fv': { |
3900 'type': 'PUTn', | 3893 'type': 'PUTn', |
3901 'count': 8, | 3894 'count': 8, |
3902 'decoder_func': 'DoUniformMatrix4x2fv', | 3895 'decoder_func': 'DoUniformMatrix4x2fv', |
3903 'unsafe': True, | 3896 'unsafe': True, |
3904 }, | 3897 }, |
3905 'UniformMatrix4x3fv': { | 3898 'UniformMatrix4x3fv': { |
3906 'type': 'PUTn', | 3899 'type': 'PUTn', |
3907 'count': 12, | 3900 'count': 12, |
(...skipping 5065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8973 def GetInvalidArg(self, index): | 8966 def GetInvalidArg(self, index): |
8974 """overridden from SizeArgument.""" | 8967 """overridden from SizeArgument.""" |
8975 return ("-1", "kOutOfBounds", "GL_NO_ERROR") | 8968 return ("-1", "kOutOfBounds", "GL_NO_ERROR") |
8976 | 8969 |
8977 def WriteValidationCode(self, f, func): | 8970 def WriteValidationCode(self, f, func): |
8978 """overridden from SizeArgument.""" | 8971 """overridden from SizeArgument.""" |
8979 pass | 8972 pass |
8980 | 8973 |
8981 | 8974 |
8982 class EnumBaseArgument(Argument): | 8975 class EnumBaseArgument(Argument): |
8983 """Base class for EnumArgument, IntArgument, BitfieldArgument, and | 8976 """Base class for EnumArgument, IntArgument, and BitfieldArgument.""" |
8984 ValidatedBoolArgument.""" | |
8985 | 8977 |
8986 def __init__(self, name, gl_type, type, gl_error): | 8978 def __init__(self, name, gl_type, type, gl_error): |
8987 Argument.__init__(self, name, gl_type) | 8979 Argument.__init__(self, name, gl_type) |
8988 | 8980 |
8989 self.gl_error = gl_error | 8981 self.gl_error = gl_error |
8990 name = type[len(gl_type):] | 8982 name = type[len(gl_type):] |
8991 self.type_name = name | 8983 self.type_name = name |
8992 self.named_type = NamedType(_NAMED_TYPE_INFO[name]) | 8984 self.named_type = NamedType(_NAMED_TYPE_INFO[name]) |
8993 | 8985 |
8994 def IsConstant(self): | 8986 def IsConstant(self): |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9096 """A class for a GLint argument that can only accept specific values. | 9088 """A class for a GLint argument that can only accept specific values. |
9097 | 9089 |
9098 For example glTexImage2D takes a GLint for its internalformat | 9090 For example glTexImage2D takes a GLint for its internalformat |
9099 argument instead of a GLenum. | 9091 argument instead of a GLenum. |
9100 """ | 9092 """ |
9101 | 9093 |
9102 def __init__(self, name, type): | 9094 def __init__(self, name, type): |
9103 EnumBaseArgument.__init__(self, name, "GLint", type, "GL_INVALID_VALUE") | 9095 EnumBaseArgument.__init__(self, name, "GLint", type, "GL_INVALID_VALUE") |
9104 | 9096 |
9105 | 9097 |
9106 class ValidatedBoolArgument(EnumBaseArgument): | |
9107 """A class for a GLboolean argument that can only accept specific values. | |
9108 | |
9109 For example glUniformMatrix takes a GLboolean for it's transpose but it | |
9110 must be false. | |
9111 """ | |
9112 | |
9113 def __init__(self, name, type): | |
9114 EnumBaseArgument.__init__(self, name, "GLboolean", type, "GL_INVALID_VALUE") | |
9115 | |
9116 def GetLogArg(self): | |
9117 """Overridden from Argument.""" | |
9118 return 'GLES2Util::GetStringBool(%s)' % self.name | |
9119 | |
9120 | |
9121 class BitFieldArgument(EnumBaseArgument): | 9098 class BitFieldArgument(EnumBaseArgument): |
9122 """A class for a GLbitfield argument that can only accept specific values. | 9099 """A class for a GLbitfield argument that can only accept specific values. |
9123 | 9100 |
9124 For example glFenceSync takes a GLbitfield for its flags argument bit it | 9101 For example glFenceSync takes a GLbitfield for its flags argument bit it |
9125 must be 0. | 9102 must be 0. |
9126 """ | 9103 """ |
9127 | 9104 |
9128 def __init__(self, name, type): | 9105 def __init__(self, name, type): |
9129 EnumBaseArgument.__init__(self, name, "GLbitfield", type, | 9106 EnumBaseArgument.__init__(self, name, "GLbitfield", type, |
9130 "GL_INVALID_VALUE") | 9107 "GL_INVALID_VALUE") |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10105 elif t.startswith('GLidBind'): | 10082 elif t.startswith('GLidBind'): |
10106 return ResourceIdBindArgument(arg_name, arg_type) | 10083 return ResourceIdBindArgument(arg_name, arg_type) |
10107 elif t.startswith('GLidZero'): | 10084 elif t.startswith('GLidZero'): |
10108 return ResourceIdZeroArgument(arg_name, arg_type) | 10085 return ResourceIdZeroArgument(arg_name, arg_type) |
10109 elif t.startswith('GLid'): | 10086 elif t.startswith('GLid'): |
10110 return ResourceIdArgument(arg_name, arg_type) | 10087 return ResourceIdArgument(arg_name, arg_type) |
10111 elif t.startswith('GLenum') and t !='GLenum': | 10088 elif t.startswith('GLenum') and t !='GLenum': |
10112 return EnumArgument(arg_name, arg_type) | 10089 return EnumArgument(arg_name, arg_type) |
10113 elif t.startswith('GLbitfield') and t != 'GLbitfield': | 10090 elif t.startswith('GLbitfield') and t != 'GLbitfield': |
10114 return BitFieldArgument(arg_name, arg_type) | 10091 return BitFieldArgument(arg_name, arg_type) |
10115 elif t.startswith('GLboolean') and t != 'GLboolean': | |
10116 return ValidatedBoolArgument(arg_name, arg_type) | |
10117 elif t.startswith('GLboolean'): | 10092 elif t.startswith('GLboolean'): |
10118 return BoolArgument(arg_name, arg_type) | 10093 return BoolArgument(arg_name, arg_type) |
10119 elif t.startswith('GLintUniformLocation'): | 10094 elif t.startswith('GLintUniformLocation'): |
10120 return UniformLocationArgument(arg_name) | 10095 return UniformLocationArgument(arg_name) |
10121 elif (t.startswith('GLint') and t != 'GLint' and | 10096 elif (t.startswith('GLint') and t != 'GLint' and |
10122 not t.startswith('GLintptr')): | 10097 not t.startswith('GLintptr')): |
10123 return IntArgument(arg_name, arg_type) | 10098 return IntArgument(arg_name, arg_type) |
10124 elif t == 'GLsizeiNotNegative' or t == 'GLintptrNotNegative': | 10099 elif t == 'GLsizeiNotNegative' or t == 'GLintptrNotNegative': |
10125 return SizeNotNegativeArgument(arg_name, t.replace('NotNegative', '')) | 10100 return SizeNotNegativeArgument(arg_name, t.replace('NotNegative', '')) |
10126 elif t.startswith('GLsize'): | 10101 elif t.startswith('GLsize'): |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11551 Format(gen.generated_cpp_filenames) | 11526 Format(gen.generated_cpp_filenames) |
11552 | 11527 |
11553 if gen.errors > 0: | 11528 if gen.errors > 0: |
11554 print "%d errors" % gen.errors | 11529 print "%d errors" % gen.errors |
11555 return 1 | 11530 return 1 |
11556 return 0 | 11531 return 0 |
11557 | 11532 |
11558 | 11533 |
11559 if __name__ == '__main__': | 11534 if __name__ == '__main__': |
11560 sys.exit(main(sys.argv[1:])) | 11535 sys.exit(main(sys.argv[1:])) |
OLD | NEW |