| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2017 The Chromium Authors. All rights reserved. | 2 # Copyright 2017 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 import json | 6 import json |
| 7 import os | 7 import os |
| 8 import platform | 8 import platform |
| 9 import sys | 9 import sys |
| 10 from optparse import OptionParser | 10 from optparse import OptionParser |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 data_helper_file.write('%s, // gl_reset_notification_strategy\n' % | 493 data_helper_file.write('%s, // gl_reset_notification_strategy\n' % |
| 494 gl_reset_notification_strategy) | 494 gl_reset_notification_strategy) |
| 495 write_boolean_value(direct_rendering, 'direct_rendering', data_helper_file) | 495 write_boolean_value(direct_rendering, 'direct_rendering', data_helper_file) |
| 496 write_version(gpu_count, 'gpu_count', data_helper_file) | 496 write_version(gpu_count, 'gpu_count', data_helper_file) |
| 497 data_helper_file.write('};\n\n') | 497 data_helper_file.write('};\n\n') |
| 498 # reference more data in entry | 498 # reference more data in entry |
| 499 data_file.write('&%s, // more data\n' % var_name) | 499 data_file.write('&%s, // more data\n' % var_name) |
| 500 | 500 |
| 501 | 501 |
| 502 def write_entry(entry, total_feature_set, feature_name_prefix, | 502 def write_entry(entry, total_feature_set, feature_name_prefix, |
| 503 data_file, data_helper_file, data_exception_file): | 503 data_file, data_helper_file, data_exception_file): |
| 504 data_file.write('{\n') | 504 data_file.write('{\n') |
| 505 # ID | 505 # ID |
| 506 entry_id = entry['id'] | 506 entry_id = entry['id'] |
| 507 data_file.write('%d, // id\n' % entry_id) | 507 data_file.write('%d, // id\n' % entry_id) |
| 508 data_file.write('"%s",\n' % entry['description']); | 508 data_file.write('"%s",\n' % entry['description']); |
| 509 # Features | 509 # Features |
| 510 if 'features' in entry: | 510 if 'features' in entry: |
| 511 features = entry['features'] | 511 features = entry['features'] |
| 512 feature_set = get_feature_set(features, total_feature_set) | 512 feature_set = get_feature_set(features, total_feature_set) |
| 513 data_file.write('arraysize(kFeatureListForEntry%d), // features size\n' % | 513 data_file.write('arraysize(kFeatureListForEntry%d), // features size\n' % |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 if begin: | 575 if begin: |
| 576 file.write('#ifndef %s\n#define %s\n\n' % (token, token)) | 576 file.write('#ifndef %s\n#define %s\n\n' % (token, token)) |
| 577 else: | 577 else: |
| 578 file.write('\n#endif // %s\n' % token) | 578 file.write('\n#endif // %s\n' % token) |
| 579 | 579 |
| 580 | 580 |
| 581 def process_json_file(json_filepath, list_tag, | 581 def process_json_file(json_filepath, list_tag, |
| 582 feature_header_filename, total_features, feature_tag, | 582 feature_header_filename, total_features, feature_tag, |
| 583 output_header_filepath, output_data_filepath, | 583 output_header_filepath, output_data_filepath, |
| 584 output_helper_filepath, output_exception_filepath, path, | 584 output_helper_filepath, output_exception_filepath, path, |
| 585 export_tag, git_format): | 585 export_tag, git_format, os_filter): |
| 586 output_header_filename = os.path.basename(output_header_filepath) | 586 output_header_filename = os.path.basename(output_header_filepath) |
| 587 output_helper_filename = os.path.basename(output_helper_filepath) | 587 output_helper_filename = os.path.basename(output_helper_filepath) |
| 588 output_exception_filename = os.path.basename(output_exception_filepath) | 588 output_exception_filename = os.path.basename(output_exception_filepath) |
| 589 json_file = open(json_filepath, 'rb') | 589 json_file = open(json_filepath, 'rb') |
| 590 json_data = json.load(json_file) | 590 json_data = json.load(json_file) |
| 591 json_file.close() | 591 json_file.close() |
| 592 data_file = open(output_data_filepath, 'wb') | 592 data_file = open(output_data_filepath, 'wb') |
| 593 data_file.write(_LICENSE) | 593 data_file.write(_LICENSE) |
| 594 data_file.write(_DO_NOT_EDIT_WARNING) | 594 data_file.write(_DO_NOT_EDIT_WARNING) |
| 595 data_file.write('#include "%s/%s"\n\n' % (path, output_header_filename)) | 595 data_file.write('#include "%s/%s"\n\n' % (path, output_header_filename)) |
| 596 data_file.write('#include "%s/%s"\n' % (path, output_helper_filename)) | 596 data_file.write('#include "%s/%s"\n' % (path, output_helper_filename)) |
| 597 data_file.write('#include "%s/%s"\n\n' % (path, output_exception_filename)) | 597 data_file.write('#include "%s/%s"\n\n' % (path, output_exception_filename)) |
| 598 data_helper_file = open(output_helper_filepath, 'wb') | 598 data_helper_file = open(output_helper_filepath, 'wb') |
| 599 data_helper_file.write(_LICENSE) | 599 data_helper_file.write(_LICENSE) |
| 600 data_helper_file.write(_DO_NOT_EDIT_WARNING) | 600 data_helper_file.write(_DO_NOT_EDIT_WARNING) |
| 601 write_header_file_guard(data_helper_file, output_helper_filename, path, True) | 601 write_header_file_guard(data_helper_file, output_helper_filename, path, True) |
| 602 data_helper_file.write('#include "gpu/config/%s"\n\n' % | 602 data_helper_file.write('#include "gpu/config/%s"\n\n' % |
| 603 feature_header_filename) | 603 feature_header_filename) |
| 604 data_helper_file.write('namespace gpu {\n') | 604 data_helper_file.write('namespace gpu {\n') |
| 605 data_exception_file = open(output_exception_filepath, 'wb') | 605 data_exception_file = open(output_exception_filepath, 'wb') |
| 606 data_exception_file.write(_LICENSE) | 606 data_exception_file.write(_LICENSE) |
| 607 data_exception_file.write(_DO_NOT_EDIT_WARNING) | 607 data_exception_file.write(_DO_NOT_EDIT_WARNING) |
| 608 write_header_file_guard(data_exception_file, output_exception_filename, path, | 608 write_header_file_guard(data_exception_file, output_exception_filename, path, |
| 609 True) | 609 True) |
| 610 data_exception_file.write('namespace gpu {\n') | 610 data_exception_file.write('namespace gpu {\n') |
| 611 data_file.write('namespace gpu {\n\n') | 611 data_file.write('namespace gpu {\n\n') |
| 612 data_file.write('const char k%sVersion[] = "%s";\n\n' % | 612 data_file.write('const char k%sVersion[] = "%s";\n\n' % |
| 613 (list_tag, json_data['version'])) | 613 (list_tag, json_data['version'])) |
| 614 entry_count = len(json_data['entries']) | 614 data_file.write('const GpuControlList::Entry k%sEntries[] = {\n' % list_tag) |
| 615 data_file.write('const size_t k%sEntryCount = %d;\n' % | |
| 616 (list_tag, entry_count)) | |
| 617 data_file.write('const GpuControlList::Entry k%sEntries[%d] = {\n' % | |
| 618 (list_tag, entry_count)) | |
| 619 ids = [] | 615 ids = [] |
| 620 for index in range(entry_count): | 616 entry_count = 0 |
| 617 for index in range(len(json_data['entries'])): |
| 621 entry = json_data['entries'][index] | 618 entry = json_data['entries'][index] |
| 622 entry_id = entry['id'] | 619 entry_id = entry['id'] |
| 623 assert entry_id not in ids | 620 assert entry_id not in ids |
| 624 ids.append(entry_id) | 621 ids.append(entry_id) |
| 622 if os_filter != None and 'os' in entry and entry['os']['type'] != os_filter: |
| 623 continue |
| 624 entry_count += 1 |
| 625 write_entry(entry, total_features, feature_tag, | 625 write_entry(entry, total_features, feature_tag, |
| 626 data_file, data_helper_file, data_exception_file) | 626 data_file, data_helper_file, data_exception_file) |
| 627 data_file.write('};\n') | 627 data_file.write('};\n') |
| 628 data_file.write('const size_t k%sEntryCount = %d;\n' % |
| 629 (list_tag, entry_count)) |
| 628 data_file.write('} // namespace gpu\n') | 630 data_file.write('} // namespace gpu\n') |
| 629 data_file.close() | 631 data_file.close() |
| 630 data_helper_file.write('} // namespace gpu\n') | 632 data_helper_file.write('} // namespace gpu\n') |
| 631 write_header_file_guard(data_helper_file, output_helper_filename, path, False) | 633 write_header_file_guard(data_helper_file, output_helper_filename, path, False) |
| 632 data_helper_file.close() | 634 data_helper_file.close() |
| 633 data_exception_file.write('} // namespace gpu\n') | 635 data_exception_file.write('} // namespace gpu\n') |
| 634 write_header_file_guard(data_exception_file, output_exception_filename, path, | 636 write_header_file_guard(data_exception_file, output_exception_filename, path, |
| 635 False) | 637 False) |
| 636 data_exception_file.close() | 638 data_exception_file.close() |
| 637 data_header_file = open(output_header_filepath, 'wb') | 639 data_header_file = open(output_header_filepath, 'wb') |
| (...skipping 13 matching lines...) Expand all Loading... |
| 651 '%sextern const GpuControlList::Entry k%sEntries[];\n' % | 653 '%sextern const GpuControlList::Entry k%sEntries[];\n' % |
| 652 (export_tag, list_tag)) | 654 (export_tag, list_tag)) |
| 653 data_header_file.write('} // namespace gpu\n') | 655 data_header_file.write('} // namespace gpu\n') |
| 654 write_header_file_guard(data_header_file, output_header_filename, path, False) | 656 write_header_file_guard(data_header_file, output_header_filename, path, False) |
| 655 data_header_file.close() | 657 data_header_file.close() |
| 656 if git_format: | 658 if git_format: |
| 657 format_files([output_header_filepath, output_data_filepath, | 659 format_files([output_header_filepath, output_data_filepath, |
| 658 output_helper_filepath, output_exception_filepath]) | 660 output_helper_filepath, output_exception_filepath]) |
| 659 | 661 |
| 660 | 662 |
| 661 def process_software_rendering_list(script_dir, output_dir): | 663 def process_software_rendering_list(script_dir, output_dir, os_filter): |
| 662 total_features = load_software_rendering_list_features( | 664 total_features = load_software_rendering_list_features( |
| 663 os.path.join(script_dir, 'gpu_feature_type.h')) | 665 os.path.join(script_dir, 'gpu_feature_type.h')) |
| 664 process_json_file( | 666 process_json_file( |
| 665 os.path.join(script_dir, 'software_rendering_list.json'), | 667 os.path.join(script_dir, 'software_rendering_list.json'), |
| 666 'SoftwareRenderingList', | 668 'SoftwareRenderingList', |
| 667 'gpu_feature_type.h', | 669 'gpu_feature_type.h', |
| 668 total_features, | 670 total_features, |
| 669 'GPU_FEATURE_TYPE_', | 671 'GPU_FEATURE_TYPE_', |
| 670 os.path.join(output_dir, 'software_rendering_list_autogen.h'), | 672 os.path.join(output_dir, 'software_rendering_list_autogen.h'), |
| 671 os.path.join(output_dir, 'software_rendering_list_autogen.cc'), | 673 os.path.join(output_dir, 'software_rendering_list_autogen.cc'), |
| 672 os.path.join(output_dir, | 674 os.path.join(output_dir, |
| 673 'software_rendering_list_arrays_and_structs_autogen.h'), | 675 'software_rendering_list_arrays_and_structs_autogen.h'), |
| 674 os.path.join(output_dir, 'software_rendering_list_exceptions_autogen.h'), | 676 os.path.join(output_dir, 'software_rendering_list_exceptions_autogen.h'), |
| 675 'gpu/config', | 677 'gpu/config', |
| 676 'GPU_EXPORT ', | 678 'GPU_EXPORT ', |
| 677 False) | 679 False, |
| 680 os_filter) |
| 678 | 681 |
| 679 | 682 |
| 680 def process_gpu_driver_bug_list(script_dir, output_dir): | 683 def process_gpu_driver_bug_list(script_dir, output_dir, os_filter): |
| 681 total_features = load_gpu_driver_bug_workarounds( | 684 total_features = load_gpu_driver_bug_workarounds( |
| 682 os.path.join(script_dir, 'gpu_driver_bug_workaround_type.h')) | 685 os.path.join(script_dir, 'gpu_driver_bug_workaround_type.h')) |
| 683 process_json_file( | 686 process_json_file( |
| 684 os.path.join(script_dir, 'gpu_driver_bug_list.json'), | 687 os.path.join(script_dir, 'gpu_driver_bug_list.json'), |
| 685 'GpuDriverBugList', | 688 'GpuDriverBugList', |
| 686 'gpu_driver_bug_workaround_type.h', | 689 'gpu_driver_bug_workaround_type.h', |
| 687 total_features, | 690 total_features, |
| 688 '', | 691 '', |
| 689 os.path.join(output_dir, 'gpu_driver_bug_list_autogen.h'), | 692 os.path.join(output_dir, 'gpu_driver_bug_list_autogen.h'), |
| 690 os.path.join(output_dir, 'gpu_driver_bug_list_autogen.cc'), | 693 os.path.join(output_dir, 'gpu_driver_bug_list_autogen.cc'), |
| 691 os.path.join(output_dir, | 694 os.path.join(output_dir, |
| 692 'gpu_driver_bug_list_arrays_and_structs_autogen.h'), | 695 'gpu_driver_bug_list_arrays_and_structs_autogen.h'), |
| 693 os.path.join(output_dir, 'gpu_driver_bug_list_exceptions_autogen.h'), | 696 os.path.join(output_dir, 'gpu_driver_bug_list_exceptions_autogen.h'), |
| 694 'gpu/config', | 697 'gpu/config', |
| 695 'GPU_EXPORT ', | 698 'GPU_EXPORT ', |
| 696 False) | 699 False, |
| 700 os_filter) |
| 697 | 701 |
| 698 | 702 |
| 699 def process_gpu_control_list_testing(script_dir, output_dir): | 703 def process_gpu_control_list_testing(script_dir, output_dir): |
| 700 total_features = ['test_feature_0', 'test_feature_1', 'test_feature_2'] | 704 total_features = ['test_feature_0', 'test_feature_1', 'test_feature_2'] |
| 701 process_json_file( | 705 process_json_file( |
| 702 os.path.join(script_dir, 'gpu_control_list_testing.json'), | 706 os.path.join(script_dir, 'gpu_control_list_testing.json'), |
| 703 'GpuControlListTesting', | 707 'GpuControlListTesting', |
| 704 'gpu_control_list_testing_data.h', | 708 'gpu_control_list_testing_data.h', |
| 705 total_features, | 709 total_features, |
| 706 '', | 710 '', |
| 707 os.path.join(output_dir, 'gpu_control_list_testing_autogen.h'), | 711 os.path.join(output_dir, 'gpu_control_list_testing_autogen.h'), |
| 708 os.path.join(output_dir, 'gpu_control_list_testing_autogen.cc'), | 712 os.path.join(output_dir, 'gpu_control_list_testing_autogen.cc'), |
| 709 os.path.join(output_dir, | 713 os.path.join(output_dir, |
| 710 'gpu_control_list_testing_arrays_and_structs_autogen.h'), | 714 'gpu_control_list_testing_arrays_and_structs_autogen.h'), |
| 711 os.path.join(output_dir, 'gpu_control_list_testing_exceptions_autogen.h'), | 715 os.path.join(output_dir, 'gpu_control_list_testing_exceptions_autogen.h'), |
| 712 'gpu/config', | 716 'gpu/config', |
| 713 '', | 717 '', |
| 714 True) | 718 True, |
| 719 None) |
| 715 | 720 |
| 716 | 721 |
| 717 def process_gpu_data_manager_testing(script_dir, output_dir): | 722 def process_gpu_data_manager_testing(script_dir, output_dir): |
| 718 total_features = load_software_rendering_list_features( | 723 total_features = load_software_rendering_list_features( |
| 719 os.path.join(script_dir, 'gpu_feature_type.h')) | 724 os.path.join(script_dir, 'gpu_feature_type.h')) |
| 720 process_json_file( | 725 process_json_file( |
| 721 os.path.join(output_dir, 'gpu_data_manager_testing.json'), | 726 os.path.join(output_dir, 'gpu_data_manager_testing.json'), |
| 722 'GpuDataManagerTesting', | 727 'GpuDataManagerTesting', |
| 723 'gpu_feature_type.h', | 728 'gpu_feature_type.h', |
| 724 total_features, | 729 total_features, |
| 725 'GPU_FEATURE_TYPE_', | 730 'GPU_FEATURE_TYPE_', |
| 726 os.path.join(output_dir, 'gpu_data_manager_testing_autogen.h'), | 731 os.path.join(output_dir, 'gpu_data_manager_testing_autogen.h'), |
| 727 os.path.join(output_dir, 'gpu_data_manager_testing_autogen.cc'), | 732 os.path.join(output_dir, 'gpu_data_manager_testing_autogen.cc'), |
| 728 os.path.join(output_dir, | 733 os.path.join(output_dir, |
| 729 'gpu_data_manager_testing_arrays_and_structs_autogen.h'), | 734 'gpu_data_manager_testing_arrays_and_structs_autogen.h'), |
| 730 os.path.join(output_dir, 'gpu_data_manager_testing_exceptions_autogen.h'), | 735 os.path.join(output_dir, 'gpu_data_manager_testing_exceptions_autogen.h'), |
| 731 'content/browser/gpu', | 736 'content/browser/gpu', |
| 732 '', | 737 '', |
| 733 True) | 738 True, |
| 739 None) |
| 734 | 740 |
| 735 | 741 |
| 736 def write_test_entry_enums(input_json_filepath, output_entry_enums_filepath, | 742 def write_test_entry_enums(input_json_filepath, output_entry_enums_filepath, |
| 737 path, list_tag): | 743 path, list_tag): |
| 738 json_file = open(input_json_filepath, 'rb') | 744 json_file = open(input_json_filepath, 'rb') |
| 739 json_data = json.load(json_file) | 745 json_data = json.load(json_file) |
| 740 json_file.close() | 746 json_file.close() |
| 741 | 747 |
| 742 output_entry_enums_filename = os.path.basename(output_entry_enums_filepath) | 748 output_entry_enums_filename = os.path.basename(output_entry_enums_filepath) |
| 743 enum_file = open(output_entry_enums_filepath, 'wb') | 749 enum_file = open(output_entry_enums_filepath, 'wb') |
| (...skipping 20 matching lines...) Expand all Loading... |
| 764 | 770 |
| 765 def main(argv): | 771 def main(argv): |
| 766 parser = OptionParser() | 772 parser = OptionParser() |
| 767 parser.add_option("--output-dir", | 773 parser.add_option("--output-dir", |
| 768 help="output directory for SoftwareRenderingList and " | 774 help="output directory for SoftwareRenderingList and " |
| 769 "GpuDriverBugList data files. " | 775 "GpuDriverBugList data files. " |
| 770 "If unspecified, these files are not generated.") | 776 "If unspecified, these files are not generated.") |
| 771 parser.add_option("--skip-testing-data", action="store_false", | 777 parser.add_option("--skip-testing-data", action="store_false", |
| 772 dest="generate_testing_data", default=True, | 778 dest="generate_testing_data", default=True, |
| 773 help="skip testing data generation.") | 779 help="skip testing data generation.") |
| 780 parser.add_option("--os-filter", |
| 781 help="only output entries applied to the specified os.") |
| 774 (options, args) = parser.parse_args(args=argv) | 782 (options, args) = parser.parse_args(args=argv) |
| 775 | 783 |
| 776 script_dir = os.path.dirname(os.path.realpath(__file__)) | 784 script_dir = os.path.dirname(os.path.realpath(__file__)) |
| 777 | 785 |
| 778 if options.output_dir != None: | 786 if options.output_dir != None: |
| 779 process_software_rendering_list(script_dir, options.output_dir) | 787 process_software_rendering_list( |
| 780 process_gpu_driver_bug_list(script_dir, options.output_dir) | 788 script_dir, options.output_dir, options.os_filter) |
| 789 process_gpu_driver_bug_list( |
| 790 script_dir, options.output_dir, options.os_filter) |
| 781 | 791 |
| 782 if options.generate_testing_data: | 792 if options.generate_testing_data: |
| 783 # Testing data files are generated by calling the script manually. | 793 # Testing data files are generated by calling the script manually. |
| 784 process_gpu_control_list_testing(script_dir, script_dir) | 794 process_gpu_control_list_testing(script_dir, script_dir) |
| 785 write_test_entry_enums( | 795 write_test_entry_enums( |
| 786 os.path.join(script_dir, 'gpu_control_list_testing.json'), | 796 os.path.join(script_dir, 'gpu_control_list_testing.json'), |
| 787 os.path.join(script_dir, | 797 os.path.join(script_dir, |
| 788 'gpu_control_list_testing_entry_enums_autogen.h'), | 798 'gpu_control_list_testing_entry_enums_autogen.h'), |
| 789 'gpu/config', | 799 'gpu/config', |
| 790 'GpuControlListTesting') | 800 'GpuControlListTesting') |
| 791 chrome_root_dir = os.path.abspath(os.path.join(script_dir, '../../')) | 801 chrome_root_dir = os.path.abspath(os.path.join(script_dir, '../../')) |
| 792 gpu_data_manager_dir = os.path.join(chrome_root_dir, 'content/browser/gpu') | 802 gpu_data_manager_dir = os.path.join(chrome_root_dir, 'content/browser/gpu') |
| 793 process_gpu_data_manager_testing(script_dir, gpu_data_manager_dir) | 803 process_gpu_data_manager_testing(script_dir, gpu_data_manager_dir) |
| 794 write_test_entry_enums( | 804 write_test_entry_enums( |
| 795 os.path.join(gpu_data_manager_dir, 'gpu_data_manager_testing.json'), | 805 os.path.join(gpu_data_manager_dir, 'gpu_data_manager_testing.json'), |
| 796 os.path.join(gpu_data_manager_dir, | 806 os.path.join(gpu_data_manager_dir, |
| 797 'gpu_data_manager_testing_entry_enums_autogen.h'), | 807 'gpu_data_manager_testing_entry_enums_autogen.h'), |
| 798 'content/browser/gpu', | 808 'content/browser/gpu', |
| 799 'GpuDataManagerTesting') | 809 'GpuDataManagerTesting') |
| 800 | 810 |
| 801 | 811 |
| 802 if __name__ == '__main__': | 812 if __name__ == '__main__': |
| 803 sys.exit(main(sys.argv[1:])) | 813 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |