1
0
Fork 0
mirror of https://github.com/wagesj45/butterflow-ui.git synced 2024-12-22 01:02:43 -06:00

Added Force CPU option

Added an option to force CPU usage in case no compatible OpenCL devices were found.
This commit is contained in:
Jordan Wages 2019-01-06 00:20:29 -06:00
parent 2d366141a9
commit 2c8f51a453
16 changed files with 56 additions and 20 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="butterflow-ui" Language="1033" Version="1.0.4" Manufacturer="butterflow-ui @ github" UpgradeCode="bba9d512-377a-467e-920a-cbcf36ffc072"> <Product Id="*" Name="butterflow-ui" Language="1033" Version="1.0.5" Manufacturer="butterflow-ui @ github" UpgradeCode="bba9d512-377a-467e-920a-cbcf36ffc072">
<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> <Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

View file

@ -14,7 +14,7 @@
<value>en-US</value> <value>en-US</value>
</setting> </setting>
<setting name="Device" serializeAs="String"> <setting name="Device" serializeAs="String">
<value>0</value> <value>-1</value>
</setting> </setting>
</butterflow_ui.Properties.Settings> </butterflow_ui.Properties.Settings>
</userSettings> </userSettings>

View file

@ -97,7 +97,7 @@ namespace butterflow_ui
/// <summary> Gets or sets the list of devices available for butterflow processing. </summary> /// <summary> Gets or sets the list of devices available for butterflow processing. </summary>
/// <value> The devices available for butterflow processing. </value> /// <value> The devices available for butterflow processing. </value>
public Dictionary<int, string> Devices { get; private set; } = new Dictionary<int, string>(); public Dictionary<int, string> Devices { get; private set; } = new Dictionary<int, string>() { { 0, Localization.Localization.ForceCPU } };
#endregion #endregion
@ -256,7 +256,8 @@ namespace butterflow_ui
var deviceID = match.Groups["DeviceID"].Value; var deviceID = match.Groups["DeviceID"].Value;
var deviceName = match.Groups["DeviceName"].Value.Trim(); 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)) if (!this.Devices.ContainsKey(this.interpreter.Int))
{ {

View file

@ -402,6 +402,15 @@ namespace butterflow_ui.Localization {
} }
} }
/// <summary>
/// Looks up a localized string similar to Force CPU.
/// </summary>
public static string ForceCPU {
get {
return ResourceManager.GetString("ForceCPU", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Height. /// Looks up a localized string similar to Height.
/// </summary> /// </summary>

View file

@ -393,4 +393,7 @@
<data name="DeviceLabel" xml:space="preserve"> <data name="DeviceLabel" xml:space="preserve">
<value>جهاز الحوسبة</value> <value>جهاز الحوسبة</value>
</data> </data>
<data name="ForceCPU" xml:space="preserve">
<value>قوة وحدة المعالجة المركزية</value>
</data>
</root> </root>

View file

@ -393,4 +393,7 @@
<data name="DeviceLabel" xml:space="preserve"> <data name="DeviceLabel" xml:space="preserve">
<value>Dispositivo de computación</value> <value>Dispositivo de computación</value>
</data> </data>
<data name="ForceCPU" xml:space="preserve">
<value>Unidad de procesamiento central de fuerza</value>
</data>
</root> </root>

View file

@ -393,4 +393,7 @@
<data name="DeviceLabel" xml:space="preserve"> <data name="DeviceLabel" xml:space="preserve">
<value>コンピューティングデバイス</value> <value>コンピューティングデバイス</value>
</data> </data>
<data name="ForceCPU" xml:space="preserve">
<value>中央処理装置を強制する</value>
</data>
</root> </root>

View file

@ -393,4 +393,7 @@
<data name="DeviceLabel" xml:space="preserve"> <data name="DeviceLabel" xml:space="preserve">
<value>Computing Device</value> <value>Computing Device</value>
</data> </data>
<data name="ForceCPU" xml:space="preserve">
<value>Force CPU</value>
</data>
</root> </root>

View file

@ -393,4 +393,7 @@
<data name="DeviceLabel" xml:space="preserve"> <data name="DeviceLabel" xml:space="preserve">
<value>Вычислительное устройство</value> <value>Вычислительное устройство</value>
</data> </data>
<data name="ForceCPU" xml:space="preserve">
<value>Force CPU</value>
</data>
</root> </root>

View file

@ -393,4 +393,7 @@
<data name="DeviceLabel" xml:space="preserve"> <data name="DeviceLabel" xml:space="preserve">
<value>计算设备</value> <value>计算设备</value>
</data> </data>
<data name="ForceCPU" xml:space="preserve">
<value>部队中央处理股</value>
</data>
</root> </root>

View file

@ -312,7 +312,7 @@
<Canvas x:Name="canvas" Grid.Row="1" Grid.RowSpan="3" Visibility="{Binding OptionsConfiguration.MultipleFiles, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BoolVisibilityConverter}}"> <Canvas x:Name="canvas" Grid.Row="1" Grid.RowSpan="3" Visibility="{Binding OptionsConfiguration.MultipleFiles, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BoolVisibilityConverter}}">
<TextBlock TextAlignment="Center" VerticalAlignment="Center" Width="{Binding ActualWidth, ElementName=canvas}" Height="{Binding ActualHeight, ElementName=canvas}" TextWrapping="WrapWithOverflow" Text="{x:Static loc:Localization.MultipleFilesPreviewWarningLabel}" /> <TextBlock TextAlignment="Center" VerticalAlignment="Center" Width="{Binding ActualWidth, ElementName=canvas}" Height="{Binding ActualHeight, ElementName=canvas}" TextWrapping="WrapWithOverflow" Text="{x:Static loc:Localization.MultipleFilesPreviewWarningLabel}" />
</Canvas> </Canvas>
<gu:MediaElementWrapper Grid.Row="1" Name="mediaPreview" Stretch="Uniform" ScrubbingEnabled="True" MediaOpened="mediaPreview_MediaOpened" MediaEnded="mediaPreview_MediaEnded" Visibility="{Binding OptionsConfiguration.MultipleFiles, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource InverseBoolVisibilityConverter}}" /> <gu:MediaElementWrapper Grid.Row="1" Name="mediaPreview" Stretch="Uniform" ScrubbingEnabled="True" MediaEnded="mediaPreview_MediaEnded" Visibility="{Binding OptionsConfiguration.MultipleFiles, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource InverseBoolVisibilityConverter}}" />
<Grid Grid.Row="2" Visibility="{Binding OptionsConfiguration.MultipleFiles, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource InverseBoolVisibilityConverter}}"> <Grid Grid.Row="2" Visibility="{Binding OptionsConfiguration.MultipleFiles, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource InverseBoolVisibilityConverter}}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />

View file

@ -258,15 +258,6 @@ namespace butterflow_ui
} }
} }
/// <summary> Event handler. Called by mediaPreview for media opened events. </summary>
/// <param name="sender"> Source of the event. </param>
/// <param name="e"> Routed event information. </param>
private void mediaPreview_MediaOpened(object sender, RoutedEventArgs e)
{
//this.OptionsConfiguration.Width = this.mediaPreview.NaturalVideoWidth.ToString();
//this.OptionsConfiguration.Height = this.mediaPreview.NaturalVideoHeight.ToString();
}
/// <summary> Event handler. Called by mediaPreview for media ended events. </summary> /// <summary> Event handler. Called by mediaPreview for media ended events. </summary>
/// <param name="sender"> Source of the event. </param> /// <param name="sender"> Source of the event. </param>
/// <param name="e"> Routed event information. </param> /// <param name="e"> Routed event information. </param>
@ -442,7 +433,11 @@ namespace butterflow_ui
{ {
var optionsWindow = new OptionsWindow(); 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 #endregion

View file

@ -467,11 +467,20 @@ namespace butterflow_ui
#region Methods #region Methods
/// <summary> Subregion property changed. </summary>
/// <param name="sender"> Source of the event. </param>
/// <param name="e"> Property changed event information. </param>
private void SubregionPropertyChanged(object sender, PropertyChangedEventArgs e) private void SubregionPropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
OnPropertyChanged("CommandLineOutput"); OnPropertyChanged("CommandLineOutput");
} }
/// <summary> Force the object's properties to report as updated. </summary>
public void ForceUpdate()
{
OnPropertyChanged();
}
/// <summary> Converts this object to a <seealso cref="OptionsConfigurationFile"/>. </summary> /// <summary> Converts this object to a <seealso cref="OptionsConfigurationFile"/>. </summary>
/// <returns> This object as an OptionsConfigurationFile. </returns> /// <returns> This object as an OptionsConfigurationFile. </returns>
public OptionsConfigurationFile ToFile() public OptionsConfigurationFile ToFile()
@ -532,7 +541,11 @@ namespace butterflow_ui
stringBuilder.AppendFormat("-vs {0}:{1} ", this.Width, this.Height); 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); stringBuilder.AppendFormat("-device {0} ", Settings.Default.Device);
} }

View file

@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.4.*")] [assembly: AssemblyVersion("1.0.5.*")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -12,7 +12,7 @@ namespace butterflow_ui.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [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 { public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 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.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")] [global::System.Configuration.DefaultSettingValueAttribute("-1")]
public int Device { public int Device {
get { get {
return ((int)(this["Device"])); return ((int)(this["Device"]));

View file

@ -6,7 +6,7 @@
<Value Profile="(Default)">en-US</Value> <Value Profile="(Default)">en-US</Value>
</Setting> </Setting>
<Setting Name="Device" Type="System.Int32" Scope="User"> <Setting Name="Device" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value> <Value Profile="(Default)">-1</Value>
</Setting> </Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>