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
This commit is contained in:
Alaska
2025-03-26 23:52:14 +01:00
committed by Alaska
parent 7a257359f8
commit 7a47762c20
2 changed files with 18 additions and 6 deletions

View File

@@ -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:

View File

@@ -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