Bug 371497

Summary: Wishlist: Add option to launch application on discrete GPU
Product: [Plasma] plasmashell Reporter: Paul Konecny <paul>
Component: Application Launcher (Kickoff)Assignee: David Edmundson <kde>
Status: RESOLVED FIXED    
Severity: wishlist CC: faure, jgrulich, kde, plasma-bugs, simonandric5
Priority: NOR    
Version: master   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Paul Konecny 2016-10-22 20:29:27 UTC
Hi, 
I just noticed that Gnome is adding an option to directly launch an application on a discrete GPU when one is available.
https://git.gnome.org/browse/gnome-shell/commit/?id=009d021e4f93bfce69d1f4497612d804c88972b6&utm_source=anzwix

Would this be easily achievable? Currently I'm using special application shortcuts that set the DRI_PRIME=1 variable.  To avoid getting a black screen I have to disable compositing with Alt-Shift-F12 or switch kwin to Xrender mode. 
https://wiki.archlinux.org/index.php/PRIME#When_an_application_is_rendered_with_the_discrete_card.2C_it_only_renders_a_black_screen

My suggestion would be: 
1. Right-click application (menu entry or other shortcut i.e. desktop launcher)
2. Select "Run on discrete GPU"
3. Switch kwin to Xrender mode, set DRI_PRIME=1 and launch

Thanks in advance for your feedback!
Cheers!
Comment 1 David Edmundson 2016-10-24 09:52:23 UTC
Is choosing which card an app should run on something you do on a per-app basis or a per-execution basis?

i.e would you *always* want to start Doom3 on the discrete card, or just sometimes?
Comment 2 Paul Konecny 2016-10-25 08:25:29 UTC
I'd say I generally choose on a per app basis. I mostly use this for kdenlive (with movit) and Steam games. 
Sometimes I have to switch to a per-execution basis when debugging though. I once had to investigate a crash that originated in Qt's handling of DRI_PRIME.
Comment 3 Paul Konecny 2016-10-25 08:34:41 UTC
A little correction to my initial post. 
Kwin has to be in Xrender mode because PRIME needs a compositor. If you deactivate it or switch to OpenGL you get a black window. 

My suggested procedure for launching would be: 
1. Right-click application (menu entry or other shortcut i.e. desktop launcher) 
2. Select "Run on discrete GPU" 
4. Check if kwin's enabled or in which compositing mode it is running (i.e.  to OpenGL 3.1)
3. Switch kwin to Xrender mode, set DRI_PRIME=1 and launch
5. End application
6. Restore kwin to previous compositor mode
Comment 4 David Edmundson 2016-11-03 10:26:21 UTC
thanks
Comment 5 Kai Uwe Broulik 2016-11-08 14:42:13 UTC
I think this should be in KRun/KIO so you can configure an application to run on a discrete GPU just like you can configure it to run in terminal, then all places would honor this setting out of the box.

Also, maybe KRun needs another flag where an application can explicitly request running on discrete GPU, when we have a "Run on discrete" option in places.
Comment 6 Jan Grulich 2016-11-09 09:22:11 UTC
Do you think this should go into advanced options, same as "run in terminal" option? Or should it be rather more visible to the user?
Comment 7 Jan Grulich 2016-12-13 13:57:08 UTC
Already implemented and upstreamed. Will be available with Plasma 5.9 and KDE frameworks 5.30.