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:
parent
aea4ed00d5
commit
f68ef05a56
@ -30,7 +30,7 @@ import _cycles
|
|||||||
|
|
||||||
enum_devices = (
|
enum_devices = (
|
||||||
('CPU', "CPU", "Use CPU for rendering"),
|
('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:
|
if _cycles.with_network:
|
||||||
@ -1188,7 +1188,7 @@ class CyclesPreferences(bpy.types.AddonPreferences):
|
|||||||
|
|
||||||
def get_devices(self):
|
def get_devices(self):
|
||||||
import _cycles
|
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()
|
device_list = _cycles.available_devices()
|
||||||
|
|
||||||
cuda_devices = []
|
cuda_devices = []
|
||||||
@ -1236,21 +1236,19 @@ class CyclesPreferences(bpy.types.AddonPreferences):
|
|||||||
|
|
||||||
|
|
||||||
def draw_impl(self, layout, context):
|
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)
|
layout.row().prop(self, "compute_device_type", expand=True)
|
||||||
|
|
||||||
cuda_devices, opencl_devices = self.get_devices()
|
cuda_devices, opencl_devices = self.get_devices()
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|
||||||
if cuda_devices:
|
if self.compute_device_type == 'CUDA' and cuda_devices:
|
||||||
col = row.column(align=True)
|
col = row.column(align=True)
|
||||||
col.label(text="CUDA devices:")
|
|
||||||
for device in cuda_devices:
|
for device in cuda_devices:
|
||||||
col.prop(device, "use", text=device.name, toggle=True)
|
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 = row.column(align=True)
|
||||||
col.label(text="OpenCL devices:")
|
|
||||||
for device in opencl_devices:
|
for device in opencl_devices:
|
||||||
col.prop(device, "use", text=device.name, toggle=True)
|
col.prop(device, "use", text=device.name, toggle=True)
|
||||||
|
|
||||||
|
@ -1623,11 +1623,9 @@ def draw_device(self, context):
|
|||||||
|
|
||||||
split = layout.split(percentage=1/3)
|
split = layout.split(percentage=1/3)
|
||||||
split.label("Device:")
|
split.label("Device:")
|
||||||
row = split.row(align=True)
|
row = split.row()
|
||||||
sub = row.split(align=True)
|
row.active = show_device_selection(context)
|
||||||
sub.active = show_device_selection(context)
|
row.prop(cscene, "device", text="")
|
||||||
sub.prop(cscene, "device", text="")
|
|
||||||
row.operator("wm.addon_userpref_show", text="", icon='PREFERENCES').module = __package__
|
|
||||||
|
|
||||||
if engine.with_osl() and use_cpu(context):
|
if engine.with_osl() and use_cpu(context):
|
||||||
layout.prop(cscene, "shading_system")
|
layout.prop(cscene, "shading_system")
|
||||||
|
@ -172,6 +172,18 @@ def custom_bake_remap(scene):
|
|||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def do_versions(self):
|
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
|
# We don't modify startup file because it assumes to
|
||||||
# have all the default values only.
|
# have all the default values only.
|
||||||
if not bpy.data.is_saved:
|
if not bpy.data.is_saved:
|
||||||
|
@ -429,6 +429,9 @@ class USERPREF_PT_system(Panel):
|
|||||||
|
|
||||||
col.separator()
|
col.separator()
|
||||||
|
|
||||||
|
if userpref.addons.find('cycles') != -1:
|
||||||
|
userpref.addons['cycles'].preferences.draw_impl(col, context)
|
||||||
|
|
||||||
if hasattr(system, "opensubdiv_compute_type"):
|
if hasattr(system, "opensubdiv_compute_type"):
|
||||||
col.label(text="OpenSubdiv compute:")
|
col.label(text="OpenSubdiv compute:")
|
||||||
col.row().prop(system, "opensubdiv_compute_type", text="")
|
col.row().prop(system, "opensubdiv_compute_type", text="")
|
||||||
|
@ -1108,8 +1108,12 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
|
|||||||
tselem->flag &= ~TSE_CLOSED;
|
tselem->flag &= ~TSE_CLOSED;
|
||||||
|
|
||||||
if (TSELEM_OPEN(tselem, soops)) {
|
if (TSELEM_OPEN(tselem, soops)) {
|
||||||
for (a = 0; a < tot; a++)
|
for (a = 0; a < tot; a++) {
|
||||||
outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_PROPERTY, 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)
|
else if (tot)
|
||||||
te->flag |= TE_LAZY_CLOSED;
|
te->flag |= TE_LAZY_CLOSED;
|
||||||
|
@ -867,14 +867,6 @@ typedef enum eNdof_Flag {
|
|||||||
|
|
||||||
#define NDOF_PIXELS_PER_SECOND 600.0f
|
#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 {
|
typedef enum eMultiSample_Type {
|
||||||
USER_MULTISAMPLE_NONE = 0,
|
USER_MULTISAMPLE_NONE = 0,
|
||||||
USER_MULTISAMPLE_2 = 2,
|
USER_MULTISAMPLE_2 = 2,
|
||||||
|
@ -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");
|
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,
|
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_int_funcs(prop, "rna_Main_version_get", NULL, NULL);
|
||||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
RNA_def_property_flag(prop, PROP_THICK_WRAP);
|
RNA_def_property_flag(prop, PROP_THICK_WRAP);
|
||||||
|
@ -124,6 +124,14 @@ static EnumPropertyItem rna_enum_language_default_items[] = {
|
|||||||
#endif
|
#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))
|
static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
|
||||||
{
|
{
|
||||||
WM_main_add_notifier(NC_WINDOW, NULL);
|
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_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");
|
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, "rna_userdef_opensubdiv_update");
|
||||||
#endif
|
#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)
|
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_pointer_funcs(prop, "rna_UserDef_system_get", NULL, NULL, NULL);
|
||||||
RNA_def_property_ui_text(prop, "System & OpenGL", "Graphics driver and operating system settings");
|
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_view(brna);
|
||||||
rna_def_userdef_edit(brna);
|
rna_def_userdef_edit(brna);
|
||||||
rna_def_userdef_input(brna);
|
rna_def_userdef_input(brna);
|
||||||
|
Loading…
Reference in New Issue
Block a user