2015-01-22 10:53:49 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Apache License, Version 2.0
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
2017-08-19 10:09:28 +00:00
|
|
|
import shlex
|
2016-06-13 22:39:49 +00:00
|
|
|
import shutil
|
2015-01-22 10:53:49 +00:00
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
2019-05-10 21:00:35 +00:00
|
|
|
def render_files(filepaths, output_filepaths):
|
|
|
|
command = [BLENDER, "--background"]
|
2017-08-19 10:09:28 +00:00
|
|
|
|
|
|
|
# OSL and GPU examples
|
|
|
|
# custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.shading_system = True"]
|
|
|
|
# custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.device = 'GPU'"]
|
2019-02-11 17:26:47 +00:00
|
|
|
custom_args = os.getenv('CYCLESTEST_ARGS')
|
|
|
|
custom_args = shlex.split(custom_args) if custom_args else []
|
2018-02-14 16:33:06 +00:00
|
|
|
|
2019-05-10 21:00:35 +00:00
|
|
|
for filepath, output_filepath in zip(filepaths, output_filepaths):
|
|
|
|
dirname = os.path.dirname(filepath)
|
|
|
|
basedir = os.path.dirname(dirname)
|
|
|
|
subject = os.path.basename(dirname)
|
|
|
|
|
|
|
|
frame_filepath = output_filepath + '0001.png'
|
|
|
|
|
|
|
|
common_args = [
|
|
|
|
"-noaudio",
|
|
|
|
"--factory-startup",
|
|
|
|
"--enable-autoexec",
|
|
|
|
filepath,
|
|
|
|
"-E", "CYCLES",
|
|
|
|
"-o", output_filepath,
|
|
|
|
"-F", "PNG"]
|
|
|
|
|
|
|
|
common_args += custom_args
|
|
|
|
|
|
|
|
if subject == 'bake':
|
|
|
|
command.extend(common_args)
|
|
|
|
command.extend(['--python', os.path.join(basedir, "util", "render_bake.py")])
|
|
|
|
elif subject == 'denoise_animation':
|
|
|
|
command.extend(common_args)
|
|
|
|
command.extend(['--python', os.path.join(basedir, "util", "render_denoise.py")])
|
|
|
|
else:
|
|
|
|
command.extend(common_args)
|
|
|
|
command.extend(["-f", "1"])
|
|
|
|
|
|
|
|
error = None
|
2015-01-22 10:53:49 +00:00
|
|
|
try:
|
2018-02-14 16:33:06 +00:00
|
|
|
# Success
|
2015-01-22 10:53:49 +00:00
|
|
|
output = subprocess.check_output(command)
|
|
|
|
if VERBOSE:
|
2018-05-18 14:40:41 +00:00
|
|
|
print(" ".join(command))
|
2015-01-22 10:53:49 +00:00
|
|
|
print(output.decode("utf-8"))
|
|
|
|
except subprocess.CalledProcessError as e:
|
2018-02-14 16:33:06 +00:00
|
|
|
# Error
|
2015-01-22 10:53:49 +00:00
|
|
|
if VERBOSE:
|
2018-05-18 14:40:41 +00:00
|
|
|
print(" ".join(command))
|
2015-01-22 10:53:49 +00:00
|
|
|
print(e.output.decode("utf-8"))
|
2019-05-10 21:00:35 +00:00
|
|
|
error = "CRASH"
|
2016-09-10 20:55:28 +00:00
|
|
|
except BaseException as e:
|
2018-02-14 16:33:06 +00:00
|
|
|
# Crash
|
2015-01-22 10:53:49 +00:00
|
|
|
if VERBOSE:
|
2018-05-18 14:40:41 +00:00
|
|
|
print(" ".join(command))
|
2019-05-10 21:00:35 +00:00
|
|
|
print(e.decode("utf-8"))
|
|
|
|
error = "CRASH"
|
|
|
|
|
|
|
|
# Detect missing filepaths and consider those errors
|
|
|
|
errors = []
|
|
|
|
for output_filepath in output_filepaths:
|
|
|
|
frame_filepath = output_filepath + '0001.png'
|
|
|
|
if os.path.exists(frame_filepath):
|
|
|
|
shutil.copy(frame_filepath, output_filepath)
|
|
|
|
os.remove(frame_filepath)
|
|
|
|
errors.append(None)
|
|
|
|
else:
|
|
|
|
errors.append(error)
|
|
|
|
error = 'SKIPPED'
|
2015-01-22 10:53:49 +00:00
|
|
|
|
2019-05-10 21:00:35 +00:00
|
|
|
return errors
|
2015-01-22 10:53:49 +00:00
|
|
|
|
|
|
|
def create_argparse():
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("-blender", nargs="+")
|
|
|
|
parser.add_argument("-testdir", nargs=1)
|
2017-08-03 14:41:50 +00:00
|
|
|
parser.add_argument("-outdir", nargs=1)
|
2015-01-22 10:53:49 +00:00
|
|
|
parser.add_argument("-idiff", nargs=1)
|
|
|
|
return parser
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = create_argparse()
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2018-02-14 16:33:06 +00:00
|
|
|
global BLENDER, VERBOSE
|
2017-01-12 08:45:04 +00:00
|
|
|
|
2015-01-22 10:53:49 +00:00
|
|
|
BLENDER = args.blender[0]
|
|
|
|
VERBOSE = os.environ.get("BLENDER_VERBOSE") is not None
|
|
|
|
|
2018-02-14 16:33:06 +00:00
|
|
|
test_dir = args.testdir[0]
|
|
|
|
idiff = args.idiff[0]
|
|
|
|
output_dir = args.outdir[0]
|
2015-01-22 10:53:49 +00:00
|
|
|
|
2018-02-14 16:33:06 +00:00
|
|
|
from modules import render_report
|
|
|
|
report = render_report.Report("Cycles Test Report", output_dir, idiff)
|
|
|
|
report.set_pixelated(True)
|
2019-05-06 17:46:32 +00:00
|
|
|
report.set_reference_dir("cycles_renders")
|
2018-05-18 15:52:46 +00:00
|
|
|
report.set_compare_engines('cycles', 'eevee')
|
2019-05-10 21:00:35 +00:00
|
|
|
ok = report.run(test_dir, render_files)
|
2015-01-22 10:53:49 +00:00
|
|
|
|
|
|
|
sys.exit(not ok)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|