Better GPU offload handling

Currently GPU offloading for notebooks with both iGPU and dGPU is done via environment variables. However this does not integrate very good with programm and game launchers like Steam, or even desktop files.

Way better would be a way, where the user can select a binary, that then always starts on the dGPU by default. I would like to implement a GUI for that, but afaik there is currently no API this could be built upon.

There is however this suggestion for such an API including a PoC:

  • https:// gitlab.freedesktop .org/glvnd/libglvnd/-/merge_requests/224
  • https:// gitlab.freedesktop .org/glvnd/libglvnd/-/merge_requests/228

I’m here to interest people in these MRs to get the discussion about the API moving.

Has someone an Idea on how to reach the relevant maintainers?

Currently there isn’t a way for this to work in OpenGL and usually will have to use gpu manufacturer programs to select the dedicated gpu for this. However gpu vendors have made a way to access this options outside of this

extern "C" 
{
	__declspec(dllexport) uint32_t NvOptimusEnablement = 1; //for nvidia
	__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; //for amd
}

This is something that vulkan is very good at with requiring the host to select a physical device. So if this doesn’t work then there isn’t much you can do apart from switching API’s.

EDIT: some useful links
NVIDIA Optimus
Selecting the Best Graphics Device to Run a 3D Intensive Application - AMD GPUOpen

Thanks for the reply, but that only helps with new appilcations.

I’m mainly concerned about preexisting binaries like games from Steam, EGS, Lutris, itch, etc… You can already force them to use the dGPU, but that requires environment variables. The suggested API above adds another way with a central config file where specific binaries can be entered to always be executed on the dGPU without the binary needing to support it itself or requiering to set the environment variables before launch. With this a nice gui could be build, with the environment variable approach sadly not because the launchers are too different.

What kind of “API” are you talking about? This doesn’t seem like an “API” (something that those binaries would have to call); this sounds more like an OS configuration. Which already exists, even if it’s not in the most convenient form.

Perhaps when the games are using a library such as OpenGL but not Vulkan as developer chooses the device at runtime. Whether the game uses the dedicated gpu or not with opengl is up to the driver. NVIDIA and AMD have applications that allow you to switch between the two and that’s the only way it can be done as it’s at a driver level. I am not sure what you mean by “the environment variables method” or what you mean by a specific API to do this.

I was using API in a very loose definiton for “a way to interact with the driver stack”.

The “not in the most convenient form”-part is what I seek to fix ^^.

Sorry, I forgot to mention in my initial post that I’m talking about the situation on Linux. I came to this forum from the Mesa website and did not “process” the context switch in my head it seems when I wrote that post.

I guess my point is that this isn’t a thing Khronos or “OpenGL” or even AMD/NVIDIA can fix. This is an OS-level thing and therefore it would need an OS level solution. This is just the wrong venue for looking for a solution.

Bear in mind as well that there are valid reasons for sometimes wanting to prefer to use an integrated GPU. Sometimes it’s the higher-performing device (there are edge cases where this can happen), and sometimes the user may prefer it for power-saving reasons, and as a desirable tradeoff against performance. It’s incorrect to just assume that where a dedicated GPU is in a system, that would always be the preferred device.

For it to work with openGL on Linux it needs to be implemented in the Mesa stack, and finding a link to this forum on the Mesa website I figured I might be able to reach Mesa people here?

ofc, that’s why there should be a gui to select on a per program basis.