Josh Posted April 2, 2021 Share Posted April 2, 2021 In my test I was running right now, it seemed that a new Leadwerks project was preferring the Intel integrated graphics on a laptop with switchable graphics. The Leadwerks static library already includes a special file that is supposed to tell the computer to prefer discrete graphics but it seems this is not being detected. If you add this file into your C++ project (just drag it into the solution explorer) you may see a significant performance improvement. SwitchableGraphics.cpp 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted April 2, 2021 Author Share Posted April 2, 2021 Or just copy this code into any of your .cpp files: //--------------------------------------------------------------------------------------------------------------------- // // Include this file in your project to indicate the application should use a discrete card, if one is present. // You can remove this file if your application is meant to run in low-performance / low-power mode.11 // //--------------------------------------------------------------------------------------------------------------------- #ifdef _WIN32 #include <windows.h> //Hack to force NVidia discrete card when integrated graphics are present: //http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf - Page 3 extern "C" { _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; _declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; } #endif 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted April 3, 2021 Author Share Posted April 3, 2021 It looks like the discrete card is chosen when the precompiled Lua executable is used, but this code is not detected in the Leadwerks static library when a new C++ project is compiled, so you need to include the code above into your C++ projects in order to select the discrete GPU. This might be new behavior or it could also be something we just never noticed, since it only happens in that one situation. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Robert_d1968 Posted April 3, 2021 Share Posted April 3, 2021 I'm going to switch to Linux, I just can't stand Windows any longer. Will the newer platforms run under linux? Robert Quote Link to comment Share on other sites More sharing options...
Josh Posted April 3, 2021 Author Share Posted April 3, 2021 I don't think this is really a Windows issue. OpenGL was never designed to handle multiple GPU devices. Now that we have the new GUI system functioning this will allow much better cross-platform support, but I do not have a timeframe set for Linux support. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
reepblue Posted April 3, 2021 Share Posted April 3, 2021 I wonder if I can reformat the code to make this work for Linux. I know some System76 laptops support switchable graphics. Not sure if it is a problem with the drivers on that platform. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.