[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51501] trunk/blender/intern/cycles: Fix related to #32929: update list of available devices for cycles rendering

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Oct 22 16:04:44 CEST 2012


Revision: 51501
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51501
Author:   blendix
Date:     2012-10-22 14:04:44 +0000 (Mon, 22 Oct 2012)
Log Message:
-----------
Fix related to #32929: update list of available devices for cycles rendering
while Blender is running, not only on load. It might help a case when Blender
is started before the CUDA driver is fully initialized.

Modified Paths:
--------------
    trunk/blender/intern/cycles/device/device.cpp
    trunk/blender/intern/cycles/util/util_task.h

Modified: trunk/blender/intern/cycles/device/device.cpp
===================================================================
--- trunk/blender/intern/cycles/device/device.cpp	2012-10-22 14:04:40 UTC (rev 51500)
+++ trunk/blender/intern/cycles/device/device.cpp	2012-10-22 14:04:44 UTC (rev 51501)
@@ -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"
 
@@ -188,7 +189,19 @@
 {
 	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
 		if(cuLibraryInit())
@@ -211,6 +224,7 @@
 #endif
 
 		devices_init = true;
+		device_update_time = time_dt();
 	}
 
 	return devices;

Modified: trunk/blender/intern/cycles/util/util_task.h
===================================================================
--- trunk/blender/intern/cycles/util/util_task.h	2012-10-22 14:04:40 UTC (rev 51500)
+++ trunk/blender/intern/cycles/util/util_task.h	2012-10-22 14:04:44 UTC (rev 51501)
@@ -95,6 +95,7 @@
 	static void exit();
 
 	static int num_threads() { return threads.size(); }
+	static bool active() { return users != 0; }
 
 protected:
 	friend class TaskPool;




More information about the Bf-blender-cvs mailing list