[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52065] trunk/blender: Cycles: correction to how device of lists is exposed to blender

Sergey Sharybin sergey.vfx at gmail.com
Sat Nov 10 09:37:06 CET 2012


Revision: 52065
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52065
Author:   nazgul
Date:     2012-11-10 08:37:02 +0000 (Sat, 10 Nov 2012)
Log Message:
-----------
Cycles: correction to how device of lists is exposed to blender

compute_device_list is using static vector of device information which
had pointers (identifier and name) to values from device information
structures. That structures are also stored in static vector and being
refreshed every 5 seconds.

The issue is, as soon as device information is being updated, pointers
in vector from compute_device_list became incorrect.

Seems it was the reason of issues with sudden switching from CUDA to
OpenCL on my desktop and from CUDA to CPU on my laptop, It was also
seems to be making persistent images behaves instable.

Made it so device identifier and name are copied from device info
to structures used by RNA (CCLDeviceInfo).

Alternative could be avoid cacheing CCLDeviceInfo and always use actual
list of device information by RNA. It shouldn't be so much slow.

Modified Paths:
--------------
    trunk/blender/intern/cycles/blender/CCL_api.h
    trunk/blender/intern/cycles/blender/blender_python.cpp
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c

Modified: trunk/blender/intern/cycles/blender/CCL_api.h
===================================================================
--- trunk/blender/intern/cycles/blender/CCL_api.h	2012-11-10 08:13:13 UTC (rev 52064)
+++ trunk/blender/intern/cycles/blender/CCL_api.h	2012-11-10 08:37:02 UTC (rev 52065)
@@ -23,12 +23,12 @@
 extern "C" {
 #endif
 
-/* returns a list of devices for selection, array is name NULL pointer
+/* returns a list of devices for selection, array is empty identifier
  * terminated and must not be freed */
 
 typedef struct CCLDeviceInfo {
-	const char *identifier;
-	const char *name;
+	char identifier[128];
+	char name[512];
 	int value;
 } CCLDeviceInfo;
 

Modified: trunk/blender/intern/cycles/blender/blender_python.cpp
===================================================================
--- trunk/blender/intern/cycles/blender/blender_python.cpp	2012-11-10 08:13:13 UTC (rev 52064)
+++ trunk/blender/intern/cycles/blender/blender_python.cpp	2012-11-10 08:37:02 UTC (rev 52065)
@@ -418,14 +418,23 @@
 			if(info.type == type ||
 			   (info.type == DEVICE_MULTI && info.multi_devices[0].type == type))
 			{
-				CCLDeviceInfo cinfo = {info.id.c_str(), info.description.c_str(), i++};
+				CCLDeviceInfo cinfo;
+
+				strncpy(cinfo.identifier, info.id.c_str(), sizeof(cinfo.identifier));
+				cinfo.identifier[info.id.length()] = '\0';
+
+				strncpy(cinfo.name, info.description.c_str(), sizeof(cinfo.name));
+				cinfo.name[info.description.length()] = '\0';
+
+				cinfo.value = i++;
+
 				device_list.push_back(cinfo);
 			}
 		}
 
 		/* null terminate */
 		if(!device_list.empty()) {
-			CCLDeviceInfo cinfo = {NULL, NULL, 0};
+			CCLDeviceInfo cinfo = {"", "", 0};
 			device_list.push_back(cinfo);
 		}
 	}

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2012-11-10 08:13:13 UTC (rev 52064)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2012-11-10 08:37:02 UTC (rev 52065)
@@ -395,7 +395,7 @@
 		int a;
 
 		if (devices) {
-			for (a = 0; devices[a].name; a++) {
+			for (a = 0; devices[a].identifier[0]; a++) {
 				tmp.value = devices[a].value;
 				tmp.identifier = devices[a].identifier;
 				tmp.name = devices[a].name;




More information about the Bf-blender-cvs mailing list