diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-07-26 15:25:06 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-07-26 15:25:32 +0300 |
commit | a4189e1c4329a20188fbc73a2bc37b43a77bbcb0 (patch) | |
tree | c873af63d5515cdc865f1b74375558a33b16c10d | |
parent | 4665f62cf5900542a440313d3382f20b80e75cc8 (diff) |
Initialize GPU backend in background by rendering a 1x1 image.
-rw-r--r-- | tests/python/eevee_render_tests.py | 1 | ||||
-rw-r--r-- | tests/python/gpu_info.py | 14 |
2 files changed, 12 insertions, 3 deletions
diff --git a/tests/python/eevee_render_tests.py b/tests/python/eevee_render_tests.py index 89737fa8010..34c15872a11 100644 --- a/tests/python/eevee_render_tests.py +++ b/tests/python/eevee_render_tests.py @@ -103,6 +103,7 @@ def get_gpu_device_type(blender): command = [ blender, "-noaudio", + "--background" "--factory-startup", "--python", str(pathlib.Path(__file__).parent / "gpu_info.py") diff --git a/tests/python/gpu_info.py b/tests/python/gpu_info.py index f964816c5cf..159eafed94e 100644 --- a/tests/python/gpu_info.py +++ b/tests/python/gpu_info.py @@ -1,13 +1,21 @@ """ Prints GPU backend information to the console and exits. - Use this script as `blender --python gpu_info.py`. - Doesn't work with `--background` parameter as then the GPU backend won't - be initialized. + Use this script as `blender --background --python gpu_info.py`. """ +import bpy import gpu import sys +# Render with workbench to initialize the GPU backend otherwise it would fail when running in +# background mode as the GPU backend won't be initialized. +scene = bpy.context.scene +scene.render.resolution_x = 1 +scene.render.resolution_y = 1 +scene.render.engine = "BLENDER_WORKBENCH" +bpy.ops.render.render(animation=False, write_still=False) + + print('GPU_VENDOR:' + gpu.platform.vendor_get()) print('GPU_RENDERER:' + gpu.platform.renderer_get()) print('GPU_VERSION:' + gpu.platform.version_get()) |