问题
In order to save power it is common in recent graphics architectures to dynamically switch between a discrete high-performance and an integrated lower-performance GPU, where the high-performance GPU is only enabled when the need for extra performance is present.
This technology is branded as nvidia Optimus and AMD Enduro for the two main GPU vendors.
However due to the non-standardized way in which these technologies work, managing them from a developer's perspective can be a nightmare. For example in this PDF from nvidia on the subject, they explain the many intricacies, limitations and pitfalls that you will have to worry about as a developer to manage nvidia Optimus on just one platform.
As an example, in the linked PDF above, the following is a tip for selecting GPU on Windows:
extern "C" {
_declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}
However that will only work for nvidia GPUs on Windows platform. What would be the equivalent for AMD/Intel on OSX/Linux, and on AMD hardware?
So in more detail my question is, how can I
- Detect the presence of Optimus/Enduro and possibly other dynamically=switching GPU architectures programmatically?
- Select which of the GPUs should be enabled programmatically?
- Do so in a manner that is cross-platform over all relevant platforms?
- Do so in a manner that works together with all technologies that might use GPU such as DX/OpenGL/Vulkan/OpenCL/CUDA/Qt?
I am working with C++14/Qt5.7 codebase under Ubuntu 16.04-amd64 using nVidia hardware.
来源:https://stackoverflow.com/questions/40684299/enable-disable-optimus-enduro-in-cross-platform-manner