blob: 12424dfaaf93e4ee5d14a2514bae67091bb6a69c [file] [log] [blame]
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from __future__ import print_function
import json
import os
import subprocess
import sys
if len(sys.argv) != 3:
print(sys.argv[0], ' <compiler> <folder>')
compiler = sys.argv[1]
folder = sys.argv[2]
stats = {}
for filename in os.listdir(folder):
basename, ext = os.path.splitext(filename)
if ext not in ['.frag', '.spv']:
cmdline = [compiler]
if ext == '.spv':
cmdline.extend(['-f', '-p'])
cmdline.append(os.path.join(folder, filename))
output = subprocess.check_output(cmdline)
except subprocess.CalledProcessError:
stats.setdefault(basename, {})
for line in output.splitlines():
if line.startswith('Instructions Emitted'):
inst = line.split(':')[1].split()
stats[basename][ext] = inst
for k, v in stats.iteritems():
gl = v.get('.frag', ['', '', ''])
vk = v.get('.spv', ['', '', ''])
k, gl[0], gl[1], gl[2], vk[0], vk[1], vk[2]))