Skip to content

Commit

Permalink
Merge pull request DLR-RM#933 from common/render_device_type_fallback…
Browse files Browse the repository at this point in the history
…_quick_fix

fix(initializer): Fixes rendering on cuda-only devices per default
  • Loading branch information
themasterlink authored and GitHub Enterprise committed May 11, 2021
2 parents 6aaf468 + 7e0e5d3 commit e96ec48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/InitializerModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ def __init__(self, config):
def run(self):
horizon_color = self.config.get_list("horizon_color", [0.05, 0.05, 0.05])
compute_device = self.config.get_string("compute_device", "GPU")
compute_device_type = self.config.get_string("compute_device_type", "OPTIX")
compute_device_type = self.config.get_string("compute_device_type", None)
use_experimental_features = self.config.get_bool("use_experimental_features", False)
Initializer.init(horizon_color, compute_device, compute_device_type, use_experimental_features, clean_up_scene=False)
6 changes: 3 additions & 3 deletions src/utility/Initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
class Initializer:

@staticmethod
def init(horizon_color: list = [0.05, 0.05, 0.05], compute_device: str = "GPU", compute_device_type: str = "OPTIX", use_experimental_features: bool = False, clean_up_scene: bool = True):
def init(horizon_color: list = [0.05, 0.05, 0.05], compute_device: str = "GPU", compute_device_type: str = None, use_experimental_features: bool = False, clean_up_scene: bool = True):
""" Initializes basic blender settings, the world and the camera.
Also cleans up the whole scene at first.
:param horizon_color: The color to use for the world background.
:param compute_device: The compute device to use for the Cycles Render Engine i.e. CPU or GPU. (default: ``GPU``).
:param compute_device_type: The compute device type to use for the Cycles Render Engine i.e. OPTIX or CUDA. Only necessary to specify if compute device is GPU. (default: ``OPTIX``).
:param compute_device_type: The compute device type to use for the Cycles Render Engine i.e. OPTIX or CUDA. Only necessary to specify, if compute device is GPU. If None is given, the available device type is used (OPTIX is preferred).
:param use_experimental_features: Set to True, if you want to use the Experimental features of the Cycles Render Engine i.e Adaptive subdivision. (default: ``False``).
:param clean_up_scene: Set to False, if you want to keep all scene data.
"""
Expand Down Expand Up @@ -51,7 +51,7 @@ def init(horizon_color: list = [0.05, 0.05, 0.05], compute_device: str = "GPU",
for gpu_type in ["OPTIX", "CUDA"]:
found = False
for device in preferences.devices:
if device.type == gpu_type and compute_device_type == gpu_type:
if device.type == gpu_type and (compute_device_type is None or compute_device_type == gpu_type):
bpy.context.preferences.addons['cycles'].preferences.compute_device_type = gpu_type
print('Device {} of type {} found and used.'.format(device.name, device.type))
found = True
Expand Down

0 comments on commit e96ec48

Please sign in to comment.