Cycles: add basic backwards compatibility for device selection, move to System tab.

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
This commit is contained in:
Brecht Van Lommel 2016-11-19 01:15:08 +01:00
parent aea4ed00d5
commit f68ef05a56
8 changed files with 52 additions and 23 deletions

View 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)

View 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")

View 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:

View 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="")

View 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;

View 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,

View 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);

View 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);