Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/device/device.cpp
| Show All 26 Lines | |||||
| #include "util_opengl.h" | #include "util_opengl.h" | ||||
| #include "util_time.h" | #include "util_time.h" | ||||
| #include "util_types.h" | #include "util_types.h" | ||||
| #include "util_vector.h" | #include "util_vector.h" | ||||
| #include "util_string.h" | #include "util_string.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| bool Device::need_types_update = true; | |||||
| bool Device::need_devices_update = true; | |||||
| /* Device Requested Features */ | /* Device Requested Features */ | ||||
| std::ostream& operator <<(std::ostream &os, | std::ostream& operator <<(std::ostream &os, | ||||
| const DeviceRequestedFeatures& requested_features) | const DeviceRequestedFeatures& requested_features) | ||||
| { | { | ||||
| os << "Experimental features: " | os << "Experimental features: " | ||||
| << (requested_features.experimental ? "On" : "Off") << std::endl; | << (requested_features.experimental ? "On" : "Off") << std::endl; | ||||
| os << "Max closure count: " << requested_features.max_closure << std::endl; | os << "Max closure count: " << requested_features.max_closure << std::endl; | ||||
| ▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | else if(type == DEVICE_MULTI) | ||||
| return "multi"; | return "multi"; | ||||
| return ""; | return ""; | ||||
| } | } | ||||
| vector<DeviceType>& Device::available_types() | vector<DeviceType>& Device::available_types() | ||||
| { | { | ||||
| static vector<DeviceType> types; | static vector<DeviceType> types; | ||||
| static bool types_init = false; | |||||
| if(!types_init) { | if(need_types_update) { | ||||
| types.clear(); | |||||
| types.push_back(DEVICE_CPU); | types.push_back(DEVICE_CPU); | ||||
| #ifdef WITH_CUDA | #ifdef WITH_CUDA | ||||
| if(device_cuda_init()) | if(device_cuda_init()) | ||||
| types.push_back(DEVICE_CUDA); | types.push_back(DEVICE_CUDA); | ||||
| #endif | #endif | ||||
| #ifdef WITH_OPENCL | #ifdef WITH_OPENCL | ||||
| if(device_opencl_init()) | if(device_opencl_init()) | ||||
| types.push_back(DEVICE_OPENCL); | types.push_back(DEVICE_OPENCL); | ||||
| #endif | #endif | ||||
| #ifdef WITH_NETWORK | #ifdef WITH_NETWORK | ||||
| types.push_back(DEVICE_NETWORK); | types.push_back(DEVICE_NETWORK); | ||||
| #endif | #endif | ||||
| #ifdef WITH_MULTI | #ifdef WITH_MULTI | ||||
| types.push_back(DEVICE_MULTI); | types.push_back(DEVICE_MULTI); | ||||
| #endif | #endif | ||||
| types_init = true; | need_types_update = false; | ||||
| } | } | ||||
| return types; | return types; | ||||
| } | } | ||||
| vector<DeviceInfo>& Device::available_devices() | vector<DeviceInfo>& Device::available_devices() | ||||
| { | { | ||||
| static vector<DeviceInfo> devices; | static vector<DeviceInfo> devices; | ||||
| static bool devices_init = false; | |||||
| if(!devices_init) { | if(need_types_update) { | ||||
| devices.clear(); | |||||
| #ifdef WITH_CUDA | #ifdef WITH_CUDA | ||||
| if(device_cuda_init()) | if(device_cuda_init()) | ||||
| device_cuda_info(devices); | device_cuda_info(devices); | ||||
| #endif | #endif | ||||
| #ifdef WITH_OPENCL | #ifdef WITH_OPENCL | ||||
| if(device_opencl_init()) | if(device_opencl_init()) | ||||
| device_opencl_info(devices); | device_opencl_info(devices); | ||||
| #endif | #endif | ||||
| #ifdef WITH_MULTI | #ifdef WITH_MULTI | ||||
| device_multi_info(devices); | device_multi_info(devices); | ||||
| #endif | #endif | ||||
| device_cpu_info(devices); | device_cpu_info(devices); | ||||
| #ifdef WITH_NETWORK | #ifdef WITH_NETWORK | ||||
| device_network_info(devices); | device_network_info(devices); | ||||
| #endif | #endif | ||||
| devices_init = true; | need_types_update = false; | ||||
| } | } | ||||
| return devices; | return devices; | ||||
| } | } | ||||
| string Device::device_capabilities() | string Device::device_capabilities() | ||||
| { | { | ||||
| string capabilities = "CPU device capabilities: "; | string capabilities = "CPU device capabilities: "; | ||||
| Show All 10 Lines | if(device_opencl_init()) { | ||||
| capabilities += "\nOpenCL device capabilities:\n"; | capabilities += "\nOpenCL device capabilities:\n"; | ||||
| capabilities += device_opencl_capabilities(); | capabilities += device_opencl_capabilities(); | ||||
| } | } | ||||
| #endif | #endif | ||||
| return capabilities; | return capabilities; | ||||
| } | } | ||||
| void Device::tag_update() | |||||
| { | |||||
| need_types_update = true; | |||||
| need_devices_update = true; | |||||
| } | |||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||