diff --git a/CodeLegacy/IO/Config.cs b/CodeLegacy/IO/Config.cs index 43c8bbf..011528d 100644 --- a/CodeLegacy/IO/Config.cs +++ b/CodeLegacy/IO/Config.cs @@ -45,14 +45,17 @@ namespace Flowframes.IO } } - public static void Set(Key key, string value) + public static void Set(Key key, string value, bool allowIfExists = true) { - Set(key.ToString(), value); + Set(key.ToString(), value, allowIfExists); } - public static void Set(string str, string value) + public static void Set(string str, string value, bool allowIfExists = true) { // Reload(); + if (!allowIfExists && CachedValues.ContainsKey(str)) + return; + CachedValues[str] = value; WriteConfig(); } diff --git a/CodeLegacy/Os/VulkanUtils.cs b/CodeLegacy/Os/VulkanUtils.cs index f9f9ea4..af48dbc 100644 --- a/CodeLegacy/Os/VulkanUtils.cs +++ b/CodeLegacy/Os/VulkanUtils.cs @@ -76,13 +76,13 @@ namespace Flowframes.Os if (VkDevices.Count == 0) { Logger.Log($"No Vulkan-capable GPUs found. NCNN implementations will run on the CPU instead and may be unstable."); - Config.Set(Config.Key.ncnnGpus, "-1"); // -1 = CPU + Config.Set(Config.Key.ncnnGpus, "-1", allowIfExists: false); // -1 = CPU return; } // Set the device that has the most compute queues as default GPU var maxQueuesDevice = VkDevices.OrderByDescending(d => d.ComputeQueueCount).First(); - Config.Set(Config.Key.ncnnGpus, $"{maxQueuesDevice.Id}"); + Config.Set(Config.Key.ncnnGpus, $"{maxQueuesDevice.Id}", allowIfExists: false); } public static int GetMaxNcnnThreads(int deviceId)