From 2c8f51a453a054951e0a4ecd3b39aee782534e6d Mon Sep 17 00:00:00 2001 From: Jordan Wages Date: Sun, 6 Jan 2019 00:20:29 -0600 Subject: [PATCH] Added Force CPU option Added an option to force CPU usage in case no compatible OpenCL devices were found. --- butterflow-ui.setup/Product.wxs | 2 +- butterflow-ui/App.config | 2 +- butterflow-ui/ButterflowWrapper.cs | 5 +++-- .../Localization/Localization.Designer.cs | 9 +++++++++ butterflow-ui/Localization/Localization.ar.resx | 3 +++ butterflow-ui/Localization/Localization.es.resx | 3 +++ butterflow-ui/Localization/Localization.ja.resx | 3 +++ butterflow-ui/Localization/Localization.resx | 3 +++ butterflow-ui/Localization/Localization.ru.resx | 3 +++ .../Localization/Localization.zh-CN.resx | 3 +++ butterflow-ui/MainWindow.xaml | 2 +- butterflow-ui/MainWindow.xaml.cs | 15 +++++---------- butterflow-ui/OptionsConfiguration.cs | 15 ++++++++++++++- butterflow-ui/Properties/AssemblyInfo.cs | 2 +- butterflow-ui/Properties/Settings.Designer.cs | 4 ++-- butterflow-ui/Properties/Settings.settings | 2 +- 16 files changed, 56 insertions(+), 20 deletions(-) diff --git a/butterflow-ui.setup/Product.wxs b/butterflow-ui.setup/Product.wxs index 67caa36..787a8a6 100644 --- a/butterflow-ui.setup/Product.wxs +++ b/butterflow-ui.setup/Product.wxs @@ -1,6 +1,6 @@ - + diff --git a/butterflow-ui/App.config b/butterflow-ui/App.config index 748bc2f..2f4bad6 100644 --- a/butterflow-ui/App.config +++ b/butterflow-ui/App.config @@ -14,7 +14,7 @@ en-US - 0 + -1 diff --git a/butterflow-ui/ButterflowWrapper.cs b/butterflow-ui/ButterflowWrapper.cs index f30ff73..d56febb 100644 --- a/butterflow-ui/ButterflowWrapper.cs +++ b/butterflow-ui/ButterflowWrapper.cs @@ -97,7 +97,7 @@ namespace butterflow_ui /// Gets or sets the list of devices available for butterflow processing. /// The devices available for butterflow processing. - public Dictionary Devices { get; private set; } = new Dictionary(); + public Dictionary Devices { get; private set; } = new Dictionary() { { 0, Localization.Localization.ForceCPU } }; #endregion @@ -256,7 +256,8 @@ namespace butterflow_ui var deviceID = match.Groups["DeviceID"].Value; var deviceName = match.Groups["DeviceName"].Value.Trim(); - this.interpreter.Interpret(deviceID); + //Add 1 to the index count. This accounts for the 0 index of the "Force CPU" option in the options window. + this.interpreter.Interpret(string.Concat(deviceID,"+1")); if (!this.Devices.ContainsKey(this.interpreter.Int)) { diff --git a/butterflow-ui/Localization/Localization.Designer.cs b/butterflow-ui/Localization/Localization.Designer.cs index 333b237..8328b9f 100644 --- a/butterflow-ui/Localization/Localization.Designer.cs +++ b/butterflow-ui/Localization/Localization.Designer.cs @@ -402,6 +402,15 @@ namespace butterflow_ui.Localization { } } + /// + /// Looks up a localized string similar to Force CPU. + /// + public static string ForceCPU { + get { + return ResourceManager.GetString("ForceCPU", resourceCulture); + } + } + /// /// Looks up a localized string similar to Height. /// diff --git a/butterflow-ui/Localization/Localization.ar.resx b/butterflow-ui/Localization/Localization.ar.resx index ac868ca..64e0f65 100644 --- a/butterflow-ui/Localization/Localization.ar.resx +++ b/butterflow-ui/Localization/Localization.ar.resx @@ -393,4 +393,7 @@ جهاز الحوسبة + + قوة وحدة المعالجة المركزية + \ No newline at end of file diff --git a/butterflow-ui/Localization/Localization.es.resx b/butterflow-ui/Localization/Localization.es.resx index 47c4e83..9aa8b7e 100644 --- a/butterflow-ui/Localization/Localization.es.resx +++ b/butterflow-ui/Localization/Localization.es.resx @@ -393,4 +393,7 @@ Dispositivo de computación + + Unidad de procesamiento central de fuerza + \ No newline at end of file diff --git a/butterflow-ui/Localization/Localization.ja.resx b/butterflow-ui/Localization/Localization.ja.resx index 0fffad4..c4685bc 100644 --- a/butterflow-ui/Localization/Localization.ja.resx +++ b/butterflow-ui/Localization/Localization.ja.resx @@ -393,4 +393,7 @@ コンピューティングデバイス + + 中央処理装置を強制する + \ No newline at end of file diff --git a/butterflow-ui/Localization/Localization.resx b/butterflow-ui/Localization/Localization.resx index e7bcb12..ca249b7 100644 --- a/butterflow-ui/Localization/Localization.resx +++ b/butterflow-ui/Localization/Localization.resx @@ -393,4 +393,7 @@ Computing Device + + Force CPU + \ No newline at end of file diff --git a/butterflow-ui/Localization/Localization.ru.resx b/butterflow-ui/Localization/Localization.ru.resx index dd8744d..564500e 100644 --- a/butterflow-ui/Localization/Localization.ru.resx +++ b/butterflow-ui/Localization/Localization.ru.resx @@ -393,4 +393,7 @@ Вычислительное устройство + + Force CPU + \ No newline at end of file diff --git a/butterflow-ui/Localization/Localization.zh-CN.resx b/butterflow-ui/Localization/Localization.zh-CN.resx index cb5c850..657093a 100644 --- a/butterflow-ui/Localization/Localization.zh-CN.resx +++ b/butterflow-ui/Localization/Localization.zh-CN.resx @@ -393,4 +393,7 @@ 计算设备 + + 部队中央处理股 + \ No newline at end of file diff --git a/butterflow-ui/MainWindow.xaml b/butterflow-ui/MainWindow.xaml index 9c30410..5125954 100644 --- a/butterflow-ui/MainWindow.xaml +++ b/butterflow-ui/MainWindow.xaml @@ -312,7 +312,7 @@ - + diff --git a/butterflow-ui/MainWindow.xaml.cs b/butterflow-ui/MainWindow.xaml.cs index 0248dee..f901934 100644 --- a/butterflow-ui/MainWindow.xaml.cs +++ b/butterflow-ui/MainWindow.xaml.cs @@ -258,15 +258,6 @@ namespace butterflow_ui } } - /// Event handler. Called by mediaPreview for media opened events. - /// Source of the event. - /// Routed event information. - private void mediaPreview_MediaOpened(object sender, RoutedEventArgs e) - { - //this.OptionsConfiguration.Width = this.mediaPreview.NaturalVideoWidth.ToString(); - //this.OptionsConfiguration.Height = this.mediaPreview.NaturalVideoHeight.ToString(); - } - /// Event handler. Called by mediaPreview for media ended events. /// Source of the event. /// Routed event information. @@ -442,7 +433,11 @@ namespace butterflow_ui { var optionsWindow = new OptionsWindow(); - optionsWindow.Show(); + optionsWindow.ShowDialog(); + + //Force an update on the command line arguments in case the user changed something in the + //Options window that necessitates it, such as the compute device. + this.OptionsConfiguration.ForceUpdate(); } #endregion diff --git a/butterflow-ui/OptionsConfiguration.cs b/butterflow-ui/OptionsConfiguration.cs index b0eea4e..f4d75ca 100644 --- a/butterflow-ui/OptionsConfiguration.cs +++ b/butterflow-ui/OptionsConfiguration.cs @@ -467,11 +467,20 @@ namespace butterflow_ui #region Methods + /// Subregion property changed. + /// Source of the event. + /// Property changed event information. private void SubregionPropertyChanged(object sender, PropertyChangedEventArgs e) { OnPropertyChanged("CommandLineOutput"); } + /// Force the object's properties to report as updated. + public void ForceUpdate() + { + OnPropertyChanged(); + } + /// Converts this object to a . /// This object as an OptionsConfigurationFile. public OptionsConfigurationFile ToFile() @@ -532,7 +541,11 @@ namespace butterflow_ui stringBuilder.AppendFormat("-vs {0}:{1} ", this.Width, this.Height); } - if(Settings.Default.Device != 0) + if(Settings.Default.Device == 0) + { + stringBuilder.Append("-sw "); + } + if(Settings.Default.Device > 0) { stringBuilder.AppendFormat("-device {0} ", Settings.Default.Device); } diff --git a/butterflow-ui/Properties/AssemblyInfo.cs b/butterflow-ui/Properties/AssemblyInfo.cs index 0f64b90..95dd2cc 100644 --- a/butterflow-ui/Properties/AssemblyInfo.cs +++ b/butterflow-ui/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ using System.Windows; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.4.*")] +[assembly: AssemblyVersion("1.0.5.*")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/butterflow-ui/Properties/Settings.Designer.cs b/butterflow-ui/Properties/Settings.Designer.cs index be501e5..066ab23 100644 --- a/butterflow-ui/Properties/Settings.Designer.cs +++ b/butterflow-ui/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace butterflow_ui.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -37,7 +37,7 @@ namespace butterflow_ui.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("0")] + [global::System.Configuration.DefaultSettingValueAttribute("-1")] public int Device { get { return ((int)(this["Device"])); diff --git a/butterflow-ui/Properties/Settings.settings b/butterflow-ui/Properties/Settings.settings index 1658093..f444b12 100644 --- a/butterflow-ui/Properties/Settings.settings +++ b/butterflow-ui/Properties/Settings.settings @@ -6,7 +6,7 @@ en-US - 0 + -1 \ No newline at end of file