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:
Diffstat (limited to 'intern/cycles/device/device.cpp')
-rw-r--r--intern/cycles/device/device.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index 2db2b11c1cb..721c262f094 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -28,6 +28,7 @@
#include "util_math.h"
#include "util_opencl.h"
#include "util_opengl.h"
+#include "util_time.h"
#include "util_types.h"
#include "util_vector.h"
@@ -79,36 +80,36 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
}
}
-Device *Device::create(DeviceInfo& info, bool background, int threads)
+Device *Device::create(DeviceInfo& info, Stats &stats, bool background)
{
Device *device;
switch(info.type) {
case DEVICE_CPU:
- device = device_cpu_create(info, threads);
+ device = device_cpu_create(info, stats);
break;
#ifdef WITH_CUDA
case DEVICE_CUDA:
if(cuLibraryInit())
- device = device_cuda_create(info, background);
+ device = device_cuda_create(info, stats, background);
else
device = NULL;
break;
#endif
#ifdef WITH_MULTI
case DEVICE_MULTI:
- device = device_multi_create(info, background);
+ device = device_multi_create(info, stats, background);
break;
#endif
#ifdef WITH_NETWORK
case DEVICE_NETWORK:
- device = device_network_create(info, "127.0.0.1");
+ device = device_network_create(info, stats, "127.0.0.1");
break;
#endif
#ifdef WITH_OPENCL
case DEVICE_OPENCL:
if(clLibraryInit())
- device = device_opencl_create(info, background);
+ device = device_opencl_create(info, stats, background);
else
device = NULL;
break;
@@ -190,6 +191,18 @@ vector<DeviceInfo>& Device::available_devices()
{
static vector<DeviceInfo> devices;
static bool devices_init = false;
+ static double device_update_time = 0.0;
+
+ /* only update device list if we're not actively rendering already, things
+ * could go very wrong if a device suddenly becomes (un)available. also do
+ * it only every 5 seconds. it not super cpu intensive but don't want to do
+ * it on every redraw. */
+ if(devices_init) {
+ if(!TaskScheduler::active() && (time_dt() > device_update_time + 5.0)) {
+ devices.clear();
+ devices_init = false;
+ }
+ }
if(!devices_init) {
#ifdef WITH_CUDA
@@ -213,6 +226,7 @@ vector<DeviceInfo>& Device::available_devices()
#endif
devices_init = true;
+ device_update_time = time_dt();
}
return devices;