Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Force usage of dedicated GPU for OpenGL with Delphi and FreePascal/Lazarus on Multi-GPU systems such as Notebooks on Windows
// 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