Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing Machine to Use Dedicated Graphics Card?

I am part of a team developing an application using C++ with SDL and OpenGL.

On laptops when the application is ran the dedicated graphics card is not used and the GL context fails to create because the integrated graphics card does not support the version of GL we want.

I have a feeling that this problem is specific to the laptop in question and not something we can solve through code. But, if anyone knows if there is a solution that'd be great.

like image 708
Connor Hollis Avatar asked May 29 '13 20:05

Connor Hollis


People also ask

How do I force GPU in BIOS?

From the Startup Menu, press the F10 key to enter the BIOS setup utility. Click Advanced. Select Built-In Device Options. Select Graphics, and then select Discrete Graphics.


1 Answers

The easiest way from C++ to ensure that the dedicated graphics card is used instead of chipset switchable graphics under Windows is to export the following symbols (MSVC sample code):

Enable dedicated graphics for NVIDIA:

extern "C" 
{
  __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
}

Enable dedicated graphics for AMD Radeon:

extern "C"
{
  __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}

Caveat: If the user has created a profile for the application to use integrated chipset, then these will not work.

I am unsure if this would work similarly under Linux / MacOS (unlikely).

like image 80
Christopher Oezbek Avatar answered Oct 21 '22 10:10

Christopher Oezbek