diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_userdef.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 104 |
1 files changed, 95 insertions, 9 deletions
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 164f8e4f0d0..d19498776a0 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -46,6 +46,14 @@ #include "BKE_sound.h" +#ifdef WITH_CYCLES +static EnumPropertyItem compute_device_type_items[] = { + {USER_COMPUTE_DEVICE_NONE, "NONE", 0, "None", "Don't use compute device"}, + {USER_COMPUTE_DEVICE_CUDA, "CUDA", 0, "CUDA", "Use CUDA for GPU acceleration"}, + {USER_COMPUTE_DEVICE_OPENCL, "OPENCL", 0, "OpenCL", "Use OpenCL for GPU acceleration"}, + { 0, NULL, 0, NULL, NULL}}; +#endif + #ifdef RNA_RUNTIME #include "DNA_object_types.h" @@ -65,6 +73,8 @@ #include "UI_interface.h" +#include "CCL_api.h" + static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) { WM_main_add_notifier(NC_WINDOW, NULL); @@ -302,6 +312,68 @@ static void rna_userdef_text_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P WM_main_add_notifier(NC_WINDOW, NULL); } +#ifdef WITH_CYCLES +static EnumPropertyItem *rna_userdef_compute_device_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) +{ + EnumPropertyItem *item= NULL; + int totitem= 0; + + /* add supported device types */ + RNA_enum_items_add_value(&item, &totitem, compute_device_type_items, USER_COMPUTE_DEVICE_NONE); + if(CCL_compute_device_list(0)) + RNA_enum_items_add_value(&item, &totitem, compute_device_type_items, USER_COMPUTE_DEVICE_CUDA); + if(CCL_compute_device_list(1)) + RNA_enum_items_add_value(&item, &totitem, compute_device_type_items, USER_COMPUTE_DEVICE_OPENCL); + + RNA_enum_item_end(&item, &totitem); + *free = 1; + + return item; +} + +static int rna_userdef_compute_device_get(PointerRNA *UNUSED(ptr)) +{ + if(U.compute_device_type == USER_COMPUTE_DEVICE_NONE) + return 0; + + return U.compute_device_id; +} + +static EnumPropertyItem *rna_userdef_compute_device_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) +{ + EnumPropertyItem tmp= {0, "", 0, "", ""}; + EnumPropertyItem *item= NULL; + int totitem= 0; + + if(U.compute_device_type == USER_COMPUTE_DEVICE_NONE) { + /* only add a single CPU device */ + tmp.value = 0; + tmp.name = "CPU"; + tmp.identifier = "CPU"; + RNA_enum_item_add(&item, &totitem, &tmp); + } + else { + /* get device list from cycles. it would be good to make this generic + once we have more subsystems using opencl, for now this is easiest */ + int opencl = (U.compute_device_type == USER_COMPUTE_DEVICE_OPENCL); + CCLDeviceInfo *devices = CCL_compute_device_list(opencl); + int a; + + for(a = 0; devices[a].name; a++) { + tmp.value = devices[a].value; + tmp.identifier = devices[a].identifier; + tmp.name = devices[a].name; + RNA_enum_item_add(&item, &totitem, &tmp); + } + } + + RNA_enum_item_end(&item, &totitem); + *free = 1; + + return item; +} +#endif + #else static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) @@ -1898,6 +1970,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna) prop= RNA_def_property(srna, "theme_area", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "active_theme_area"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_property_enum_items(prop, active_theme_area); RNA_def_property_ui_text(prop, "Active Theme Area", ""); @@ -2608,7 +2681,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) /* locale according to http://www.roseindia.net/tutorials/I18N/locales-list.shtml */ /* if you edit here, please also edit the source/blender/blenfont/intern/blf_lang.c 's locales */ /* Note: As this list is in alphabetical order, and not defined order, - * here is the highest define currently in use: 28 (serbian latin). */ + * here is the highest define currently in use: 29 (kyrgyz). */ static EnumPropertyItem language_items[] = { { 0, "", 0, "Nearly done", ""}, { 0, "DEFAULT", 0, "Default (Default)", ""}, @@ -2633,6 +2706,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) {23, "GREEK", 0, "Greek (Ελληνικά)", "el_GR"}, {27, "INDONESIAN", 0, "Indonesian (Bahasa indonesia)", "id_ID"}, { 2, "JAPANESE", 0, "Japanese (日本語)", "ja_JP"}, + {29, "KYRGYZ", 0, "Kyrgyz (Kyrgyz tili)", "ki"}, {24, "KOREAN", 0, "Korean (한국 언어)", "ko_KR"}, {25, "NEPALI", 0, "Nepali (नेपाली)", "ne_NP"}, /* using the utf8 flipped form of Persian (فارسی) */ @@ -2645,6 +2719,12 @@ static void rna_def_userdef_system(BlenderRNA *brna) {18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"}, { 0, NULL, 0, NULL, NULL}}; +#ifdef WITH_CYCLES + static EnumPropertyItem compute_device_items[] = { + {0, "CPU", 0, "CPU", ""}, + { 0, NULL, 0, NULL, NULL}}; +#endif + srna= RNA_def_struct(brna, "UserPreferencesSystem", NULL); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "UserPreferences"); @@ -2853,14 +2933,20 @@ static void rna_def_userdef_system(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Text Anti-aliasing", "Draw user interface text anti-aliased"); RNA_def_property_update(prop, 0, "rna_userdef_text_update"); -#if 0 - prop= RNA_def_property(srna, "verse_master", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "versemaster"); - RNA_def_property_ui_text(prop, "Verse Master", "Verse Master-server IP"); - - prop= RNA_def_property(srna, "verse_username", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "verseuser"); - RNA_def_property_ui_text(prop, "Verse Username", "Verse user name"); +#ifdef WITH_CYCLES + prop= RNA_def_property(srna, "compute_device_type", PROP_ENUM, PROP_NONE); + RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); + RNA_def_property_enum_sdna(prop, NULL, "compute_device_type"); + RNA_def_property_enum_items(prop, compute_device_type_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_userdef_compute_device_type_itemf"); + RNA_def_property_ui_text(prop, "Compute Device Type", "Device to use for computation (rendering with Cycles)"); + + prop= RNA_def_property(srna, "compute_device", PROP_ENUM, PROP_NONE); + RNA_def_property_flag(prop, PROP_ENUM_NO_CONTEXT); + RNA_def_property_enum_sdna(prop, NULL, "compute_device_id"); + RNA_def_property_enum_items(prop, compute_device_items); + RNA_def_property_enum_funcs(prop, "rna_userdef_compute_device_get", NULL, "rna_userdef_compute_device_itemf"); + RNA_def_property_ui_text(prop, "Compute Device", "Device to use for computation"); #endif } |