OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2006-2009 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 GL command buffers.""" | 7 """code generator for GL command buffers.""" |
8 | 8 |
9 import os | 9 import os |
10 import os.path | 10 import os.path |
11 import sys | 11 import sys |
12 import re | 12 import re |
13 from optparse import OptionParser | 13 from optparse import OptionParser |
14 | 14 |
15 _SIZE_OF_UINT32 = 4 | 15 _SIZE_OF_UINT32 = 4 |
16 _SIZE_OF_COMMAND_HEADER = 4 | 16 _SIZE_OF_COMMAND_HEADER = 4 |
17 _FIRST_SPECIFIC_COMMAND_ID = 256 | 17 _FIRST_SPECIFIC_COMMAND_ID = 256 |
18 | 18 |
19 _LICENSE = """ | 19 _LICENSE = """ |
20 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 20 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
21 // Use of this source code is governed by a BSD-style license that can be | 21 // Use of this source code is governed by a BSD-style license that can be |
22 // found in the LICENSE file. | 22 // found in the LICENSE file. |
23 | 23 |
24 """ | 24 """ |
25 | 25 |
26 # This string is copied directly out of the gl2.h file from GLES2.0 | 26 # This string is copied directly out of the gl2.h file from GLES2.0 |
27 # the reasons it is copied out instead of parsed directly are | 27 # the reasons it is copied out instead of parsed directly are |
28 # | 28 # |
29 # 1) Because order is important. The command IDs need to stay constant forever | 29 # 1) Because order is important. The command IDs need to stay constant forever |
30 # so if you add a new command it needs to be added to the bottom of the list. | 30 # so if you add a new command it needs to be added to the bottom of the list. |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 file.Write(" typedef %s ValueType;\n" % func.name) | 411 file.Write(" typedef %s ValueType;\n" % func.name) |
412 file.Write(" static const CommandId kCmdId = k%s;\n" % func.name) | 412 file.Write(" static const CommandId kCmdId = k%s;\n" % func.name) |
413 func.WriteCmdArgFlag(file) | 413 func.WriteCmdArgFlag(file) |
414 file.Write("\n") | 414 file.Write("\n") |
415 | 415 |
416 func.WriteCmdComputeSize(file) | 416 func.WriteCmdComputeSize(file) |
417 func.WriteCmdSetHeader(file) | 417 func.WriteCmdSetHeader(file) |
418 func.WriteCmdInit(file) | 418 func.WriteCmdInit(file) |
419 func.WriteCmdSet(file) | 419 func.WriteCmdSet(file) |
420 | 420 |
421 file.Write(" command_buffer::CommandHeader header;\n") | 421 file.Write(" gpu::CommandHeader header;\n") |
422 args = func.GetCmdArgs() | 422 args = func.GetCmdArgs() |
423 for arg in args: | 423 for arg in args: |
424 file.Write(" %s %s;\n" % (arg.cmd_type, arg.name)) | 424 file.Write(" %s %s;\n" % (arg.cmd_type, arg.name)) |
425 file.Write("};\n") | 425 file.Write("};\n") |
426 file.Write("\n") | 426 file.Write("\n") |
427 | 427 |
428 size = len(args) * _SIZE_OF_UINT32 + _SIZE_OF_COMMAND_HEADER | 428 size = len(args) * _SIZE_OF_UINT32 + _SIZE_OF_COMMAND_HEADER |
429 file.Write("COMPILE_ASSERT(sizeof(%s) == %d,\n" % (func.name, size)) | 429 file.Write("COMPILE_ASSERT(sizeof(%s) == %d,\n" % (func.name, size)) |
430 file.Write(" Sizeof_%s_is_not_%d);\n" % (func.name, size)) | 430 file.Write(" Sizeof_%s_is_not_%d);\n" % (func.name, size)) |
431 file.Write("COMPILE_ASSERT(offsetof(%s, header) == 0,\n" % func.name) | 431 file.Write("COMPILE_ASSERT(offsetof(%s, header) == 0,\n" % func.name) |
(...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2410 file.Write( | 2410 file.Write( |
2411 "// This file is auto-generated. DO NOT EDIT!\n" | 2411 "// This file is auto-generated. DO NOT EDIT!\n" |
2412 "\n") | 2412 "\n") |
2413 | 2413 |
2414 def WriteLicense(self, file): | 2414 def WriteLicense(self, file): |
2415 """Writes the license.""" | 2415 """Writes the license.""" |
2416 file.Write(_LICENSE) | 2416 file.Write(_LICENSE) |
2417 | 2417 |
2418 def WriteNamespaceOpen(self, file): | 2418 def WriteNamespaceOpen(self, file): |
2419 """Writes the code for the namespace.""" | 2419 """Writes the code for the namespace.""" |
2420 file.Write("namespace command_buffer {\n") | 2420 file.Write("namespace gpu {\n") |
2421 file.Write("namespace gles2 {\n") | 2421 file.Write("namespace gles2 {\n") |
2422 file.Write("\n") | 2422 file.Write("\n") |
2423 | 2423 |
2424 def WriteNamespaceClose(self, file): | 2424 def WriteNamespaceClose(self, file): |
2425 """Writes the code to close the namespace.""" | 2425 """Writes the code to close the namespace.""" |
2426 file.Write("} // namespace gles2\n") | 2426 file.Write("} // namespace gles2\n") |
2427 file.Write("} // namespace command_buffer\n") | 2427 file.Write("} // namespace gpu\n") |
2428 file.Write("\n") | 2428 file.Write("\n") |
2429 | 2429 |
2430 def MakeGuard(self, filename): | 2430 def MakeGuard(self, filename): |
2431 """Creates a header guard id.""" | 2431 """Creates a header guard id.""" |
2432 base = os.path.dirname(os.path.dirname(os.path.dirname( | 2432 base = os.path.dirname(os.path.dirname(os.path.dirname( |
2433 os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) | 2433 os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) |
2434 hpath = os.path.abspath(filename)[len(base) + 1:] | 2434 hpath = os.path.abspath(filename)[len(base) + 1:] |
2435 return self._non_alnum_re.sub('_', hpath).upper() | 2435 return self._non_alnum_re.sub('_', hpath).upper() |
2436 | 2436 |
2437 def ParseArgs(self, arg_string): | 2437 def ParseArgs(self, arg_string): |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2692 gen.WriteGLES2ImplementationImpl("client/gles2_implementation_gen.h") | 2692 gen.WriteGLES2ImplementationImpl("client/gles2_implementation_gen.h") |
2693 gen.WriteServiceValidation("service/gles2_cmd_decoder_validate.h") | 2693 gen.WriteServiceValidation("service/gles2_cmd_decoder_validate.h") |
2694 | 2694 |
2695 if options.generate_command_id_tests: | 2695 if options.generate_command_id_tests: |
2696 gen.WriteCommandIdTest("common/gles2_cmd_id_test.cc") | 2696 gen.WriteCommandIdTest("common/gles2_cmd_id_test.cc") |
2697 | 2697 |
2698 | 2698 |
2699 if __name__ == '__main__': | 2699 if __name__ == '__main__': |
2700 main(sys.argv[1:]) | 2700 main(sys.argv[1:]) |
2701 | 2701 |
OLD | NEW |