blender/tests/performance/api/common.py
Jeroen Bakker 64ac8ada59 Benchmark: Vulkan device selection
This PR allows to run benchmarks on multiple GPUs (one at a time).
It also contains some fixes to the reporting and normalization of the
device ID's.

Device ID normalization is done as some existing configs only contain
`VULKAN` which need to be matched against `VULKAN_0` and vise-versa.

Device selection doesn't use `blender --gpu-device help` to detect devices
as that option doesn't exist in older builds.

Now with fixed python validations.

Original Pull Request: https://projects.blender.org/blender/blender/pulls/158898

Pull Request: https://projects.blender.org/blender/blender/pulls/159234
2026-05-28 16:28:15 +02:00

11 lines
353 B
Python

# SPDX-FileCopyrightText: 2026 Blender Authors
#
# SPDX-License-Identifier: Apache-2.0
def normalize_device_id(device_id: str) -> str:
"""Normalize a device ID by adding _0 suffix when there is no index."""
parts = device_id.rsplit('_', 1)
if len(parts) == 1 or not parts[1].isdigit():
return device_id + '_0'
return device_id