Jump to content

Make sure your Leadwerks project is using the discrete GPU


Josh
 Share

Recommended Posts

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

  • Like 2

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

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

 

  • Thanks 1

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

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.

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

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.

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

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.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...