I have dual GPU's, Intel HD and Nvidia GPU. I want to force my application to use Nvidia GPU. So I created header file
extern "C"
{
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}
and then included into my cpp file where I'm creating device with Nvidia adapter
D3D10CreateDeviceAndSwapChain(dxgiAdapter, D3D10_DRIVER_TYPE_HARDWARE,
0, 0, D3D10_SDK_VERSION, &swapChainDesc,
&pSwapChain, &pDevice);
where dxgiAdapter
is dxgiFactory -> EnumAdapters(1, &dxgiAdapter_);
1
is Nvidia GPU index, 0 - intel HD GPU index.
but my program still using intel's GPU. What is the problem?
Try to pass nullptr
instead of dxgiAdapter
, NvOptimusEnablement
should handle it itself. For example on my machine the nvidia GPU is on the first place and then Intel HD Graphics, so you might be selecting Intel after all. And make sure that somewhere in the nvidia control panel you have set the preferred graphics processor to be auto-selected.
User contributions licensed under CC BY-SA 3.0