0

I am developing a .net core application where I need to retrieve as much information about the system as possible. I have managed to retrieve already a lot, however, I am struggling to find out whether the GPU has Vsync turned on or not. I have tried the NvApi Wrapper for an Nvidia GPU but couldn't get it working as it throws an exception when trying to initialize it (could not load nvapi64.dll). The original NvApi is written in C and making a Wrapper just for this one specific thing seems a bit too much. I guess there must be an easier way to get this information.

I have also tried to get the value using the ManagementObjectSearcher as shown below but it doesn't return whether vsync is active or not:

var managementObjectSearcher = new ManagementObjectSearcher("select * from Win32_VideoController");
foreach (ManagementObject obj in managementObjectSearcher.Get())
{
    foreach(var prop in obj.Properties)
    {
        Console.WriteLine($"Name: {prop.Name} Value: {prop.Value}");
    }
}
Isma
  • 14,604
  • 5
  • 37
  • 51
Chookees
  • 33
  • 1
  • 7
  • @Isma Thanks :-) – Chookees Mar 05 '19 at 09:43
  • Can you use DirectX for this? – Isma Mar 05 '19 at 09:52
  • @Isma No i tried it, but couldn't figur out through it, whether Vsync is enabled or disabled. – Chookees Mar 05 '19 at 10:08
  • Are you using Windows Forms or WPF? – Isma Mar 05 '19 at 10:15
  • @Isma Neither, it's a .net Core 2.0 Application. – Chookees Mar 05 '19 at 10:18
  • Whether or not v-sync is in effect is not a property of the GPU, and to some extent not even the driver. You can control this per application, so it's unclear what you're even after, and why. For example, the GPU driver may have a default for v-sync that's applied if the application doesn't override it. Getting this setting necessarily means using proprietary interfaces, though (or else running a small 3D application that overrides no defaults and checking if v-sync happens to be applied). A lot of effort for what can't be a lot of gain, outside an application that needs to care. – Jeroen Mostert Mar 05 '19 at 10:40

1 Answers1

0

I could get the info you need using the open source library OpenTK which provides a managed wrapper for OpenGL, for more info see here.

First, add the NuGet package compatible with .net core:

Install-Package OpenTK.NetStandard -Version 1.0.4 

Then, you can just create a dummy class with an instance of GameWindow and you will have access to the information you are looking for (among others):

public sealed class DummyInfoGameWindow : GameWindow
{
    private DummyInfoGameWindow() {}

    public static DummyInfoGameWindow InitAndGetInfo()
    {
        return new DummyInfoGameWindow();
    }
}

Then just call the static method from your code:

static void Main(string[] args)
{
    var info = DummyInfoGameWindow.InitAndGetInfo();

    Console.WriteLine($"VSync enabled {info.VSync}");

    Console.Read();
}

The output is:

VSync enabled On
Isma
  • 14,604
  • 5
  • 37
  • 51