Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-01-30 20:36:54 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-01-30 20:36:54 +0300
commitf4b1f1f0beece897df0a9013adf2253e89a85975 (patch)
tree936e13ede178105f13396008076db7a955bc97a9 /intern/cycles/blender/blender_python.cpp
parentab682b15582bfc2e550f979c34f2f2b27629ea3d (diff)
parent001414fb2f7346d2ff332bf851373522d87659d7 (diff)
Merge branch 'blender2.7'
Diffstat (limited to 'intern/cycles/blender/blender_python.cpp')
-rw-r--r--intern/cycles/blender/blender_python.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index bf5c2432bc7..d111a1c1f1d 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -388,9 +388,18 @@ static PyObject *sync_func(PyObject * /*self*/, PyObject *args)
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++) {
@@ -746,11 +755,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));
@@ -772,7 +781,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, ""},