...
<compiler_options>
<defines>
<define>CASTLE_NO_FORCE_DEDICATED_GPU</define>
</defines>
</compiler_options>
Many laptops come now with 2 GPUs: a slower one that consumes less battery and a "dedicated" GPU consuming more battery but capable of much better speeds, esp. when used with non-trivial 3D data. The CGE editor and your applications automatically use the "dedicated" GPU.
Note
|
There’s generally no need to do anything for new projects to activate this. Project DPR / LPR file will contain appropriate code automatically. Unless you have created your project with CGE before 2023-03-07, then run in CGE editor menu item "Code → Regenerate Project". |
Applications created using CGE automatically use dedicated GPU by default, as this is a much better default for games. However you can choose to disable it, and let system choose the default GPU (which may or may not be the faster one).
To do this, compile the project with CASTLE_NO_FORCE_DEDICATED_GPU
symbol defined. We recommend to define it in CastleEngineManifest.xml, like this:
...
<compiler_options>
<defines>
<define>CASTLE_NO_FORCE_DEDICATED_GPU</define>
</defines>
</compiler_options>
To update Lazarus LPI with new symbol, be sure to use "Code → Regenerate Project" menu item in CGE editor (otherwise compiling from Lazarus IDE would not use the new symbol).
Our code to make it happen is based on Benjamin Rosseaux code from https://gist.github.com/BeRo1985/939241b471f776ab844657d28d59368c .
NVidia resources about this:
It is confirmed to work on Windows, with both FPC and Delphi applications.
Linux: We use it, but despite all testing, I (Michalis) remain unsure whether it has any effect.
The necessary code to force dedicated GPU compiles on Linux OK, but does it have any effect on e.g. Nvidia Optimus on Linux? On all my Linux laptop systems with Nvidia installed, I have a somewhat non-standard Optimus setup, and it seems that this flag is ignored (but maybe it’s the fault of my setup). Reports to the contrary are welcome.
macOS, FreeBSD: The necessary code doesn’t even compile, so we disabled it. If there’s a sense to use some similar trick for macOS / FreeBSD, let us know.
To improve this documentation just edit this page and create a pull request to cge-www repository.
Copyright Michalis Kamburelis and Castle Game Engine Contributors.
This webpage is also open-source and we welcome pull requests to improve it.
We use cookies for analytics. See our privacy policy.