Created
May 30, 2018 04:04
-
-
Save BeRo1985/939241b471f776ab844657d28d59368c to your computer and use it in GitHub Desktop.
Force usage of dedicated GPU for OpenGL with Delphi and FreePascal/Lazarus on Multi-GPU systems such as Notebooks on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Force usage of dedicated GPU for OpenGL with Delphi and FreePascal/Lazarus on Multi-GPU systems such as Notebooks on Windows | |
// Insert that into your main source file, which is for example the .dpr (Delphi) or .lpr (Lazarus) file | |
{$define ForceDedicatedGPUUsage} // then you can uncomment and recomment this line, for compile-time-switching between | |
// integrated GPU and dedicated GPU | |
{$if defined(Windows) and defined(ForceDedicatedGPUUsage) and (defined(cpu386) or defined(cpux64) or defined(cpuamd64))} | |
{$ifdef fpc} | |
{$asmmode intel} | |
{$endif} | |
procedure NvOptimusEnablement; {$ifdef fpc}assembler; nostackframe;{$endif} | |
asm | |
{$ifdef cpu64} | |
{$ifndef fpc} | |
.NOFRAME | |
{$endif} | |
{$endif} | |
dd 1 | |
end; | |
procedure AmdPowerXpressRequestHighPerformance; {$ifdef fpc}assembler; nostackframe;{$endif} | |
asm | |
{$ifdef cpu64} | |
{$ifndef fpc} | |
.NOFRAME | |
{$endif} | |
{$endif} | |
dd 1 | |
end; | |
exports NvOptimusEnablement, | |
AmdPowerXpressRequestHighPerformance; | |
{$ifend} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment