From b4230d84dccef2f96aa0dfde34de5befda1d66fa Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Thu, 19 Dec 2024 14:33:09 +0200 Subject: [PATCH] Compositor: Unify references between CPU and GPU tests This patch removes the references for the GPU tests and uses the CPU references for both CPU and GPU, since they are expected to match. This also unifies the tests scripts into a single script with an argument for execution device. --- tests/data | 2 +- tests/python/CMakeLists.txt | 11 ++-- .../compositor_realtime_render_tests.py | 64 ------------------- ...er_tests.py => compositor_render_tests.py} | 19 ++++-- 4 files changed, 19 insertions(+), 77 deletions(-) delete mode 100644 tests/python/compositor_realtime_render_tests.py rename tests/python/{compositor_cpu_render_tests.py => compositor_render_tests.py} (70%) diff --git a/tests/data b/tests/data index a965544f03c..97542f876bd 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit a965544f03cfa05d8878a34feaf9909726804774 +Subproject commit 97542f876bdca3e4917ba7e3b8c88d26a9d86afd diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index 09d6f99546d..904ae96470c 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -884,8 +884,8 @@ else() foreach(comp_test ${compositor_tests}) add_render_test( - compositor_${comp_test}_cpu - ${CMAKE_CURRENT_LIST_DIR}/compositor_cpu_render_tests.py + compositor_cpu_${comp_test} + ${CMAKE_CURRENT_LIST_DIR}/compositor_render_tests.py --testdir "${TEST_SRC_DIR}/compositor/${comp_test}" --outdir "${TEST_OUT_DIR}/compositor_cpu" ) @@ -914,10 +914,11 @@ if(WITH_COMPOSITOR_REALTIME_TESTS) foreach(comp_test ${compositor_tests}) add_render_test( - compositor_${comp_test}_realtime - ${CMAKE_CURRENT_LIST_DIR}/compositor_realtime_render_tests.py + compositor_gpu_${comp_test} + ${CMAKE_CURRENT_LIST_DIR}/compositor_render_tests.py --testdir "${TEST_SRC_DIR}/compositor/${comp_test}" - --outdir "${TEST_OUT_DIR}/compositor_realtime" + --outdir "${TEST_OUT_DIR}/compositor_gpu" + --gpu ) endforeach() endif() diff --git a/tests/python/compositor_realtime_render_tests.py b/tests/python/compositor_realtime_render_tests.py deleted file mode 100644 index 773ff8e32a0..00000000000 --- a/tests/python/compositor_realtime_render_tests.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2015-2023 Blender Authors -# -# SPDX-License-Identifier: Apache-2.0 - -import argparse -import os -import sys - - -# When run from inside Blender, render and exit. -try: - import bpy - inside_blender = True -except ImportError: - inside_blender = False - -SET_COMPOSITOR_DEVICE_SCRIPT = "import bpy; " \ - "bpy.data.scenes[0].render.compositor_device = 'GPU'" - - -def get_arguments(filepath, output_filepath): - return [ - "--background", - "--factory-startup", - "--enable-autoexec", - "--debug-memory", - "--debug-exit-on-error", - filepath, - "-P", os.path.realpath(__file__), - "--python-expr", SET_COMPOSITOR_DEVICE_SCRIPT, - "-o", output_filepath, - "-F", "PNG", - "-f", "1" - ] - - -def create_argparse(): - parser = argparse.ArgumentParser( - description="Run test script for each blend file in TESTDIR, comparing the render result with known output." - ) - parser.add_argument("--blender", required=True) - parser.add_argument("--testdir", required=True) - parser.add_argument("--outdir", required=True) - parser.add_argument("--oiiotool", required=True) - parser.add_argument('--batch', default=False, action='store_true') - return parser - - -def main(): - parser = create_argparse() - args = parser.parse_args() - - from modules import render_report - report = render_report.Report("Compositor Realtime", args.outdir, args.oiiotool) - report.set_reference_dir("compositor_realtime_renders") - - ok = report.run(args.testdir, args.blender, get_arguments, batch=args.batch) - - sys.exit(not ok) - - -if not inside_blender and __name__ == "__main__": - main() diff --git a/tests/python/compositor_cpu_render_tests.py b/tests/python/compositor_render_tests.py similarity index 70% rename from tests/python/compositor_cpu_render_tests.py rename to tests/python/compositor_render_tests.py index f457163a5fe..bf39b190c6b 100644 --- a/tests/python/compositor_cpu_render_tests.py +++ b/tests/python/compositor_render_tests.py @@ -15,11 +15,12 @@ try: except ImportError: inside_blender = False -SET_COMPOSITOR_DEVICE_SCRIPT = "import bpy; " \ - "bpy.data.scenes[0].render.compositor_device = 'CPU'" + +def get_compositor_device_setter_script(execution_device): + return f"import bpy; bpy.data.scenes[0].render.compositor_device = '{execution_device}'" -def get_arguments(filepath, output_filepath): +def get_arguments(filepath, output_filepath, execution_device): return [ "--background", "--factory-startup", @@ -28,7 +29,7 @@ def get_arguments(filepath, output_filepath): "--debug-exit-on-error", filepath, "-P", os.path.realpath(__file__), - "--python-expr", SET_COMPOSITOR_DEVICE_SCRIPT, + "--python-expr", get_compositor_device_setter_script(execution_device), "-o", output_filepath, "-F", "PNG", "-f", "1"] @@ -42,6 +43,7 @@ def create_argparse(): parser.add_argument("--testdir", required=True) parser.add_argument("--outdir", required=True) parser.add_argument("--oiiotool", required=True) + parser.add_argument("--gpu", default=False, action='store_true') parser.add_argument('--batch', default=False, action='store_true') return parser @@ -51,9 +53,11 @@ def main(): args = parser.parse_args() from modules import render_report - report = render_report.Report("Compositor CPU", args.outdir, args.oiiotool) + execution_device = "GPU" if args.gpu else "CPU" + report_title = f"Compositor {execution_device}" + report = render_report.Report(report_title, args.outdir, args.oiiotool) report.set_pixelated(True) - report.set_reference_dir("compositor_cpu_renders") + report.set_reference_dir("compositor_renders") if os.path.basename(args.testdir) == 'filter': # Temporary change to pass OpenImageDenoise test with both 1.3 and 1.4. @@ -66,7 +70,8 @@ def main(): report.set_fail_threshold(0.06) report.set_fail_percent(2) - ok = report.run(args.testdir, args.blender, get_arguments, batch=args.batch) + arguments_callback = lambda filepath, output_filepath: get_arguments(filepath, output_filepath, execution_device) + ok = report.run(args.testdir, args.blender, arguments_callback, batch=args.batch) sys.exit(not ok)