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

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

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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
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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 }, 537 },
538 ], 538 ],
539 }, 539 },
540 } 540 }
541 541
542 # Named type info object represents a named type that is used in OpenGL call 542 # Named type info object represents a named type that is used in OpenGL call
543 # arguments. Each named type defines a set of valid OpenGL call arguments. The 543 # arguments. Each named type defines a set of valid OpenGL call arguments. The
544 # named types are used in 'cmd_buffer_functions.txt'. 544 # named types are used in 'cmd_buffer_functions.txt'.
545 # type: The actual GL type of the named type. 545 # type: The actual GL type of the named type.
546 # valid: The list of values that are valid for both the client and the service. 546 # valid: The list of values that are valid for both the client and the service.
547 # valid_es3: The list of values that are valid in OpenGL ES 3, but not ES 2.
547 # invalid: Examples of invalid values for the type. At least these values 548 # invalid: Examples of invalid values for the type. At least these values
548 # should be tested to be invalid. 549 # should be tested to be invalid.
549 # is_complete: The list of valid values of type are final and will not be 550 # is_complete: The list of valid values of type are final and will not be
550 # modified during runtime. 551 # modified during runtime.
551 _NAMED_TYPE_INFO = { 552 _NAMED_TYPE_INFO = {
552 'BlitFilter': { 553 'BlitFilter': {
553 'type': 'GLenum', 554 'type': 'GLenum',
554 'valid': [ 555 'valid': [
555 'GL_NEAREST', 556 'GL_NEAREST',
556 'GL_LINEAR', 557 'GL_LINEAR',
(...skipping 20 matching lines...) Expand all
577 'invalid': [ 578 'invalid': [
578 'GL_FRAMEBUFFER', 579 'GL_FRAMEBUFFER',
579 ], 580 ],
580 }, 581 },
581 'BufferTarget': { 582 'BufferTarget': {
582 'type': 'GLenum', 583 'type': 'GLenum',
583 'valid': [ 584 'valid': [
584 'GL_ARRAY_BUFFER', 585 'GL_ARRAY_BUFFER',
585 'GL_ELEMENT_ARRAY_BUFFER', 586 'GL_ELEMENT_ARRAY_BUFFER',
586 ], 587 ],
588 'valid_es3': [
589 'GL_COPY_READ_BUFFER',
590 'GL_COPY_WRITE_BUFFER',
591 'GL_PIXEL_PACK_BUFFER',
592 'GL_PIXEL_UNPACK_BUFFER',
593 'GL_TRANSFORM_FEEDBACK_BUFFER',
594 'GL_UNIFORM_BUFFER',
595 ],
587 'invalid': [ 596 'invalid': [
588 'GL_RENDERBUFFER', 597 'GL_RENDERBUFFER',
589 ], 598 ],
590 }, 599 },
591 'IndexedBufferTarget': { 600 'IndexedBufferTarget': {
592 'type': 'GLenum', 601 'type': 'GLenum',
593 'valid': [ 602 'valid': [
594 'GL_TRANSFORM_FEEDBACK_BUFFER', 603 'GL_TRANSFORM_FEEDBACK_BUFFER',
595 'GL_UNIFORM_BUFFER', 604 'GL_UNIFORM_BUFFER',
596 ], 605 ],
597 'invalid': [ 606 'invalid': [
598 'GL_RENDERBUFFER', 607 'GL_RENDERBUFFER',
599 ], 608 ],
600 }, 609 },
610 'MapBufferAccess': {
611 'type': 'GLenum',
612 'valid': [
613 'GL_MAP_READ_BIT',
614 'GL_MAP_WRITE_BIT',
615 'GL_MAP_INVALIDATE_RANGE_BIT',
616 'GL_MAP_INVALIDATE_BUFFER_BIT',
617 'GL_MAP_FLUSH_EXPLICIT_BIT',
618 'GL_MAP_UNSYNCHRONIZED_BIT',
619 ],
620 'invalid': [
621 'GL_SYNC_FLUSH_COMMANDS_BIT',
622 ],
623 },
601 'Bufferiv': { 624 'Bufferiv': {
602 'type': 'GLenum', 625 'type': 'GLenum',
603 'valid': [ 626 'valid': [
604 'GL_COLOR', 627 'GL_COLOR',
605 'GL_STENCIL', 628 'GL_STENCIL',
606 ], 629 ],
607 'invalid': [ 630 'invalid': [
608 'GL_RENDERBUFFER', 631 'GL_RENDERBUFFER',
609 ], 632 ],
610 }, 633 },
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 'trace_level': 2, 1995 'trace_level': 2,
1973 }, 1996 },
1974 'DrawElements': { 1997 'DrawElements': {
1975 'type': 'Manual', 1998 'type': 'Manual',
1976 'cmd_args': 'GLenumDrawMode mode, GLsizei count, ' 1999 'cmd_args': 'GLenumDrawMode mode, GLsizei count, '
1977 'GLenumIndexType type, GLuint index_offset', 2000 'GLenumIndexType type, GLuint index_offset',
1978 'client_test': False, 2001 'client_test': False,
1979 'defer_draws': True, 2002 'defer_draws': True,
1980 'trace_level': 2, 2003 'trace_level': 2,
1981 }, 2004 },
2005 'DrawRangeElements': {
2006 'type': 'Manual',
2007 'gen_cmd': 'False',
2008 'unsafe': True,
2009 },
1982 'Enable': { 2010 'Enable': {
1983 'decoder_func': 'DoEnable', 2011 'decoder_func': 'DoEnable',
1984 'impl_func': False, 2012 'impl_func': False,
1985 'client_test': False, 2013 'client_test': False,
1986 }, 2014 },
1987 'EnableVertexAttribArray': { 2015 'EnableVertexAttribArray': {
1988 'decoder_func': 'DoEnableVertexAttribArray', 2016 'decoder_func': 'DoEnableVertexAttribArray',
1989 'impl_decl': False, 2017 'impl_decl': False,
1990 }, 2018 },
1991 'FenceSync': { 2019 'FenceSync': {
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
2487 'client_test': False, 2515 'client_test': False,
2488 'pepper_interface': 'ChromiumMapSub', 2516 'pepper_interface': 'ChromiumMapSub',
2489 }, 2517 },
2490 'MapTexSubImage2DCHROMIUM': { 2518 'MapTexSubImage2DCHROMIUM': {
2491 'gen_cmd': False, 2519 'gen_cmd': False,
2492 'extension': True, 2520 'extension': True,
2493 'chromium': True, 2521 'chromium': True,
2494 'client_test': False, 2522 'client_test': False,
2495 'pepper_interface': 'ChromiumMapSub', 2523 'pepper_interface': 'ChromiumMapSub',
2496 }, 2524 },
2525 'MapBufferRange': {
2526 'type': 'Custom',
2527 'data_transfer_methods': ['shm'],
2528 'cmd_args': 'GLenumBufferTarget target, GLintptrNotNegative offset, '
2529 'GLsizeiptr size, GLbitfieldMapBufferAccess access, '
2530 'uint32_t data_shm_id, uint32_t data_shm_offset, '
2531 'uint32_t result_shm_id, uint32_t result_shm_offset',
2532 'unsafe': True,
2533 'result': ['uint32_t'],
2534 },
2497 'PauseTransformFeedback': { 2535 'PauseTransformFeedback': {
2498 'unsafe': True, 2536 'unsafe': True,
2499 }, 2537 },
2500 'PixelStorei': {'type': 'Manual'}, 2538 'PixelStorei': {'type': 'Manual'},
2501 'PostSubBufferCHROMIUM': { 2539 'PostSubBufferCHROMIUM': {
2502 'type': 'Custom', 2540 'type': 'Custom',
2503 'impl_func': False, 2541 'impl_func': False,
2504 'unit_test': False, 2542 'unit_test': False,
2505 'client_test': False, 2543 'client_test': False,
2506 'extension': True, 2544 'extension': True,
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2872 'chromium': True, 2910 'chromium': True,
2873 'client_test': False, 2911 'client_test': False,
2874 }, 2912 },
2875 'UnmapBufferSubDataCHROMIUM': { 2913 'UnmapBufferSubDataCHROMIUM': {
2876 'gen_cmd': False, 2914 'gen_cmd': False,
2877 'extension': True, 2915 'extension': True,
2878 'chromium': True, 2916 'chromium': True,
2879 'client_test': False, 2917 'client_test': False,
2880 'pepper_interface': 'ChromiumMapSub', 2918 'pepper_interface': 'ChromiumMapSub',
2881 }, 2919 },
2920 'UnmapBuffer': {
2921 'type': 'Custom',
2922 'unsafe': True,
2923 },
2882 'UnmapTexSubImage2DCHROMIUM': { 2924 'UnmapTexSubImage2DCHROMIUM': {
2883 'gen_cmd': False, 2925 'gen_cmd': False,
2884 'extension': True, 2926 'extension': True,
2885 'chromium': True, 2927 'chromium': True,
2886 'client_test': False, 2928 'client_test': False,
2887 'pepper_interface': 'ChromiumMapSub', 2929 'pepper_interface': 'ChromiumMapSub',
2888 }, 2930 },
2889 'UseProgram': { 2931 'UseProgram': {
2890 'type': 'Bind', 2932 'type': 'Bind',
2891 'decoder_func': 'DoUseProgram', 2933 'decoder_func': 'DoUseProgram',
(...skipping 4608 matching lines...) Expand 10 before | Expand all | Expand 10 after
7500 """ 7542 """
7501 7543
7502 def __init__(self, info): 7544 def __init__(self, info):
7503 assert not 'is_complete' in info or info['is_complete'] == True 7545 assert not 'is_complete' in info or info['is_complete'] == True
7504 self.info = info 7546 self.info = info
7505 self.valid = info['valid'] 7547 self.valid = info['valid']
7506 if 'invalid' in info: 7548 if 'invalid' in info:
7507 self.invalid = info['invalid'] 7549 self.invalid = info['invalid']
7508 else: 7550 else:
7509 self.invalid = [] 7551 self.invalid = []
7552 if 'valid_es3' in info:
7553 self.valid_es3 = info['valid_es3']
7554 else:
7555 self.valid_es3 = []
7510 7556
7511 def GetType(self): 7557 def GetType(self):
7512 return self.info['type'] 7558 return self.info['type']
7513 7559
7514 def GetInvalidValues(self): 7560 def GetInvalidValues(self):
7515 return self.invalid 7561 return self.invalid
7516 7562
7517 def GetValidValues(self): 7563 def GetValidValues(self):
7518 return self.valid 7564 return self.valid
7519 7565
7566 def GetValidValuesES3(self):
7567 return self.valid_es3
7568
7520 def IsConstant(self): 7569 def IsConstant(self):
7521 if not 'is_complete' in self.info: 7570 if not 'is_complete' in self.info:
7522 return False 7571 return False
7523 7572
7524 return len(self.GetValidValues()) == 1 7573 return len(self.GetValidValues()) == 1
7525 7574
7526 def GetConstantValue(self): 7575 def GetConstantValue(self):
7527 return self.GetValidValues()[0] 7576 return self.GetValidValues()[0]
7528 7577
7529 class Argument(object): 7578 class Argument(object):
(...skipping 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after
9809 named_type = NamedType(_NAMED_TYPE_INFO[name]) 9858 named_type = NamedType(_NAMED_TYPE_INFO[name])
9810 if named_type.IsConstant(): 9859 if named_type.IsConstant():
9811 continue 9860 continue
9812 if named_type.GetValidValues(): 9861 if named_type.GetValidValues():
9813 file.Write("static const %s valid_%s_table[] = {\n" % 9862 file.Write("static const %s valid_%s_table[] = {\n" %
9814 (named_type.GetType(), ToUnderscore(name))) 9863 (named_type.GetType(), ToUnderscore(name)))
9815 for value in named_type.GetValidValues(): 9864 for value in named_type.GetValidValues():
9816 file.Write(" %s,\n" % value) 9865 file.Write(" %s,\n" % value)
9817 file.Write("};\n") 9866 file.Write("};\n")
9818 file.Write("\n") 9867 file.Write("\n")
9868 if named_type.GetValidValuesES3():
9869 file.Write("static const %s valid_%s_table_es3[] = {\n" %
9870 (named_type.GetType(), ToUnderscore(name)))
9871 for value in named_type.GetValidValuesES3():
9872 file.Write(" %s,\n" % value)
9873 file.Write("};\n")
9874 file.Write("\n")
9819 file.Write("Validators::Validators()") 9875 file.Write("Validators::Validators()")
9820 pre = ' : ' 9876 pre = ' : '
9821 for count, name in enumerate(names): 9877 for count, name in enumerate(names):
9822 named_type = NamedType(_NAMED_TYPE_INFO[name]) 9878 named_type = NamedType(_NAMED_TYPE_INFO[name])
9823 if named_type.IsConstant(): 9879 if named_type.IsConstant():
9824 continue 9880 continue
9825 if named_type.GetValidValues(): 9881 if named_type.GetValidValues():
9826 code = """%(pre)s%(name)s( 9882 code = """%(pre)s%(name)s(
9827 valid_%(name)s_table, arraysize(valid_%(name)s_table))""" 9883 valid_%(name)s_table, arraysize(valid_%(name)s_table))"""
9828 else: 9884 else:
9829 code = "%(pre)s%(name)s()" 9885 code = "%(pre)s%(name)s()"
9830 file.Write(code % { 9886 file.Write(code % {
9831 'name': ToUnderscore(name), 9887 'name': ToUnderscore(name),
9832 'pre': pre, 9888 'pre': pre,
9833 }) 9889 })
9834 pre = ',\n ' 9890 pre = ',\n '
9835 file.Write(" {\n"); 9891 file.Write(" {\n");
9836 file.Write("}\n\n"); 9892 file.Write("}\n\n");
9893
9894 file.Write("void Validators::AddES3Values() {\n")
9895 for name in names:
9896 named_type = NamedType(_NAMED_TYPE_INFO[name])
9897 if named_type.GetValidValuesES3():
9898 code = """ %(name)s.AddValues(
9899 valid_%(name)s_table_es3, arraysize(valid_%(name)s_table_es3));
9900 """
9901 file.Write(code % {
9902 'name': ToUnderscore(name),
9903 })
9904 file.Write("}\n\n");
9837 file.Close() 9905 file.Close()
9838 self.generated_cpp_filenames.append(file.filename) 9906 self.generated_cpp_filenames.append(file.filename)
9839 9907
9840 def WriteCommonUtilsHeader(self, filename): 9908 def WriteCommonUtilsHeader(self, filename):
9841 """Writes the gles2 common utility header.""" 9909 """Writes the gles2 common utility header."""
9842 file = CHeaderWriter(filename) 9910 file = CHeaderWriter(filename)
9843 type_infos = sorted(_NAMED_TYPE_INFO.keys()) 9911 type_infos = sorted(_NAMED_TYPE_INFO.keys())
9844 for type_info in type_infos: 9912 for type_info in type_infos:
9845 if _NAMED_TYPE_INFO[type_info]['type'] == 'GLenum': 9913 if _NAMED_TYPE_INFO[type_info]['type'] == 'GLenum':
9846 file.Write("static std::string GetString%s(uint32_t value);\n" % 9914 file.Write("static std::string GetString%s(uint32_t value);\n" %
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
9885 const size_t GLES2Util::enum_to_string_table_len_ = 9953 const size_t GLES2Util::enum_to_string_table_len_ =
9886 sizeof(enum_to_string_table) / sizeof(enum_to_string_table[0]); 9954 sizeof(enum_to_string_table) / sizeof(enum_to_string_table[0]);
9887 9955
9888 """) 9956 """)
9889 9957
9890 enums = sorted(_NAMED_TYPE_INFO.keys()) 9958 enums = sorted(_NAMED_TYPE_INFO.keys())
9891 for enum in enums: 9959 for enum in enums:
9892 if _NAMED_TYPE_INFO[enum]['type'] == 'GLenum': 9960 if _NAMED_TYPE_INFO[enum]['type'] == 'GLenum':
9893 file.Write("std::string GLES2Util::GetString%s(uint32_t value) {\n" % 9961 file.Write("std::string GLES2Util::GetString%s(uint32_t value) {\n" %
9894 enum) 9962 enum)
9895 if len(_NAMED_TYPE_INFO[enum]['valid']) > 0: 9963 valid_list = _NAMED_TYPE_INFO[enum]['valid']
9964 if 'valid_es3' in _NAMED_TYPE_INFO[enum]:
9965 valid_list = valid_list + _NAMED_TYPE_INFO[enum]['valid_es3']
9966 assert len(valid_list) == len(set(valid_list))
9967 if len(valid_list) > 0:
9896 file.Write(" static const EnumToString string_table[] = {\n") 9968 file.Write(" static const EnumToString string_table[] = {\n")
9897 for value in _NAMED_TYPE_INFO[enum]['valid']: 9969 for value in valid_list:
9898 file.Write(' { %s, "%s" },\n' % (value, value)) 9970 file.Write(' { %s, "%s" },\n' % (value, value))
9899 file.Write(""" }; 9971 file.Write(""" };
9900 return GLES2Util::GetQualifiedEnumString( 9972 return GLES2Util::GetQualifiedEnumString(
9901 string_table, arraysize(string_table), value); 9973 string_table, arraysize(string_table), value);
9902 } 9974 }
9903 9975
9904 """) 9976 """)
9905 else: 9977 else:
9906 file.Write(""" return GLES2Util::GetQualifiedEnumString( 9978 file.Write(""" return GLES2Util::GetQualifiedEnumString(
9907 NULL, 0, value); 9979 NULL, 0, value);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
10252 Format(gen.generated_cpp_filenames) 10324 Format(gen.generated_cpp_filenames)
10253 10325
10254 if gen.errors > 0: 10326 if gen.errors > 0:
10255 print "%d errors" % gen.errors 10327 print "%d errors" % gen.errors
10256 return 1 10328 return 1
10257 return 0 10329 return 0
10258 10330
10259 10331
10260 if __name__ == '__main__': 10332 if __name__ == '__main__':
10261 sys.exit(main(sys.argv[1:])) 10333 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.cc ('k') | gpu/command_buffer/client/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698