Cycles: add basic backwards compatibility for device selection, move to System tab.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sat, 19 Nov 2016 00:15:08 +0000 (01:15 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 20 Nov 2016 14:45:22 +0000 (15:45 +0100)
For the multi-GPU case users still have to reconfigure the devices they want to use.

Based on patch from Lukas Stockner.

Differential Revision: https://developer.blender.org/D2347

intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/addon/version_update.py
release/scripts/startup/bl_ui/space_userpref.py
source/blender/editors/space_outliner/outliner_tree.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_userdef.c

index 575a3f9b6c51c31d98f262fd5d4d66a843a86787..b53f85c326637f29e999a9a8ec2b82a800e1217f 100644 (file)
@@ -30,7 +30,7 @@ import _cycles
 
 enum_devices = (
     ('CPU', "CPU", "Use CPU for rendering"),
-    ('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in user preferences"),
+    ('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in the system tab in the user preferences"),
     )
 
 if _cycles.with_network:
@@ -1188,7 +1188,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
 
     def get_devices(self):
         import _cycles
-        # Layout of the device tuples: (Name, Type, Internal ID, Persistent ID)
+        # Layout of the device tuples: (Name, Type, Persistent ID)
         device_list = _cycles.available_devices()
 
         cuda_devices = []
@@ -1236,21 +1236,19 @@ class CyclesPreferences(bpy.types.AddonPreferences):
 
 
     def draw_impl(self, layout, context):
-        layout.label(text="Compute Device:")
+        layout.label(text="Cycles Compute Device:")
         layout.row().prop(self, "compute_device_type", expand=True)
 
         cuda_devices, opencl_devices = self.get_devices()
         row = layout.row()
 
-        if cuda_devices:
+        if self.compute_device_type == 'CUDA' and cuda_devices:
             col = row.column(align=True)
-            col.label(text="CUDA devices:")
             for device in cuda_devices:
                 col.prop(device, "use", text=device.name, toggle=True)
 
-        if opencl_devices:
+        if self.compute_device_type == 'OPENCL' and opencl_devices:
             col = row.column(align=True)
-            col.label(text="OpenCL devices:")
             for device in opencl_devices:
                 col.prop(device, "use", text=device.name, toggle=True)
 
index 6296d6787e511ecec0ab005f380a432e8df84d8a..1856b278c897dab940f0c790e9d016909b88d529 100644 (file)
@@ -1623,11 +1623,9 @@ def draw_device(self, context):
 
         split = layout.split(percentage=1/3)
         split.label("Device:")
-        row = split.row(align=True)
-        sub = row.split(align=True)
-        sub.active = show_device_selection(context)
-        sub.prop(cscene, "device", text="")
-        row.operator("wm.addon_userpref_show", text="", icon='PREFERENCES').module = __package__
+        row = split.row()
+        row.active = show_device_selection(context)
+        row.prop(cscene, "device", text="")
 
         if engine.with_osl() and use_cpu(context):
             layout.prop(cscene, "shading_system")
index 951afd37a92152fd707eff7cdf0757974dd7818c..136080efadce189ec51f954d2ca419e46f311984 100644 (file)
@@ -172,6 +172,18 @@ def custom_bake_remap(scene):
 
 @persistent
 def do_versions(self):
+    if bpy.context.user_preferences.version <= (2, 78, 1):
+        prop = bpy.context.user_preferences.addons[__package__].preferences
+        system = bpy.context.user_preferences.system
+        if not prop.is_property_set("compute_device_type"):
+            if system.legacy_compute_device_type == 1:
+                prop.compute_device_type = 'OPENCL'
+            elif system.legacy_compute_device_type == 2:
+                prop.compute_device_type = 'CUDA'
+            else:
+                prop.compute_device_type = 'NONE'
+            prop.get_devices()
+
     # We don't modify startup file because it assumes to
     # have all the default values only.
     if not bpy.data.is_saved:
index ab3ec3559e551ca08cefee879afcdea103ad6c0a..bdbb63302320473ecece959c1a42053006ce71c6 100644 (file)
@@ -429,6 +429,9 @@ class USERPREF_PT_system(Panel):
 
         col.separator()
 
+        if userpref.addons.find('cycles') != -1:
+            userpref.addons['cycles'].preferences.draw_impl(col, context)
+
         if hasattr(system, "opensubdiv_compute_type"):
             col.label(text="OpenSubdiv compute:")
             col.row().prop(system, "opensubdiv_compute_type", text="")
index 015988efc421d12a389d78559b995656aa040e08..20f7ca4db168dcf76e1f562e0ecb35aa9e0b4699 100644 (file)
@@ -1108,8 +1108,12 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                                        tselem->flag &= ~TSE_CLOSED;
 
                        if (TSELEM_OPEN(tselem, soops)) {
-                               for (a = 0; a < tot; a++)
-                                       outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_PROPERTY, a);
+                               for (a = 0; a < tot; a++) {
+                                       RNA_property_collection_lookup_int(ptr, iterprop, a, &propptr);
+                                       if (!(RNA_property_flag(propptr.data) & PROP_HIDDEN)) {
+                                               outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_PROPERTY, a);
+                                       }
+                               }
                        }
                        else if (tot)
                                te->flag |= TE_LAZY_CLOSED;
index e018b66dd60e4d2963e8853ec01b356022ea58ed..0ad4482708f51d9ec0324e932bfe4590402bbf22 100644 (file)
@@ -867,14 +867,6 @@ typedef enum eNdof_Flag {
 
 #define NDOF_PIXELS_PER_SECOND 600.0f
 
-/* compute_device_type */
-typedef enum eCompute_Device_Type {
-       USER_COMPUTE_DEVICE_NONE        = 0,
-       USER_COMPUTE_DEVICE_OPENCL      = 1,
-       USER_COMPUTE_DEVICE_CUDA        = 2,
-} eCompute_Device_Type;
-
-       
 typedef enum eMultiSample_Type {
        USER_MULTISAMPLE_NONE   = 0,
        USER_MULTISAMPLE_2      = 2,
index d432f086dbaf9ed2d0543a2064d8bdfd6a3dcf2a..94687b6fd465a26d5e949a55bab45850158f3876 100644 (file)
@@ -399,7 +399,7 @@ void RNA_def_main(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Use Autopack", "Automatically pack all external data into .blend file");
 
        prop = RNA_def_int_vector(srna, "version", 3, NULL, 0, INT_MAX,
-                          "Version", "Version of the blender the .blend was saved with", 0, INT_MAX);
+                          "Version", "Version of Blender the .blend was saved with", 0, INT_MAX);
        RNA_def_property_int_funcs(prop, "rna_Main_version_get", NULL, NULL);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_flag(prop, PROP_THICK_WRAP);
index 10807c32b910e959d3a7eb804bb9a05735d4ef3f..ffdc5bb05920a0e52b83eca468b1acc774df08bc 100644 (file)
@@ -124,6 +124,14 @@ static EnumPropertyItem rna_enum_language_default_items[] = {
 #endif
 
 
+static void rna_userdef_version_get(PointerRNA *ptr, int *value)
+{
+       UserDef *userdef = (UserDef *)ptr->data;
+       value[0] = userdef->versionfile / 100;
+       value[1] = userdef->versionfile % 100;
+       value[2] = userdef->subversionfile;
+}
+
 static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
 {
        WM_main_add_notifier(NC_WINDOW, NULL);
@@ -4194,6 +4202,14 @@ static void rna_def_userdef_system(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "OpenSubdiv Compute Type", "Type of computer back-end used with OpenSubdiv");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, "rna_userdef_opensubdiv_update");
 #endif
+
+#ifdef WITH_CYCLES
+       prop = RNA_def_property(srna, "legacy_compute_device_type", PROP_INT, PROP_NONE);
+       RNA_def_property_int_sdna(prop, NULL, "compute_device_type");
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_flag(prop, PROP_HIDDEN);
+       RNA_def_property_ui_text(prop, "Legacy Compute Device Type", "For backwards compatibility only");
+#endif
 }
 
 static void rna_def_userdef_input(BlenderRNA *brna)
@@ -4711,6 +4727,12 @@ void RNA_def_userdef(BlenderRNA *brna)
        RNA_def_property_pointer_funcs(prop, "rna_UserDef_system_get", NULL, NULL, NULL);
        RNA_def_property_ui_text(prop, "System & OpenGL", "Graphics driver and operating system settings");
        
+       prop = RNA_def_int_vector(srna, "version", 3, NULL, 0, INT_MAX,
+                          "Version", "Version of Blender the userpref.blend was saved with", 0, INT_MAX);
+       RNA_def_property_int_funcs(prop, "rna_userdef_version_get", NULL, NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_flag(prop, PROP_THICK_WRAP);
+
        rna_def_userdef_view(brna);
        rna_def_userdef_edit(brna);
        rna_def_userdef_input(brna);