开发者

In .NET 3.5 C#, is there a way to detect if NVIDIA SLI mode is active

For NVIDIA graphics cards, you can have two working as one (SLI). For a .NET desktop application, I need to be able to check开发者_C百科 that SLI is enabled. Is this possible?


That should be possible.

According to the nVidia docs, you can query this via NVCPL.DLL (liked to documentation).

The call to be used is NvCplGetDataInt() (page 67), with the argument NVCPL_API_NUMBER_OF_SLI_GPUS or NVCPL_API_SLI_MULTI_GPU_RENDERING_MODE you should obtain the information required.

In oder to access this information, you'll need P/Invoke. If it is OK to statistically link NVCPL.DLL you just have to create the correct import (static external method) and you're fine. Otherwise, you can also choose the LoadLibrary and GetEntryPoint way and use the Marshal class to create an instance of a delegate (declared with the correct arguments) which represents the function to be called.

Edit: The following snippet may get you started (I don't have a nVidia card though, so that's completely untested and on your own risk ;) ):

public const int NVCPL_API_NUMBER_OF_GPUS =7;    // Graphics card number of GPUs. 
public const int NVCPL_API_NUMBER_OF_SLI_GPUS = 8;    // Graphics card number of SLI GPU clusters available. 
public const int NVCPL_API_SLI_MULTI_GPU_RENDERING_MODE = 9;    // Get/Set SLI multi-GPU redering mode.  

[DllImport("NVCPL.DLL", CallingConvention=CallingConvention.Cdecl)]
public static extern bool nvCplGetDataInt([In] int lFlag, [Out] out int plInfo);

public static void Main()   {
    int sliGpuCount;
    if (nvCplGetDataInt(NVCPL_API_NUMBER_OF_SLI_GPUS, out sliGpuCount)) {
        // we got the result
        Console.WriteLine(string.Format("SLI GPU present: {0}", sliGpuCount));
    } else {
        // something did go wrong
        Console.WriteLine("Failed to query NV data");
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜