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
This commit is contained in:
@@ -384,9 +384,18 @@ static PyObject *sync_func(PyObject * /*self*/, PyObject *value)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *available_devices_func(PyObject * /*self*/, PyObject * /*args*/)
|
||||
static PyObject *available_devices_func(PyObject * /*self*/, PyObject * args)
|
||||
{
|
||||
vector<DeviceInfo>& devices = Device::available_devices();
|
||||
const char *type_name;
|
||||
if(!PyArg_ParseTuple(args, "s", &type_name)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DeviceType type = Device::type_from_string(type_name);
|
||||
uint mask = (type == DEVICE_NONE) ? DEVICE_MASK_ALL : DEVICE_MASK(type);
|
||||
mask |= DEVICE_MASK_CPU;
|
||||
|
||||
vector<DeviceInfo> devices = Device::available_devices(mask);
|
||||
PyObject *ret = PyTuple_New(devices.size());
|
||||
|
||||
for(size_t i = 0; i < devices.size(); i++) {
|
||||
@@ -742,11 +751,11 @@ static PyObject *enable_print_stats_func(PyObject * /*self*/, PyObject * /*args*
|
||||
|
||||
static PyObject *get_device_types_func(PyObject * /*self*/, PyObject * /*args*/)
|
||||
{
|
||||
vector<DeviceInfo>& devices = Device::available_devices();
|
||||
vector<DeviceType> device_types = Device::available_types();
|
||||
bool has_cuda = false, has_opencl = false;
|
||||
for(int i = 0; i < devices.size(); i++) {
|
||||
has_cuda |= (devices[i].type == DEVICE_CUDA);
|
||||
has_opencl |= (devices[i].type == DEVICE_OPENCL);
|
||||
foreach(DeviceType device_type, device_types) {
|
||||
has_cuda |= (device_type == DEVICE_CUDA);
|
||||
has_opencl |= (device_type == DEVICE_OPENCL);
|
||||
}
|
||||
PyObject *list = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(list, 0, PyBool_FromLong(has_cuda));
|
||||
@@ -768,7 +777,7 @@ static PyMethodDef methods[] = {
|
||||
{"osl_update_node", osl_update_node_func, METH_VARARGS, ""},
|
||||
{"osl_compile", osl_compile_func, METH_VARARGS, ""},
|
||||
#endif
|
||||
{"available_devices", available_devices_func, METH_NOARGS, ""},
|
||||
{"available_devices", available_devices_func, METH_VARARGS, ""},
|
||||
{"system_info", system_info_func, METH_NOARGS, ""},
|
||||
#ifdef WITH_OPENCL
|
||||
{"opencl_disable", opencl_disable_func, METH_NOARGS, ""},
|
||||
|
||||
Reference in New Issue
Block a user