1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6 # Recipe for Skia skpbench.
11 PYTHON_VERSION_COMPATIBILITY = "PY3"
15 'recipe_engine/context',
18 'recipe_engine/platform',
19 'recipe_engine/properties',
20 'recipe_engine/python',
21 'recipe_engine/raw_io',
28 ADB_BINARY = 'adb.1.0.35'
31 def _run(api, title, *cmd, **kwargs):
32 with api.context(cwd=api.path['start_dir'].join('skia')):
33 return api.run(api.step, title, cmd=list(cmd), **kwargs)
36 def _adb(api, title, *cmd, **kwargs):
37 if 'infra_step' not in kwargs:
38 kwargs['infra_step'] = True
39 return _run(api, title, ADB_BINARY, *cmd, **kwargs)
42 def skpbench_steps(api):
43 """benchmark Skia using skpbench."""
44 is_vulkan = 'Vulkan' in api.vars.builder_name
45 is_metal = 'Metal' in api.vars.builder_name
46 is_android = 'Android' in api.vars.builder_name
47 is_apple_m1 = 'AppleM1' in api.vars.builder_name
48 is_all_paths_volatile = 'AllPathsVolatile' in api.vars.builder_name
49 is_mskp = 'Mskp' in api.vars.builder_name
50 is_ddl = 'DDL' in api.vars.builder_name
51 is_9x9 = '9x9' in api.vars.builder_name
53 api.file.ensure_directory(
54 'makedirs perf_dir', api.flavor.host_dirs.perf_data_dir)
57 app = api.vars.build_dir.join('skpbench')
58 _adb(api, 'push skpbench', 'push', app, api.flavor.device_dirs.bin_dir)
60 skpbench_dir = api.vars.workdir.join('skia', 'tools', 'skpbench')
61 table = api.path.join(api.vars.swarming_out_dir, 'table')
69 if "MaliG77" in api.vars.builder_name:
70 config = 'glesdmsaa,' + config
73 if "QuadroP400" in api.vars.builder_name or is_apple_m1:
74 config = 'gldmsaa,' + config
76 internal_samples = 4 if is_android or is_apple_m1 else 8
78 if is_all_paths_volatile:
79 config = "%smsaa%i" % (config, internal_samples)
81 skpbench_invocation = api.path.join(api.flavor.device_dirs.bin_dir, 'skpbench')
84 if is_vulkan and 'GalaxyS20' in api.vars.builder_name:
85 skpbench_invocation = "LD_LIBRARY_PATH=/data/local/tmp %s" % skpbench_invocation
89 '--resultsfile', table,
91 '--internalSamples', str(internal_samples),
92 # TODO(dogben): Track down what's causing bots to die.
95 skpbench_args += ['--ddl']
96 # disable the mask generation threads for simplicity's sake in DDL mode
97 skpbench_args += ['--gpuThreads', '0']
100 '--ddlNumRecordingThreads', 9,
101 '--ddlTilingWidthHeight', 3]
105 '--adb_binary', ADB_BINARY]
107 skpbench_args += [api.flavor.device_dirs.mskp_dir]
108 elif is_all_paths_volatile:
110 '--allPathsVolatile',
111 '--suffix', "_volatile",
112 api.path.join(api.flavor.device_dirs.skp_dir, 'desk_*svg.skp'),
113 api.path.join(api.flavor.device_dirs.skp_dir, 'desk_motionmark*.skp'),
114 api.path.join(api.flavor.device_dirs.skp_dir, 'desk_chalkboard.skp')]
116 skpbench_args += [api.flavor.device_dirs.skp_dir]
118 if api.properties.get('dont_reduce_ops_task_splitting') == 'true':
119 skpbench_args += ['--dontReduceOpsTaskSplitting']
121 if api.properties.get('gpu_resource_cache_limit'):
122 skpbench_args += ['--gpuResourceCacheLimit', api.properties.get('gpu_resource_cache_limit')]
124 api.run(api.python, 'skpbench',
125 script=skpbench_dir.join('skpbench.py'),
131 'gitHash', api.properties['revision'],
133 if api.vars.is_trybot:
134 skiaperf_args.extend([
135 'issue', api.vars.issue,
136 'patchset', api.vars.patchset,
137 'patch_storage', api.vars.patch_storage,
140 skiaperf_args.extend(['swarming_bot_id', api.vars.swarming_bot_id])
141 skiaperf_args.extend(['swarming_task_id', api.vars.swarming_task_id])
143 now = api.time.utcnow()
144 ts = int(calendar.timegm(now.utctimetuple()))
145 json_path = api.path.join(
146 api.flavor.host_dirs.perf_data_dir,
147 'skpbench_%s_%d.json' % (api.properties['revision'], ts))
149 skiaperf_args.extend([
150 '--outfile', json_path
153 skiaperf_args.append('--key')
154 for k in sorted(api.vars.builder_cfg.keys()):
155 if not k in ['configuration', 'role', 'is_trybot']:
156 skiaperf_args.extend([k, api.vars.builder_cfg[k]])
158 api.run(api.python, 'Parse skpbench output into Perf json',
159 script=skpbench_dir.join('skiaperf.py'),
165 api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir)
167 # The app_name passed to api.flavor.setup() is used to determine which app
168 # to install on an attached device. That work is done in skpbench_steps, so
170 api.flavor.setup(None)
173 mksp_mode = ('Mskp' in api.vars.builder_name)
174 api.flavor.install(skps=not mksp_mode, mskps=mksp_mode)
177 api.flavor.cleanup_steps()
178 api.run.check_failure()
182 'Perf-Android-Clang-Pixel2XL-GPU-Adreno540-arm64-Release-All-Android_Skpbench_Mskp',
183 'Perf-Android-Clang-GalaxyS20-GPU-MaliG77-arm64-Release-All-Android_AllPathsVolatile_Skpbench',
184 'Perf-Android-Clang-GalaxyS20-GPU-MaliG77-arm64-Release-All-Android_Vulkan_AllPathsVolatile_Skpbench',
185 'Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-Vulkan_Skpbench',
186 'Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-Vulkan_Skpbench_DDLTotal_9x9',
187 'Perf-Win10-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-AllPathsVolatile_Skpbench',
188 'Perf-Mac11-Clang-MacMini9.1-GPU-AppleM1-arm64-Release-All-Metal_AllPathsVolatile_Skpbench',
193 for builder in TEST_BUILDERS:
196 api.properties(buildername=builder,
198 path_config='kitchen',
199 swarm_out_dir='[SWARM_OUT_DIR]') +
201 api.path['start_dir'].join('skia'),
202 api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
205 api.step_data('get swarming bot id',
206 stdout=api.raw_io.output('skia-bot-123')) +
207 api.step_data('get swarming task id',
208 stdout=api.raw_io.output('123456'))
211 test += api.platform('win', 64)
214 b = ('Perf-Android-Clang-Pixel2XL-GPU-Adreno540-arm64-Release-All-'
215 'Android_Vulkan_Skpbench')
218 api.properties(buildername=b,
220 path_config='kitchen',
221 swarm_out_dir='[SWARM_OUT_DIR]',
222 dont_reduce_ops_task_splitting='true',
223 gpu_resource_cache_limit='16777216') +
225 api.path['start_dir'].join('skia'),
226 api.path['start_dir'].join('skia', 'infra', 'bots', 'assets',
229 api.step_data('get swarming bot id',
230 stdout=api.raw_io.output('skia-bot-123')) +
231 api.step_data('get swarming task id',
232 stdout=api.raw_io.output('123456')) +
233 api.properties(patch_storage='gerrit') +
234 api.properties.tryserver(
236 gerrit_project='skia',
237 gerrit_url='https://skia-review.googlesource.com/',