在exe里面導出下面兩個變量,同時對N卡和A卡都有效,程序默認打開就會使用獨顯運行。
導出的變量名字必須和下面的一致,不能有前置下划線。
D3D這些年沒琢磨過,理論這個設置D3D也能用。這個方法是系統層顯卡驅動在程序執行時檢測的一個標記,有這個標記,則用獨顯運行。
// http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf // The following line is to favor the high performance NVIDIA GPU if there are multiple GPUs // Has to be .exe module to be correctly detected. // N卡使用獨顯運行 extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; // And the AMD equivalent // Also has to be .exe module to be correctly detected. // A顯卡使用獨顯運行 extern "C" __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 0x00000001;