| 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 4859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4870 | 4870 |
| 4871 def WriteBucketHandlerImplementation (self, func, f): | 4871 def WriteBucketHandlerImplementation (self, func, f): |
| 4872 """Writes the handler impl for the bucket version of a command.""" | 4872 """Writes the handler impl for the bucket version of a command.""" |
| 4873 self.__WriteIdMapping(func, f) | 4873 self.__WriteIdMapping(func, f) |
| 4874 f.write(" %s(%s);\n" % | 4874 f.write(" %s(%s);\n" % |
| 4875 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) | 4875 (func.GetGLFunctionName(), func.MakeOriginalArgString(""))) |
| 4876 | 4876 |
| 4877 def WriteServiceHandlerFunctionHeader(self, func, f): | 4877 def WriteServiceHandlerFunctionHeader(self, func, f): |
| 4878 """Writes function header for service implementation handlers.""" | 4878 """Writes function header for service implementation handlers.""" |
| 4879 f.write("""error::Error GLES2DecoderImpl::Handle%(name)s( | 4879 f.write("""error::Error GLES2DecoderImpl::Handle%(name)s( |
| 4880 uint32_t immediate_data_size, const void* cmd_data) { | 4880 uint32_t immediate_data_size, const volatile void* cmd_data) { |
| 4881 """ % {'name': func.name}) | 4881 """ % {'name': func.name}) |
| 4882 if func.IsUnsafe(): | 4882 if func.IsUnsafe(): |
| 4883 f.write("""if (!unsafe_es3_apis_enabled()) | 4883 f.write("""if (!unsafe_es3_apis_enabled()) |
| 4884 return error::kUnknownCommand; | 4884 return error::kUnknownCommand; |
| 4885 """) | 4885 """) |
| 4886 f.write("""const gles2::cmds::%(name)s& c = | 4886 if func.GetCmdArgs(): |
| 4887 *static_cast<const gles2::cmds::%(name)s*>(cmd_data); | 4887 f.write("""const volatile gles2::cmds::%(name)s& c = |
| 4888 (void)c; | 4888 *static_cast<const volatile gles2::cmds::%(name)s*>(cmd_data); |
| 4889 """ % {'name': func.name}) | 4889 """ % {'name': func.name}) |
| 4890 | 4890 |
| 4891 def WriteServiceHandlerArgGetCode(self, func, f): | 4891 def WriteServiceHandlerArgGetCode(self, func, f): |
| 4892 """Writes the argument unpack code for service handlers.""" | 4892 """Writes the argument unpack code for service handlers.""" |
| 4893 if len(func.GetOriginalArgs()) > 0: | 4893 if len(func.GetOriginalArgs()) > 0: |
| 4894 last_arg = func.GetLastOriginalArg() | 4894 last_arg = func.GetLastOriginalArg() |
| 4895 all_but_last_arg = func.GetOriginalArgs()[:-1] | 4895 all_but_last_arg = func.GetOriginalArgs()[:-1] |
| 4896 for arg in all_but_last_arg: | 4896 for arg in all_but_last_arg: |
| 4897 arg.WriteGetCode(f) | 4897 arg.WriteGetCode(f) |
| 4898 self.WriteGetDataSizeCode(func, f) | 4898 self.WriteGetDataSizeCode(func, f) |
| 4899 last_arg.WriteGetCode(f) | 4899 last_arg.WriteGetCode(f) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4946 self.WriteBucketServiceHandlerArgGetCode(func, f) | 4946 self.WriteBucketServiceHandlerArgGetCode(func, f) |
| 4947 func.WriteHandlerValidation(f) | 4947 func.WriteHandlerValidation(f) |
| 4948 func.WriteHandlerImplementation(f) | 4948 func.WriteHandlerImplementation(f) |
| 4949 f.write(" return error::kNoError;\n") | 4949 f.write(" return error::kNoError;\n") |
| 4950 f.write("}\n") | 4950 f.write("}\n") |
| 4951 f.write("\n") | 4951 f.write("\n") |
| 4952 | 4952 |
| 4953 def WritePassthroughServiceFunctionHeader(self, func, f): | 4953 def WritePassthroughServiceFunctionHeader(self, func, f): |
| 4954 """Writes function header for service passthrough handlers.""" | 4954 """Writes function header for service passthrough handlers.""" |
| 4955 f.write("""error::Error GLES2DecoderPassthroughImpl::Handle%(name)s( | 4955 f.write("""error::Error GLES2DecoderPassthroughImpl::Handle%(name)s( |
| 4956 uint32_t immediate_data_size, const void* cmd_data) { | 4956 uint32_t immediate_data_size, const volatile void* cmd_data) { |
| 4957 """ % {'name': func.name}) | 4957 """ % {'name': func.name}) |
| 4958 f.write("""const gles2::cmds::%(name)s& c = | 4958 if func.GetCmdArgs(): |
| 4959 *static_cast<const gles2::cmds::%(name)s*>(cmd_data); | 4959 f.write("""const volatile gles2::cmds::%(name)s& c = |
| 4960 (void)c; | 4960 *static_cast<const volatile gles2::cmds::%(name)s*>(cmd_data); |
| 4961 """ % {'name': func.name}) | 4961 """ % {'name': func.name}) |
| 4962 | 4962 |
| 4963 def WritePassthroughServiceFunctionDoerCall(self, func, f): | 4963 def WritePassthroughServiceFunctionDoerCall(self, func, f): |
| 4964 """Writes the function call to the passthrough service doer.""" | 4964 """Writes the function call to the passthrough service doer.""" |
| 4965 f.write(""" error::Error error = Do%(name)s(%(args)s); | 4965 f.write(""" error::Error error = Do%(name)s(%(args)s); |
| 4966 if (error != error::kNoError) { | 4966 if (error != error::kNoError) { |
| 4967 return error; | 4967 return error; |
| 4968 }""" % {'name': func.original_name, | 4968 }""" % {'name': func.original_name, |
| 4969 'args': func.MakePassthroughServiceDoerArgString("")}) | 4969 'args': func.MakePassthroughServiceDoerArgString("")}) |
| 4970 | 4970 |
| 4971 def WritePassthroughServiceImplementation(self, func, f): | 4971 def WritePassthroughServiceImplementation(self, func, f): |
| (...skipping 4019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8991 match = re.match('(const\s+)?(?P<element_type>[\w]+)\s*\*', self.type) | 8991 match = re.match('(const\s+)?(?P<element_type>[\w]+)\s*\*', self.type) |
| 8992 assert match | 8992 assert match |
| 8993 return match.groupdict()['element_type'] | 8993 return match.groupdict()['element_type'] |
| 8994 | 8994 |
| 8995 def AddCmdArgs(self, args): | 8995 def AddCmdArgs(self, args): |
| 8996 """Overridden from Argument.""" | 8996 """Overridden from Argument.""" |
| 8997 pass | 8997 pass |
| 8998 | 8998 |
| 8999 def WriteGetCode(self, f): | 8999 def WriteGetCode(self, f): |
| 9000 """Overridden from Argument.""" | 9000 """Overridden from Argument.""" |
| 9001 f.write(" %s %s = GetImmediateDataAs<%s>(\n" % | 9001 f.write(" volatile %s %s = GetImmediateDataAs<volatile %s>(\n" % |
| 9002 (self.type, self.name, self.type)) | 9002 (self.type, self.name, self.type)) |
| 9003 f.write(" c, data_size, immediate_data_size);\n") | 9003 f.write(" c, data_size, immediate_data_size);\n") |
| 9004 | 9004 |
| 9005 def WriteValidationCode(self, f, func): | 9005 def WriteValidationCode(self, f, func): |
| 9006 """Overridden from Argument.""" | 9006 """Overridden from Argument.""" |
| 9007 if self.optional: | 9007 if self.optional: |
| 9008 return | 9008 return |
| 9009 f.write(" if (%s == NULL) {\n" % self.name) | 9009 f.write(" if (%s == NULL) {\n" % self.name) |
| 9010 f.write(" return error::kOutOfBounds;\n") | 9010 f.write(" return error::kOutOfBounds;\n") |
| 9011 f.write(" }\n") | 9011 f.write(" }\n") |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9276 """Represents a GLuint64 argument which splits up into 2 uint32_t items.""" | 9276 """Represents a GLuint64 argument which splits up into 2 uint32_t items.""" |
| 9277 | 9277 |
| 9278 def __init__(self, name, type): | 9278 def __init__(self, name, type): |
| 9279 Argument.__init__(self, name, type) | 9279 Argument.__init__(self, name, type) |
| 9280 | 9280 |
| 9281 def GetArgAccessor(self): | 9281 def GetArgAccessor(self): |
| 9282 return "%s()" % self.name | 9282 return "%s()" % self.name |
| 9283 | 9283 |
| 9284 def WriteArgAccessor(self, f): | 9284 def WriteArgAccessor(self, f): |
| 9285 """Writes specialized accessor for compound members.""" | 9285 """Writes specialized accessor for compound members.""" |
| 9286 f.write(" %s %s() const {\n" % (self.type, self.name)) | 9286 f.write(" %s %s() const volatile {\n" % (self.type, self.name)) |
| 9287 f.write(" return static_cast<%s>(\n" % self.type) | 9287 f.write(" return static_cast<%s>(\n" % self.type) |
| 9288 f.write(" GLES2Util::MapTwoUint32ToUint64(\n") | 9288 f.write(" GLES2Util::MapTwoUint32ToUint64(\n") |
| 9289 f.write(" %s_0,\n" % self.name) | 9289 f.write(" %s_0,\n" % self.name) |
| 9290 f.write(" %s_1));\n" % self.name) | 9290 f.write(" %s_1));\n" % self.name) |
| 9291 f.write(" }\n") | 9291 f.write(" }\n") |
| 9292 f.write("\n") | 9292 f.write("\n") |
| 9293 | 9293 |
| 9294 def WriteGetCode(self, f): | 9294 def WriteGetCode(self, f): |
| 9295 """Writes the code to get an argument from a command structure.""" | 9295 """Writes the code to get an argument from a command structure.""" |
| 9296 f.write(" %s %s = c.%s();\n" % (self.type, self.name, self.name)) | 9296 f.write(" %s %s = c.%s();\n" % (self.type, self.name, self.name)) |
| (...skipping 2012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11309 Format(gen.generated_cpp_filenames) | 11309 Format(gen.generated_cpp_filenames) |
| 11310 | 11310 |
| 11311 if gen.errors > 0: | 11311 if gen.errors > 0: |
| 11312 print "%d errors" % gen.errors | 11312 print "%d errors" % gen.errors |
| 11313 return 1 | 11313 return 1 |
| 11314 return 0 | 11314 return 0 |
| 11315 | 11315 |
| 11316 | 11316 |
| 11317 if __name__ == '__main__': | 11317 if __name__ == '__main__': |
| 11318 sys.exit(main(sys.argv[1:])) | 11318 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |