From 7a47762c20d11eb00f5f488902dc5c66898d37e3 Mon Sep 17 00:00:00 2001 From: Alaska Date: Wed, 26 Mar 2025 23:52:14 +0100 Subject: [PATCH] Benchmark: Enable OSL in Cycles performance benchmark tool This commit gives users of the Cycles performance benchmark tool the option to run performance benchmarks with OSL enabled for CPUs and OptiX devices. This can be done by adding `-OSL` to the device name: `CPU-OSL` `OPTIX-OSL_0` Pull Request: https://projects.blender.org/blender/blender/pulls/136506 --- tests/performance/api/device.py | 5 ++++- tests/performance/tests/cycles.py | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/performance/api/device.py b/tests/performance/api/device.py index 01197accb87..10b0388e02b 100644 --- a/tests/performance/api/device.py +++ b/tests/performance/api/device.py @@ -42,6 +42,8 @@ def get_gpu_device(args: None) -> list: result.append({'type': device.type, 'name': device.name, 'index': index}) if device.type in {"HIP", "METAL", "ONEAPI"}: result.append({'type': f"{device.type}-RT", 'name': device.name, 'index': index}) + if device.type in {"OPTIX"}: + result.append({'type': f"{device.type}-OSL", 'name': device.name, 'index': index}) index += 1 return result @@ -59,7 +61,8 @@ class TestMachine: def __init__(self, env, need_gpus: bool): operating_system = platform.system() - self.devices = [TestDevice('CPU', 'CPU', get_cpu_name(), operating_system)] + self.devices = [TestDevice('CPU', 'CPU', get_cpu_name(), operating_system), + TestDevice('CPU-OSL', 'CPU-OSL', get_cpu_name(), operating_system)] self.has_gpus = need_gpus if need_gpus and env.blender_executable: diff --git a/tests/performance/tests/cycles.py b/tests/performance/tests/cycles.py index a8310649c86..f4da661e3dd 100644 --- a/tests/performance/tests/cycles.py +++ b/tests/performance/tests/cycles.py @@ -8,12 +8,18 @@ import api def _run(args): import bpy - device_type, suffix = (args['device_type'].split("-") + [""])[:2] - use_hwrt = (suffix == "RT") - device_index = args['device_index'] + device_info = args['device_type'].split("-") + device_type = device_info[0] - if suffix not in {"", "RT"}: - raise SystemExit(f"Unknown device type suffix {suffix}") + device_suffixes = device_info[1:] + use_hwrt = "RT" in device_suffixes + use_osl = "OSL" in device_suffixes + + for suffix in device_suffixes: + if suffix not in {"RT", "OSL"}: + raise SystemExit(f"Unknown device type suffix {suffix}") + + device_index = args['device_index'] scene = bpy.context.scene scene.render.engine = 'CYCLES' @@ -31,6 +37,9 @@ def _run(args): scene.cycles.samples = 16384 scene.cycles.time_limit = 10.0 + if use_osl: + scene.cycles.shading_system = True + if scene.cycles.device == 'GPU': # Enable specified GPU in preferences. prefs = bpy.context.preferences