From 001414fb2f7346d2ff332bf851373522d87659d7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 29 Jan 2019 16:39:30 +0100 Subject: Cycles: delay CUDA and OpenCL initialization to avoid driver crashes. We've had many reported crashes on Windows where we suspect there is a corrupted OpenCL driver. The purpose here is to keep Blender generally usable in such cases. Now it always shows None / CUDA / OpenCL in the preferences, and only when selecting one will it reveal if there are any GPUs available. This should avoid crashes when opening the preferences or on startup. Differential Revision: https://developer.blender.org/D4265 --- intern/cycles/app/cycles_standalone.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'intern/cycles/app') diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp index ff2e0156b1a..9c899a38e7b 100644 --- a/intern/cycles/app/cycles_standalone.cpp +++ b/intern/cycles/app/cycles_standalone.cpp @@ -363,13 +363,8 @@ static void options_parse(int argc, const char **argv) string devicename = "CPU"; bool list = false; - vector& types = Device::available_types(); - - /* TODO(sergey): Here's a feedback loop happens: on the one hand we want - * the device list to be printed in help message, on the other hand logging - * is not initialized yet so we wouldn't have debug log happening in the - * device initialization. - */ + /* List devices for which support is compiled in. */ + vector types = Device::available_types(); foreach(DeviceType type, types) { if(device_names != "") device_names += ", "; @@ -421,7 +416,7 @@ static void options_parse(int argc, const char **argv) } if(list) { - vector& devices = Device::available_devices(); + vector devices = Device::available_devices(); printf("Devices:\n"); foreach(DeviceInfo& info, devices) { @@ -456,15 +451,12 @@ static void options_parse(int argc, const char **argv) /* find matching device */ DeviceType device_type = Device::type_from_string(devicename.c_str()); - vector& devices = Device::available_devices(); - bool device_available = false; + vector devices = Device::available_devices(DEVICE_MASK(device_type)); - foreach(DeviceInfo& device, devices) { - if(device_type == device.type) { - options.session_params.device = device; - device_available = true; - break; - } + bool device_available = false; + if (!devices.empty()) { + options.session_params.device = devices.front(); + device_available = true; } /* handle invalid configurations */ -- cgit v1.2.3