Nvidia optimus NvOptimusEnablement

1

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?

c++
directx
nvidia
asked on Stack Overflow Apr 27, 2018 by Alatriste • edited Apr 27, 2018 by BDL

1 Answer

0

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.

answered on Stack Overflow May 4, 2018 by Michael Loda

User contributions licensed under CC BY-SA 3.0