GPU detection will log errors to Sentry.io

This commit is contained in:
Kamil Trzciński 2022-12-20 14:39:21 +01:00
parent 4398177722
commit 9d4828fdf1
3 changed files with 32 additions and 19 deletions

View file

@ -1,5 +1,6 @@
using CommonHelpers;
using System.Diagnostics;
using static CommonHelpers.Log;
using Device = System.Tuple<string, ulong, ulong, uint>;
namespace PowerControl.Helpers.AMD
@ -35,7 +36,14 @@ namespace PowerControl.Helpers.AMD
return OpenMMIO(new IntPtr((long)device.Item2), (uint)(device.Item3 - device.Item2 + 1));
}
public static bool Detect()
public enum DetectionStatus
{
Detected,
Retryable,
NotDetected
}
public static DetectionStatus Detect()
{
var discoveredDevices = new Dictionary<string, string>();
@ -61,12 +69,17 @@ namespace PowerControl.Helpers.AMD
var ranges = DeviceManager.GetDeviceMemResources(devicePNP);
if (ranges is null)
{
TraceLine("GPU: {0}: {1}: No memory ranges", deviceName, devicePNP);
TraceError("GPU: {0}: {1}: No memory ranges", deviceName, devicePNP);
continue;
}
if (!ranges.Contains(new Tuple<UIntPtr, UIntPtr>(new UIntPtr(device.Item2), new UIntPtr(device.Item3))))
var expectedRange = new Tuple<UIntPtr, UIntPtr>(new UIntPtr(device.Item2), new UIntPtr(device.Item3));
if (!ranges.Contains(expectedRange))
{
TraceLine("GPU: {0}: {1}: Memory range not found", deviceName, devicePNP);
TraceError("GPU: {0}: {1}: Memory range not found: {2}",
deviceName,
devicePNP,
String.Join(",", ranges.Select((item) => item.ToString()))
);
continue;
}
@ -74,24 +87,24 @@ namespace PowerControl.Helpers.AMD
{
if (gpu is null)
{
TraceLine("GPU: {0}: {1}: Failed to open.", deviceName, devicePNP);
TraceError("GPU: {0}: {1}: Failed to open.", deviceName, devicePNP);
continue;
}
var smuVersion = gpu.SMUVersion;
if (smuVersion != device.Item4)
{
TraceLine("GPU: {0}: {1}: SMU not supported: {2:X8}", deviceName, devicePNP, smuVersion);
continue;
TraceError("GPU: {0}: {1}: SMU not supported: {2:X8} (IO: {3})", deviceName, devicePNP, smuVersion, expectedRange);
return DetectionStatus.Retryable;
}
TraceLine("GPU: {0}: Matched!", deviceName);
DetectedDevice = device;
return true;
return DetectionStatus.Detected;
}
}
DetectedDevice = null;
return false;
return DetectionStatus.Detected;
}
// Addresses:
@ -441,10 +454,5 @@ namespace PowerControl.Helpers.AMD
CC6_BIT = 58,
GFX_EDC_BIT = 59
}
private static void TraceLine(string format, params object?[]? arg)
{
Trace.WriteLine(string.Format(format, arg));
}
}
}

View file

@ -8,6 +8,8 @@ namespace PowerControl
{
internal static class Program
{
const int MAX_GPU_RETRIES = 3;
/// <summary>
/// The main entry point for the application.
/// </summary>
@ -24,11 +26,13 @@ namespace PowerControl
"You are running EXPERIMENTAL build."))
return;
for (int i = 0; !VangoghGPU.IsSupported; i++)
for (int i = 0; !VangoghGPU.IsSupported && i < MAX_GPU_RETRIES; i++)
{
Instance.WithGlobalMutex(1000, () => VangoghGPU.Detect());
if (VangoghGPU.IsSupported)
Thread.Sleep(300);
var status = Instance.WithGlobalMutex(1000, () => VangoghGPU.Detect());
if (status != VangoghGPU.DetectionStatus.Retryable)
break;
Thread.Sleep(300);
}
}

View file

@ -16,7 +16,8 @@
- Use `white` icons when using `Dark Theme` (thanks @maniman303 https://github.com/ayufan/steam-deck-tools/pull/23)
- Validate that all dependencies are installed
- Allow `Updater.exe` to disable automatic updates - this is selectable option via `setup.exe`
- Use `Sentry.io` for error tracking
- Use `Sentry.io` for error tracking for all builds
- Make `Updater.exe` to be able to update from `.zip` to `setup.exe`
- Bug fixing to handle all known exceptions
- Require to acknowledge when using function that might trigger `Anti-Cheat` protection via top-most window
- GPU detection will log errors to `Sentry.io`