Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
malioc_cores.py
Go to the documentation of this file.
1#!/usr/bin/env vpython3
2# Copyright 2013 The Flutter Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import argparse
7import json
8import os
9import subprocess
10import sys
11
12# This script parses the JSON output produced by malioc about GPU cores,
13# and outputs it in a form that can be consumed by GN
14
15
16def parse_args(argv):
17 parser = argparse.ArgumentParser(
18 description='This script sanitizes GPU core info output from malioc',
19 )
20 parser.add_argument(
21 '--malioc',
22 '-m',
23 type=str,
24 help='The path to malioc.',
25 )
26 parser.add_argument(
27 '--output',
28 '-o',
29 type=str,
30 help='The output path.',
31 )
32 return parser.parse_args(argv)
33
34
35def validate_args(args):
36 if not args.malioc or not os.path.isfile(args.malioc):
37 print('The --malioc argument must refer to the malioc binary.')
38 return False
39 return True
40
41
42def malioc_core_list(malioc):
43 malioc_cores = subprocess.check_output(
44 [malioc, '--list', '--format', 'json'],
45 stderr=subprocess.STDOUT,
46 )
47 cores_json = json.loads(malioc_cores)
48 cores = []
49 for core in cores_json['cores']:
50 cores.append(core['core'])
51 return cores
52
53
54def malioc_core_info(malioc, core):
55 malioc_info = subprocess.check_output(
56 [malioc, '--info', '--core', core, '--format', 'json'],
57 stderr=subprocess.STDOUT,
58 )
59 info_json = json.loads(malioc_info)
60
61 apis = info_json['apis']
62
63 opengles_max_version = 0
64 if 'opengles' in apis:
65 opengles = apis['opengles']
66 if opengles['max_version'] is not None:
67 opengles_max_version = opengles['max_version']
68 vulkan_max_version = 0
69 if 'vulkan' in apis:
70 vulkan = apis['vulkan']
71 if vulkan['max_version'] is not None:
72 vulkan_max_version = int(vulkan['max_version'] * 100)
73
74 info = {
75 'core': core,
76 'opengles_max_version': opengles_max_version,
77 'vulkan_max_version': vulkan_max_version,
78 }
79 return info
80
81
82def main(argv):
83 args = parse_args(argv[1:])
84 if not validate_args(args):
85 return 1
86
87 infos = []
88 for core in malioc_core_list(args.malioc):
89 infos.append(malioc_core_info(args.malioc, core))
90
91 if args.output:
92 with open(args.output, 'w') as file:
93 json.dump(infos, file, sort_keys=True)
94 else:
95 print(infos)
96
97 return 0
98
99
100if __name__ == '__main__':
101 sys.exit(main(sys.argv))
Type::kYUV Type::kRGBA() int(0.7 *637)
void print(void *str)
Definition bridge.cpp:126
Definition main.py:1
malioc_core_list(malioc)
validate_args(args)
malioc_core_info(malioc, core)