• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 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.
4
5import json
6import os
7import subprocess
8import sys
9
10if len(sys.argv) != 3:
11    print sys.argv[0], ' <compiler> <folder>'
12    sys.exit(1)
13
14compiler = sys.argv[1]
15folder = sys.argv[2]
16
17stats = {}
18
19for filename in os.listdir(folder):
20    basename, ext = os.path.splitext(filename)
21    if ext not in ['.frag', '.spv']:
22        continue
23    cmdline = [compiler]
24    if ext == '.spv':
25        cmdline.extend(['-f', '-p'])
26    cmdline.append(os.path.join(folder, filename))
27    try:
28        output = subprocess.check_output(cmdline)
29    except subprocess.CalledProcessError:
30        continue
31    stats.setdefault(basename, {})
32    for line in output.splitlines():
33        if line.startswith('Instructions Emitted'):
34            inst = line.split(':')[1].split()
35            stats[basename][ext] = inst
36
37for k, v in stats.iteritems():
38    gl = v.get('.frag', ['', '', ''])
39    vk = v.get('.spv', ['', '', ''])
40    print '{0},{1},{2},{3},{4},{5},{6}'.format(k, gl[0], gl[1], gl[2], vk[0], vk[1], vk[2])
41