I'm programming a DirectX game, and when I run it on an Optimus laptop the Intel GPU is used, resulting in horrible performance. If I force the NVIDIA GPU using the context menu or by renaming my executable to bf3.exe or some other famous game executable name, performance is as expected.
Obviously neither is an acceptable solution for when I have to redistribute my game, so is there a way to programmatically force the laptop to use the NVIDIA GPU?
I've already tried using DirectX to enumerate adapters (IDirect3D9::GetAdapterCount, IDirect3D9::GetAdapterIdentifier) and it doesn't work: only 1 GPU is being reported (the one in use).
Manually Configure OptimusRight Click on your desktop. Click NVIDIA Control Panel. Click Manage 3D Settings on the left menu. Click on the Preferred graphics processor drop down menu under the Global Settings tab.
You can find the 'Hybrid Mode' option on the right side of the screen. This mode allows Optimus to be enabled. This means, when you want to disable Optimus in your Gaming Laptop, you have to switch off the Hybrid Mode. The process is finally completed when you restart your computer.
How do you know if your laptop is using NVidia Optimus? There are several ways to find out what video card your computer uses. An easy method is to go to Device Manager > Display Adapters and see an NVidia option is listed.
According to http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf starting from 302 drivers it is enough to link statically with one of the following libraries: vcamp110.dll, vcamp110d.dll, nvapi.dll, nvapi64.dll, opencl.dll, nvcuda.dll, cudart*.*, or to export a NvOptimusEnablement variable in your program:
extern "C" { _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; }
The Optimus whitepaper at http://www.nvidia.com/object/LO_optimus_whitepapers.html is unclear on exactly what it takes before a switch to GPU is made. The whitepaper says that DX, DXVA, and CUDA calls are detected and will cause the GPU to be turned on. But in addition the decision is based on profiles maintained by NVIDIA and, of course, one does not yet exist for your game.
One thing to try would be make a CUDA call, for instance to cuInit(0);
. As opposed to DX and DXVA, there is not way for the Intel integrated graphics to handle that, so it should force a switch to the GPU.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With