1

We're developing software which uses DirectX for 3D rendering on Windows 7 and later machines, 64-bit C#/.NET code.

We've observed that a number of newer Dell laptops we're testing on have dual video cards. They have the Intel HD 4600 integrated graphics and they also have a faster NVIDIA Quadro card (for example).

By default, out of the box, the Intel graphics are used by the DirectX application. This is done, presumably to preserve battery life. But the performance is noticeably worse than the NVIDIA card.

Using the NVIDIA control panel, the user can control which one is used by default. As soon as the user switches it to use the NVIDIA card, the performance sees a big jump for the better.

So, my question is.... Is there any way to, in code, detect this setting and/or modify it for our application (on install and/or on launch)? Can we detect that for our app the Intel card is being used and if its one of these dual card scenarios, prompt the user and perhaps (if they request it) change the setting for them?

As it is currently we have to walk the users through manually making the change in the NVIDIA control panel.

Anyone else have any experience dealing with this and have any advice on how to proceed?

Nerdtron
  • 1,486
  • 19
  • 32

2 Answers2

2

You could use C# DLL Interop to access functions of the NVML (NVidia Management Libraries) that are part of the GPU Deployment Kit (GDK). NVML includes functions such as the following for enumerating and selecting GPU devices:

nvmlInit()
nvmlDeviceGetPciInfo()
nvmlDeviceGetCount()
nvmlDeviceGetHandleByIndex()
nvmlDeviceGetHandleByPciBusId()

and nvmlDeviceSetPersistenceMode().

However, many NVML functions require Admin access and a reboot to change settings. So these are only viable if your users are ok with this (perhaps during initial installation).

A better option would be to enumerate the Direct3D devices and select the most appropriate one: Enumerating with DirectX11, and Enumerating with DirectX9.

axon
  • 1,190
  • 6
  • 16
  • thanks for the reply and suggestions. I'll look into those options. – Nerdtron Oct 30 '15 at 13:44
  • the NVidia control panel allows the user to pick between video cards (i.e. Intel vs. NVidia). No reboot is required. Once you make the change, it takes effect on the next launch of the application. So I wonder if thats different than what would be provided with the functions you posted. – Nerdtron Oct 30 '15 at 13:47
1

The answer is you can't, at least with some exceptions. Laptops that has dual video cards usually comes with a software that switches your currently used card, either manually or automatically. There are others that can automatically detect the need of a software application for larger resources, thus automatically switching to nvidia card.

However, there are a few workarounds for this, please see this thread. In addition, I suggest that you manually set the default graphics card to nvidia for all your laptops in order to eliminate this issue.

Community
  • 1
  • 1
nirvana8510
  • 316
  • 1
  • 4
  • 7
  • Automatic selection usually only affects what the default adapter is. You can still manually enumerate and select a specific adapter using the links in @axon's answer. – MooseBoys Apr 09 '15 at 08:48
  • @nirvana8510 we can't manually set the graphics card on the laptops, they're not our laptops. These are customer machines. We can tell the customers they need to make this selection, but what I was looking for was a programmatic approach to detect/change the setting from the application. – Nerdtron Oct 30 '15 at 13:43