Optimus Detection C++


How can i get if the Optimus technology is available on a system, and if its available how to get if the NVidia GPU is used.

Thanks in advance,


Hello. I know it’s been over three years, but I came across this question while Googling and was SEVERELY disappointed to see no answers. :( I’m leaving this here in case anyone needs some ideas.

What I did was a hybrid approach. I used both OpenGL and the NVApi to make a best guess on whether the discrete Optimus NVidia GPU was used.

First, we create an OpenGL context so that we can query the device vendor of the GPU running the application (not just the ones installed on the system). This is using glGetString(GL_VENDOR). I actually got the idea from http://www.opentk.com/node/3144 and I actually used the code in the SOP_Demo.cpp file to do this, so credits to Daniel Cornel for showing me how to do what should’ve been a simple task.

If the user runs the program with a non-NVIDIA GPU, then we can assume that it’s not using Optimus. If it does, we need the NVApi for further checking.

Before all else, we need to call the NvAPI_Initialize() function to use the NVApi.

Then, we need to get the handle for the system’s physical GPU. The NvAPI_EnumPhysicalGPUs function accomplishes this. We then go through all the handles and use NvAPI_GPU_GetSystemType() to check if the GPU is a laptop GPU. If it is, we have to check whether the GPU is discrete using NvAPI_GPU_GetGPUType(). I couldn’t test this on laptops that have an integrated NVIDIA GPU because I no longer have one, but it does say that my current laptop’s NVidia is discrete.

For reference, here’s the documentation for those NVApi functions: http://docs.nvidia.com/gameworks/content/gameworkslibrary/coresdk/nvapi/group__gpu.html

I’m not sure if the laptops using the desktop GTX 980 will tell you that you’re using a laptop GPU or not. This approach probably isn’t foolproof, but it’s a good guess.

It would be nicer if NVidia could provide us API functions that would just tell us if an application uses the dGPU hint hint. Direct3D 11’s Desktop Duplication interface fails to retrieve the desktop image when the dGPU is used in my experience, which is why we needed to check whether the user overrode the default setting to use integrated graphics.