Merge branch 'blender2.7'
[blender.git] / intern / cycles / blender / addon / properties.py
index 8250100..c60db9f 100644 (file)
@@ -1453,7 +1453,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
     def get_devices(self):
         import _cycles
         # Layout of the device tuples: (Name, Type, Persistent ID)
-        device_list = _cycles.available_devices()
+        device_list = _cycles.available_devices(self.compute_device_type)
         # Make sure device entries are up to date and not referenced before
         # we know we don't add new devices. This way we guarantee to not
         # hold pointers to a resized array.
@@ -1477,7 +1477,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
 
     def get_num_gpu_devices(self):
         import _cycles
-        device_list = _cycles.available_devices()
+        device_list = _cycles.available_devices(self.compute_device_type)
         num = 0
         for device in device_list:
             if device[1] != self.compute_device_type:
@@ -1490,25 +1490,32 @@ class CyclesPreferences(bpy.types.AddonPreferences):
     def has_active_device(self):
         return self.get_num_gpu_devices() > 0
 
-    def draw_impl(self, layout, context):
-        available_device_types = self.get_device_types(context)
-        if len(available_device_types) == 1:
-            layout.label(text="No compatible GPUs found", icon='INFO')
+    def _draw_devices(self, layout, device_type, devices):
+        box = layout.box()
+
+        found_device = False
+        for device in devices:
+            if device.type == device_type:
+                found_device = True
+                break
+
+        if not found_device:
+            box.label(text="No compatible GPUs found", icon='INFO')
             return
-        layout.row().prop(self, "compute_device_type", expand=True)
 
-        cuda_devices, opencl_devices = self.get_devices()
-        row = layout.row()
+        for device in devices:
+            box.prop(device, "use", text=device.name)
 
-        if self.compute_device_type == 'CUDA' and cuda_devices:
-            box = row.box()
-            for device in cuda_devices:
-                box.prop(device, "use", text=device.name)
+    def draw_impl(self, layout, context):
+        row = layout.row()
+        row.prop(self, "compute_device_type", expand=True)
 
-        if self.compute_device_type == 'OPENCL' and opencl_devices:
-            box = row.box()
-            for device in opencl_devices:
-                box.prop(device, "use", text=device.name)
+        cuda_devices, opencl_devices = self.get_devices()
+        row = layout.row()
+        if self.compute_device_type == 'CUDA':
+            self._draw_devices(row, 'CUDA', cuda_devices)
+        elif self.compute_device_type == 'OPENCL':
+            self._draw_devices(row, 'OPENCL', opencl_devices)
 
     def draw(self, context):
         self.draw_impl(self.layout, context)