diff options
Diffstat (limited to 'intern/cycles/device/device.cpp')
-rw-r--r-- | intern/cycles/device/device.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index fc9959e0b48..8c01bcb116f 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -28,9 +28,15 @@ #include "util_time.h" #include "util_types.h" #include "util_vector.h" +#include "util_string.h" CCL_NAMESPACE_BEGIN +bool Device::need_types_update = true; +bool Device::need_devices_update = true; +vector<DeviceType> Device::types; +vector<DeviceInfo> Device::devices; + /* Device Requested Features */ std::ostream& operator <<(std::ostream &os, @@ -42,15 +48,14 @@ std::ostream& operator <<(std::ostream &os, os << "Max nodes group: " << requested_features.max_nodes_group << std::endl; /* TODO(sergey): Decode bitflag into list of names. */ os << "Nodes features: " << requested_features.nodes_features << std::endl; - /* TODO(sergey): Make it utility function to convert bool to string. */ os << "Use hair: " - << (requested_features.use_hair ? "True" : "False") << std::endl; + << string_from_bool(requested_features.use_hair) << std::endl; os << "Use object motion: " - << (requested_features.use_object_motion ? "True" : "False") << std::endl; + << string_from_bool(requested_features.use_object_motion) << std::endl; os << "Use camera motion: " - << (requested_features.use_camera_motion ? "True" : "False") << std::endl; + << string_from_bool(requested_features.use_camera_motion) << std::endl; os << "Use Baking: " - << (requested_features.use_baking ? "True" : "False") << std::endl; + << string_from_bool(requested_features.use_baking) << std::endl; return os; } @@ -277,10 +282,8 @@ string Device::string_from_type(DeviceType type) vector<DeviceType>& Device::available_types() { - static vector<DeviceType> types; - static bool types_init = false; - - if(!types_init) { + if(need_types_update) { + types.clear(); types.push_back(DEVICE_CPU); #ifdef WITH_CUDA @@ -300,7 +303,7 @@ vector<DeviceType>& Device::available_types() types.push_back(DEVICE_MULTI); #endif - types_init = true; + need_types_update = false; } return types; @@ -308,10 +311,8 @@ vector<DeviceType>& Device::available_types() vector<DeviceInfo>& Device::available_devices() { - static vector<DeviceInfo> devices; - static bool devices_init = false; - - if(!devices_init) { + if(need_devices_update) { + devices.clear(); #ifdef WITH_CUDA if(device_cuda_init()) device_cuda_info(devices); @@ -332,7 +333,7 @@ vector<DeviceInfo>& Device::available_devices() device_network_info(devices); #endif - devices_init = true; + need_devices_update = false; } return devices; @@ -359,4 +360,18 @@ string Device::device_capabilities() return capabilities; } +void Device::tag_update() +{ + need_types_update = true; + need_devices_update = true; +} + +void Device::free_memory() +{ + need_types_update = true; + need_devices_update = true; + types.free_memory(); + devices.free_memory(); +} + CCL_NAMESPACE_END |