Changeset View
Changeset View
Standalone View
Standalone View
tests/python/cycles_render_tests.py
| #!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
| # Apache License, Version 2.0 | # Apache License, Version 2.0 | ||||
| import argparse | import argparse | ||||
| import os | import os | ||||
| import shlex | import shlex | ||||
| import shutil | import shutil | ||||
| import subprocess | import subprocess | ||||
| import sys | import sys | ||||
| # This function can return 1 of 3 things | |||||
| # accept - test uses the same reference image for all architectures | |||||
| # skip - this test does not support this kernel (ie OSL tests on the GPU) | |||||
| # ownref - this test has its own reference image for this architecture | |||||
| def allow_test(filepath, kernel): | |||||
| dirname = os.path.dirname(filepath) | |||||
| basedir = os.path.dirname(dirname) | |||||
| subject = os.path.basename(dirname) | |||||
| test = os.path.splitext(os.path.basename(filepath))[0] | |||||
| # Skip osl/script tests on GPU architectures | |||||
| if (kernel == "cuda" or | |||||
| kernel == "optix" or | |||||
| kernel == "opencl"): | |||||
| if "osl" in filepath: | |||||
| return "skip" | |||||
| if "script" in filepath: | |||||
| return "skip" | |||||
| # GPU kernels have different noise here and need their own reference | |||||
| # however this may be too generic, so disable for now while we discuss | |||||
| #if subject == "light": | |||||
| # return "ownref" | |||||
| # No baking yet in the optix kernel | |||||
| if kernel == "optix" and "bake" in filepath: | |||||
| return "skip" | |||||
| # No ambient oclusion yet in the optix kernel | |||||
| if kernel == "optix" and "ambient" in filepath: | |||||
| return "skip" | |||||
| # No ambient oclusion yet in the optix kernel | |||||
| if kernel == "optix" and "bevel" in filepath: | |||||
| return "skip" | |||||
| return "accept" | |||||
| def get_arguments(filepath, output_filepath): | def get_arguments(filepath, output_filepath, kernel): | ||||
| dirname = os.path.dirname(filepath) | dirname = os.path.dirname(filepath) | ||||
| basedir = os.path.dirname(dirname) | basedir = os.path.dirname(dirname) | ||||
| subject = os.path.basename(dirname) | subject = os.path.basename(dirname) | ||||
| args = [ | args = [ | ||||
| "--background", | "--background", | ||||
| "-noaudio", | "-noaudio", | ||||
| "--factory-startup", | "--factory-startup", | ||||
| "--enable-autoexec", | "--enable-autoexec", | ||||
| filepath, | filepath, | ||||
| "-E", "CYCLES", | "-E", "CYCLES", | ||||
| "-o", output_filepath, | "-o", output_filepath, | ||||
| "-F", "PNG"] | "-F", "PNG"] | ||||
| # OSL and GPU examples | # 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.shading_system = True"] | ||||
| # custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.device = 'GPU'"] | # custom_args += ["--python-expr", "import bpy; bpy.context.scene.cycles.device = 'GPU'"] | ||||
| custom_args = os.getenv('CYCLESTEST_ARGS') | custom_args = os.getenv('CYCLESTEST_ARGS') | ||||
| if custom_args: | if custom_args: | ||||
| args.extend(shlex.split(custom_args)) | args.extend(shlex.split(custom_args)) | ||||
| kernel_script = os.path.join(os.path.dirname(os.path.realpath(__file__)), "kernels", kernel+".py") | |||||
| if (os.path.exists(kernel_script)): | |||||
| args.extend(['--debug-value', '256']) | |||||
| args.extend(['--python', kernel_script]) | |||||
| if subject == 'bake': | if subject == 'bake': | ||||
| args.extend(['--python', os.path.join(basedir, "util", "render_bake.py")]) | args.extend(['--python', os.path.join(basedir, "util", "render_bake.py")]) | ||||
| elif subject == 'denoise_animation': | elif subject == 'denoise_animation': | ||||
| args.extend(['--python', os.path.join(basedir, "util", "render_denoise.py")]) | args.extend(['--python', os.path.join(basedir, "util", "render_denoise.py")]) | ||||
| else: | else: | ||||
| args.extend(["-f", "1"]) | args.extend(["-f", "1"]) | ||||
| return args | return args | ||||
| Show All 11 Lines | def main(): | ||||
| parser = create_argparse() | parser = create_argparse() | ||||
| args = parser.parse_args() | args = parser.parse_args() | ||||
| blender = args.blender[0] | blender = args.blender[0] | ||||
| test_dir = args.testdir[0] | test_dir = args.testdir[0] | ||||
| idiff = args.idiff[0] | idiff = args.idiff[0] | ||||
| output_dir = args.outdir[0] | output_dir = args.outdir[0] | ||||
| kernels = ["host"] | |||||
| env_kernels = os.getenv('CYCLESTEST_KERNELS') | |||||
| if env_kernels: | |||||
| kernels = env_kernels.split(",") | |||||
| from modules import render_report | from modules import render_report | ||||
| report = render_report.Report("Cycles", output_dir, idiff) | report = render_report.Report("Cycles", output_dir, idiff) | ||||
| report.set_pixelated(True) | report.set_pixelated(True) | ||||
| report.set_reference_dir("cycles_renders") | report.set_reference_dir("cycles_renders") | ||||
| report.set_compare_engines('cycles', 'eevee') | report.set_compare_engines('cycles', 'eevee') | ||||
| ok = report.run(test_dir, blender, get_arguments, batch=True) | ok = report.run(test_dir, blender, get_arguments, allow_test, batch=True, enabled_kernels=kernels) | ||||
| sys.exit(not ok) | sys.exit(not ok) | ||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||
| main() | main() | ||||