d3ecfb3bb8
Graphite code snippets can be moved into these files; they will be compiled once at build time and dehydrated for later use. This allows us to avoid synthesizing and compiling them in each shader where they are referenced. (Unfortunately, the GPU driver will still need to compile them each time.) Change-Id: I5cdc5881d71d7b81a02c91a84d52804f2909b483 Bug: skia:13110 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532259 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
#!/usr/bin/env python
|
|
#
|
|
# Copyright 2020 Google LLC
|
|
#
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
sksl_precompile = sys.argv[1]
|
|
targetDir = sys.argv[2]
|
|
modules = sys.argv[3:]
|
|
|
|
dependencies = {
|
|
'sksl_frag': ['sksl_gpu'],
|
|
'sksl_vert': ['sksl_gpu'],
|
|
'sksl_graphite_frag': ['sksl_frag', 'sksl_gpu'],
|
|
'sksl_graphite_vert': ['sksl_vert', 'sksl_gpu'],
|
|
'sksl_rt_shader': ['sksl_public'],
|
|
}
|
|
|
|
for module in modules:
|
|
try:
|
|
moduleDir, moduleName = os.path.split(os.path.splitext(module)[0])
|
|
if not os.path.isdir(targetDir):
|
|
os.mkdir(targetDir)
|
|
target = os.path.join(targetDir, moduleName)
|
|
args = [sksl_precompile, target + ".dehydrated.sksl", module]
|
|
if moduleName in dependencies:
|
|
for dependent in dependencies[moduleName]:
|
|
args.append(os.path.join(moduleDir, dependent) + ".sksl")
|
|
subprocess.check_output(args).decode('utf-8')
|
|
except subprocess.CalledProcessError as err:
|
|
print("### Error compiling " + module + ":")
|
|
print(err.output)
|
|
exit(1)
|