mirror of
https://github.com/RPCS3/discord-bot.git
synced 2024-12-13 05:35:58 +00:00
fixes for showing AMD driver versions
This commit is contained in:
parent
4839792879
commit
672d36f1d4
@ -48,14 +48,43 @@ namespace CompatBot.Database.Providers
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetFromOpengl(string openglVersion)
|
||||
public static async Task<string> GetFromOpenglAsync(string openglVersion, bool autoRefresh = true)
|
||||
{
|
||||
if (OpenglToDriver.TryGetValue(openglVersion, out var result) && result != null)
|
||||
return result;
|
||||
|
||||
if (Version.TryParse(openglVersion, out var glVersion))
|
||||
{
|
||||
var glVersions = new List<(Version v, string vv)>(OpenglToDriver.Count);
|
||||
foreach (var key in OpenglToDriver.Keys)
|
||||
{
|
||||
if (Version.TryParse(key, out var ver))
|
||||
glVersions.Add((ver, OpenglToDriver[key]));
|
||||
}
|
||||
if (glVersions.Count == 0)
|
||||
return openglVersion;
|
||||
|
||||
glVersions.Sort((l, r) => l.v < r.v ? -1 : l.v > r.v ? 1 : 0);
|
||||
if (glVersion < glVersions[0].v)
|
||||
return $"older than {glVersions[0].vv} ({openglVersion})";
|
||||
|
||||
var newest = glVersions.Last();
|
||||
if (glVersion > newest.v)
|
||||
{
|
||||
if (autoRefresh)
|
||||
{
|
||||
await RefreshAsync().ConfigureAwait(false);
|
||||
return await GetFromOpenglAsync(openglVersion, false).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return $"newer than {newest.vv} ({openglVersion})";
|
||||
}
|
||||
}
|
||||
|
||||
return openglVersion;
|
||||
}
|
||||
|
||||
public static async Task<string> GetFromVulkanAsync(string vulkanVersion)
|
||||
public static async Task<string> GetFromVulkanAsync(string vulkanVersion, bool autoRefresh = true)
|
||||
{
|
||||
if (!VulkanToDriver.TryGetValue(vulkanVersion, out var result))
|
||||
await RefreshAsync().ConfigureAwait(false);
|
||||
@ -80,11 +109,19 @@ namespace CompatBot.Database.Providers
|
||||
|
||||
vkVersions.Sort((l, r) => l.v < r.v ? -1 : l.v > r.v ? 1 : 0);
|
||||
if (vkVer < vkVersions[0].v)
|
||||
return $"older than {vkVersions[0].vv}";
|
||||
return $"older than {vkVersions[0].vv} ({vulkanVersion})";
|
||||
|
||||
var newest = vkVersions.Last();
|
||||
if (vkVer > newest.v)
|
||||
return $"newer than {newest.vv}";
|
||||
{
|
||||
if (autoRefresh)
|
||||
{
|
||||
await RefreshAsync().ConfigureAwait(false);
|
||||
return await GetFromVulkanAsync(vulkanVersion, false).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return $"newer than {newest.vv} ({vulkanVersion})";
|
||||
}
|
||||
}
|
||||
|
||||
return vulkanVersion;
|
||||
|
@ -298,7 +298,7 @@ namespace CompatBot.Utils.ResultFormatters
|
||||
return null;
|
||||
|
||||
if (gpuInfo.Contains("AMD", StringComparison.InvariantCultureIgnoreCase))
|
||||
return AmdDriverVersionProvider.GetFromOpengl(version);
|
||||
return AmdDriverVersionProvider.GetFromOpenglAsync(version).GetAwaiter().GetResult();
|
||||
|
||||
return version;
|
||||
}
|
||||
@ -313,7 +313,10 @@ namespace CompatBot.Utils.ResultFormatters
|
||||
where m.Success
|
||||
select m
|
||||
).FirstOrDefault(m => m.Groups["device_name"].Value == gpu);
|
||||
return info?.Groups["version"].Value;
|
||||
var result = info?.Groups["version"].Value;
|
||||
if (gpu.Contains("AMD", StringComparison.InvariantCultureIgnoreCase))
|
||||
return AmdDriverVersionProvider.GetFromVulkanAsync(result).GetAwaiter().GetResult();
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string GetVulkanDriverVersionRaw(string gpuInfo, string version)
|
||||
|
Loading…
Reference in New Issue
Block a user