Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 2257533007: Autogenerate CreateAndConsumeTextureCHROMIUM handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gpu/command_buffer/client/gles2_cmd_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2333 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 # The default is 'immediate' if the command has one pointer 2344 # The default is 'immediate' if the command has one pointer
2345 # argument, otherwise 'shm'. One command is generated for each 2345 # argument, otherwise 'shm'. One command is generated for each
2346 # transfer method. Affects only commands which are not of type 2346 # transfer method. Affects only commands which are not of type
2347 # 'HandWritten', 'GETn' or 'GLcharN'. 2347 # 'HandWritten', 'GETn' or 'GLcharN'.
2348 # Note: the command arguments that affect this are the final args, 2348 # Note: the command arguments that affect this are the final args,
2349 # taking cmd_args override into consideration. 2349 # taking cmd_args override into consideration.
2350 # impl_func: Whether or not to generate the GLES2Implementation part of this 2350 # impl_func: Whether or not to generate the GLES2Implementation part of this
2351 # command. 2351 # command.
2352 # impl_decl: Whether or not to generate the GLES2Implementation declaration 2352 # impl_decl: Whether or not to generate the GLES2Implementation declaration
2353 # for this command. 2353 # for this command.
2354 # internal: If true, this is an internal command only, not exposed to the
2355 # client.
2354 # needs_size: If True a data_size field is added to the command. 2356 # needs_size: If True a data_size field is added to the command.
2355 # count: The number of units per element. For PUTn or PUT types. 2357 # count: The number of units per element. For PUTn or PUT types.
2356 # use_count_func: If True the actual data count needs to be computed; the count 2358 # use_count_func: If True the actual data count needs to be computed; the count
2357 # argument specifies the maximum count. 2359 # argument specifies the maximum count.
2358 # unit_test: If False no service side unit test will be generated. 2360 # unit_test: If False no service side unit test will be generated.
2359 # client_test: If False no client side unit test will be generated. 2361 # client_test: If False no client side unit test will be generated.
2360 # expectation: If False the unit test will have no expected calls. 2362 # expectation: If False the unit test will have no expected calls.
2361 # gen_func: Name of function that generates GL resource for corresponding 2363 # gen_func: Name of function that generates GL resource for corresponding
2362 # bind function. 2364 # bind function.
2363 # states: array of states that get set by this function corresponding to 2365 # states: array of states that get set by this function corresponding to
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2576 }, 2578 },
2577 'CoverageModulationCHROMIUM': { 2579 'CoverageModulationCHROMIUM': {
2578 'type': 'StateSet', 2580 'type': 'StateSet',
2579 'state': 'CoverageModulationCHROMIUM', 2581 'state': 'CoverageModulationCHROMIUM',
2580 'decoder_func': 'glCoverageModulationNV', 2582 'decoder_func': 'glCoverageModulationNV',
2581 'chromium': True, 2583 'chromium': True,
2582 'extension': 'CHROMIUM_framebuffer_mixed_samples', 2584 'extension': 'CHROMIUM_framebuffer_mixed_samples',
2583 'extension_flag': 'chromium_framebuffer_mixed_samples', 2585 'extension_flag': 'chromium_framebuffer_mixed_samples',
2584 }, 2586 },
2585 'CreateAndConsumeTextureCHROMIUM': { 2587 'CreateAndConsumeTextureCHROMIUM': {
2586 'decoder_func': 'DoCreateAndConsumeTextureCHROMIUM', 2588 'gen_cmd': False,
2587 'impl_func': False,
2588 'type': 'HandWritten',
2589 'data_transfer_methods': ['immediate'],
2590 'unit_test': False,
2591 'client_test': False,
2592 'extension': "CHROMIUM_texture_mailbox", 2589 'extension': "CHROMIUM_texture_mailbox",
2593 'chromium': True, 2590 'chromium': True,
2594 'trace_level': 2, 2591 'trace_level': 2,
2595 }, 2592 },
2593 'CreateAndConsumeTextureINTERNAL': {
2594 'decoder_func': 'DoCreateAndConsumeTextureINTERNAL',
2595 'internal': True,
2596 'type': 'PUT',
2597 'count': 64, # GL_MAILBOX_SIZE_CHROMIUM
2598 'unit_test': False,
2599 'trace_level': 2,
2600 },
2596 'ClearStencil': { 2601 'ClearStencil': {
2597 'type': 'StateSet', 2602 'type': 'StateSet',
2598 'state': 'ClearStencil', 2603 'state': 'ClearStencil',
2599 }, 2604 },
2600 'EnableFeatureCHROMIUM': { 2605 'EnableFeatureCHROMIUM': {
2601 'type': 'Custom', 2606 'type': 'Custom',
2602 'data_transfer_methods': ['shm'], 2607 'data_transfer_methods': ['shm'],
2603 'decoder_func': 'DoEnableFeatureCHROMIUM', 2608 'decoder_func': 'DoEnableFeatureCHROMIUM',
2604 'expectation': False, 2609 'expectation': False,
2605 'cmd_args': 'GLuint bucket_id, GLint* result', 2610 'cmd_args': 'GLuint bucket_id, GLint* result',
(...skipping 7038 matching lines...) Expand 10 before | Expand all | Expand 10 after
9644 9649
9645 def IsExtension(self): 9650 def IsExtension(self):
9646 return self.GetInfo('extension') or self.GetInfo('extension_flag') 9651 return self.GetInfo('extension') or self.GetInfo('extension_flag')
9647 9652
9648 def IsCoreGLFunction(self): 9653 def IsCoreGLFunction(self):
9649 return (not self.IsExtension() and 9654 return (not self.IsExtension() and
9650 not self.GetInfo('pepper_interface') and 9655 not self.GetInfo('pepper_interface') and
9651 not self.IsUnsafe()) 9656 not self.IsUnsafe())
9652 9657
9653 def InPepperInterface(self, interface): 9658 def InPepperInterface(self, interface):
9659 if self.GetInfo('internal'):
9660 return False
9654 ext = self.GetInfo('pepper_interface') 9661 ext = self.GetInfo('pepper_interface')
9655 if not interface.GetName(): 9662 if not interface.GetName():
9656 return self.IsCoreGLFunction() 9663 return self.IsCoreGLFunction()
9657 return ext == interface.GetName() 9664 return ext == interface.GetName()
9658 9665
9659 def InAnyPepperExtension(self): 9666 def InAnyPepperExtension(self):
9667 if self.GetInfo('internal'):
9668 return False
9660 return self.IsCoreGLFunction() or self.GetInfo('pepper_interface') 9669 return self.IsCoreGLFunction() or self.GetInfo('pepper_interface')
9661 9670
9662 def GetErrorReturnString(self): 9671 def GetErrorReturnString(self):
9663 if self.GetInfo("error_return"): 9672 if self.GetInfo("error_return"):
9664 return self.GetInfo("error_return") 9673 return self.GetInfo("error_return")
9665 elif self.return_type == "GLboolean": 9674 elif self.return_type == "GLboolean":
9666 return "GL_FALSE" 9675 return "GL_FALSE"
9667 elif "*" in self.return_type: 9676 elif "*" in self.return_type:
9668 return "NULL" 9677 return "NULL"
9669 return "0" 9678 return "0"
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
10930 func.WriteServiceUnitTest(f, { 10939 func.WriteServiceUnitTest(f, {
10931 'test_name': 'GLES2DecoderTestWith%s' % extension 10940 'test_name': 'GLES2DecoderTestWith%s' % extension
10932 }) 10941 })
10933 self.generated_cpp_filenames.append(filename) 10942 self.generated_cpp_filenames.append(filename)
10934 10943
10935 def WriteGLES2Header(self, filename): 10944 def WriteGLES2Header(self, filename):
10936 """Writes the GLES2 header.""" 10945 """Writes the GLES2 header."""
10937 comment = "// This file contains Chromium-specific GLES2 declarations.\n\n" 10946 comment = "// This file contains Chromium-specific GLES2 declarations.\n\n"
10938 with CHeaderWriter(filename, comment) as f: 10947 with CHeaderWriter(filename, comment) as f:
10939 for func in self.original_functions: 10948 for func in self.original_functions:
10949 if func.GetInfo('internal'):
10950 continue
10940 func.WriteGLES2Header(f) 10951 func.WriteGLES2Header(f)
10941 f.write("\n") 10952 f.write("\n")
10942 self.generated_cpp_filenames.append(filename) 10953 self.generated_cpp_filenames.append(filename)
10943 10954
10944 def WriteGLES2CLibImplementation(self, filename): 10955 def WriteGLES2CLibImplementation(self, filename):
10945 """Writes the GLES2 c lib implementation.""" 10956 """Writes the GLES2 c lib implementation."""
10946 comment = "// These functions emulate GLES2 over command buffers.\n" 10957 comment = "// These functions emulate GLES2 over command buffers.\n"
10947 with CHeaderWriter(filename, comment) as f: 10958 with CHeaderWriter(filename, comment) as f:
10948 for func in self.original_functions: 10959 for func in self.original_functions:
10960 if func.GetInfo('internal'):
10961 continue
10949 func.WriteGLES2CLibImplementation(f) 10962 func.WriteGLES2CLibImplementation(f)
10950 f.write(""" 10963 f.write("""
10951 namespace gles2 { 10964 namespace gles2 {
10952 10965
10953 extern const NameToFunc g_gles2_function_table[] = { 10966 extern const NameToFunc g_gles2_function_table[] = {
10954 """) 10967 """)
10955 for func in self.original_functions: 10968 for func in self.original_functions:
10969 if func.GetInfo('internal'):
10970 continue
10956 f.write( 10971 f.write(
10957 ' { "gl%s", reinterpret_cast<GLES2FunctionPointer>(gl%s), },\n' % 10972 ' { "gl%s", reinterpret_cast<GLES2FunctionPointer>(gl%s), },\n' %
10958 (func.name, func.name)) 10973 (func.name, func.name))
10959 f.write(""" { NULL, NULL, }, 10974 f.write(""" { NULL, NULL, },
10960 }; 10975 };
10961 10976
10962 } // namespace gles2 10977 } // namespace gles2
10963 """) 10978 """)
10964 self.generated_cpp_filenames.append(filename) 10979 self.generated_cpp_filenames.append(filename)
10965 10980
10966 def WriteGLES2InterfaceHeader(self, filename): 10981 def WriteGLES2InterfaceHeader(self, filename):
10967 """Writes the GLES2 interface header.""" 10982 """Writes the GLES2 interface header."""
10968 comment = ("// This file is included by gles2_interface.h to declare the\n" 10983 comment = ("// This file is included by gles2_interface.h to declare the\n"
10969 "// GL api functions.\n") 10984 "// GL api functions.\n")
10970 with CHeaderWriter(filename, comment) as f: 10985 with CHeaderWriter(filename, comment) as f:
10971 for func in self.original_functions: 10986 for func in self.original_functions:
10987 if func.GetInfo('internal'):
10988 continue
10972 func.WriteGLES2InterfaceHeader(f) 10989 func.WriteGLES2InterfaceHeader(f)
10973 self.generated_cpp_filenames.append(filename) 10990 self.generated_cpp_filenames.append(filename)
10974 10991
10975 def WriteGLES2InterfaceStub(self, filename): 10992 def WriteGLES2InterfaceStub(self, filename):
10976 """Writes the GLES2 interface stub header.""" 10993 """Writes the GLES2 interface stub header."""
10977 comment = "// This file is included by gles2_interface_stub.h.\n" 10994 comment = "// This file is included by gles2_interface_stub.h.\n"
10978 with CHeaderWriter(filename, comment) as f: 10995 with CHeaderWriter(filename, comment) as f:
10979 for func in self.original_functions: 10996 for func in self.original_functions:
10997 if func.GetInfo('internal'):
10998 continue
10980 func.WriteGLES2InterfaceStub(f) 10999 func.WriteGLES2InterfaceStub(f)
10981 self.generated_cpp_filenames.append(filename) 11000 self.generated_cpp_filenames.append(filename)
10982 11001
10983 def WriteGLES2InterfaceStubImpl(self, filename): 11002 def WriteGLES2InterfaceStubImpl(self, filename):
10984 """Writes the GLES2 interface header.""" 11003 """Writes the GLES2 interface header."""
10985 comment = "// This file is included by gles2_interface_stub.cc.\n" 11004 comment = "// This file is included by gles2_interface_stub.cc.\n"
10986 with CHeaderWriter(filename, comment) as f: 11005 with CHeaderWriter(filename, comment) as f:
10987 for func in self.original_functions: 11006 for func in self.original_functions:
11007 if func.GetInfo('internal'):
11008 continue
10988 func.WriteGLES2InterfaceStubImpl(f) 11009 func.WriteGLES2InterfaceStubImpl(f)
10989 self.generated_cpp_filenames.append(filename) 11010 self.generated_cpp_filenames.append(filename)
10990 11011
10991 def WriteGLES2ImplementationHeader(self, filename): 11012 def WriteGLES2ImplementationHeader(self, filename):
10992 """Writes the GLES2 Implementation header.""" 11013 """Writes the GLES2 Implementation header."""
10993 comment = \ 11014 comment = \
10994 ("// This file is included by gles2_implementation.h to declare the\n" 11015 ("// This file is included by gles2_implementation.h to declare the\n"
10995 "// GL api functions.\n") 11016 "// GL api functions.\n")
10996 with CHeaderWriter(filename, comment) as f: 11017 with CHeaderWriter(filename, comment) as f:
10997 for func in self.original_functions: 11018 for func in self.original_functions:
11019 if func.GetInfo('internal'):
11020 continue
10998 func.WriteGLES2ImplementationHeader(f) 11021 func.WriteGLES2ImplementationHeader(f)
10999 self.generated_cpp_filenames.append(filename) 11022 self.generated_cpp_filenames.append(filename)
11000 11023
11001 def WriteGLES2Implementation(self, filename): 11024 def WriteGLES2Implementation(self, filename):
11002 """Writes the GLES2 Implementation.""" 11025 """Writes the GLES2 Implementation."""
11003 comment = \ 11026 comment = \
11004 ("// This file is included by gles2_implementation.cc to define the\n" 11027 ("// This file is included by gles2_implementation.cc to define the\n"
11005 "// GL api functions.\n") 11028 "// GL api functions.\n")
11006 with CHeaderWriter(filename, comment) as f: 11029 with CHeaderWriter(filename, comment) as f:
11007 for func in self.original_functions: 11030 for func in self.original_functions:
11031 if func.GetInfo('internal'):
11032 continue
11008 func.WriteGLES2Implementation(f) 11033 func.WriteGLES2Implementation(f)
11009 self.generated_cpp_filenames.append(filename) 11034 self.generated_cpp_filenames.append(filename)
11010 11035
11011 def WriteGLES2TraceImplementationHeader(self, filename): 11036 def WriteGLES2TraceImplementationHeader(self, filename):
11012 """Writes the GLES2 Trace Implementation header.""" 11037 """Writes the GLES2 Trace Implementation header."""
11013 comment = "// This file is included by gles2_trace_implementation.h\n" 11038 comment = "// This file is included by gles2_trace_implementation.h\n"
11014 with CHeaderWriter(filename, comment) as f: 11039 with CHeaderWriter(filename, comment) as f:
11015 for func in self.original_functions: 11040 for func in self.original_functions:
11041 if func.GetInfo('internal'):
11042 continue
11016 func.WriteGLES2TraceImplementationHeader(f) 11043 func.WriteGLES2TraceImplementationHeader(f)
11017 self.generated_cpp_filenames.append(filename) 11044 self.generated_cpp_filenames.append(filename)
11018 11045
11019 def WriteGLES2TraceImplementation(self, filename): 11046 def WriteGLES2TraceImplementation(self, filename):
11020 """Writes the GLES2 Trace Implementation.""" 11047 """Writes the GLES2 Trace Implementation."""
11021 comment = "// This file is included by gles2_trace_implementation.cc\n" 11048 comment = "// This file is included by gles2_trace_implementation.cc\n"
11022 with CHeaderWriter(filename, comment) as f: 11049 with CHeaderWriter(filename, comment) as f:
11023 for func in self.original_functions: 11050 for func in self.original_functions:
11051 if func.GetInfo('internal'):
11052 continue
11024 func.WriteGLES2TraceImplementation(f) 11053 func.WriteGLES2TraceImplementation(f)
11025 self.generated_cpp_filenames.append(filename) 11054 self.generated_cpp_filenames.append(filename)
11026 11055
11027 def WriteGLES2ImplementationUnitTests(self, filename): 11056 def WriteGLES2ImplementationUnitTests(self, filename):
11028 """Writes the GLES2 helper header.""" 11057 """Writes the GLES2 helper header."""
11029 comment = \ 11058 comment = \
11030 ("// This file is included by gles2_implementation.h to declare the\n" 11059 ("// This file is included by gles2_implementation.h to declare the\n"
11031 "// GL api functions.\n") 11060 "// GL api functions.\n")
11032 with CHeaderWriter(filename, comment) as f: 11061 with CHeaderWriter(filename, comment) as f:
11033 for func in self.original_functions: 11062 for func in self.original_functions:
11063 if func.GetInfo('internal'):
11064 continue
11034 func.WriteGLES2ImplementationUnitTest(f) 11065 func.WriteGLES2ImplementationUnitTest(f)
11035 self.generated_cpp_filenames.append(filename) 11066 self.generated_cpp_filenames.append(filename)
11036 11067
11037 def WriteServiceUtilsHeader(self, filename): 11068 def WriteServiceUtilsHeader(self, filename):
11038 """Writes the gles2 auto generated utility header.""" 11069 """Writes the gles2 auto generated utility header."""
11039 with CHeaderWriter(filename) as f: 11070 with CHeaderWriter(filename) as f:
11040 for name in sorted(_NAMED_TYPE_INFO.keys()): 11071 for name in sorted(_NAMED_TYPE_INFO.keys()):
11041 named_type = NamedType(_NAMED_TYPE_INFO[name]) 11072 named_type = NamedType(_NAMED_TYPE_INFO[name])
11042 if not named_type.CreateValidator(): 11073 if not named_type.CreateValidator():
11043 continue 11074 continue
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
11535 Format(gen.generated_cpp_filenames) 11566 Format(gen.generated_cpp_filenames)
11536 11567
11537 if gen.errors > 0: 11568 if gen.errors > 0:
11538 print "%d errors" % gen.errors 11569 print "%d errors" % gen.errors
11539 return 1 11570 return 1
11540 return 0 11571 return 0
11541 11572
11542 11573
11543 if __name__ == '__main__': 11574 if __name__ == '__main__':
11544 sys.exit(main(sys.argv[1:])) 11575 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/client/gles2_cmd_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698