Stop Vulkan init from overwriting config value for NCNN GPU ID

This commit is contained in:
n00mkrad
2026-05-21 00:22:30 +02:00
parent 1d63b75feb
commit 3fe2ecb755
2 changed files with 8 additions and 5 deletions

View File

@@ -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();
}

View File

@@ -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)