Bug 98146 - DRI_PRIME=1 and fullscreen issues
Summary: DRI_PRIME=1 and fullscreen issues
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/radeonsi (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium major
Assignee: Default DRI bug account
QA Contact: Default DRI bug account
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-07 15:02 UTC by Darek Deoniziak
Modified: 2017-07-25 12:33 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Darek Deoniziak 2016-10-07 15:02:41 UTC
I have multiple issues while using DRI_PRIME=1 (radeon):
1. Few windowed mode applications don't draw content until window is resized. Also right-click context menu doesn't always appear
2. I have screen tearing for fullscreen apps running in , screen is cutted from screen corner to corner, crossing at the centre of the screen.
3. tearing and flickering when running programs.
4. fullscreen games often freeze screen when minimized or closed (tested on multiple games like Talos Principle, Dota, Tomb Raider, 0.ad, etc). After freeze i usualy go to tty and restart lightdm. Maybe it is also intel gpu related?

---
I am using DRI_PRIME=1 for multiple programs after updating drivers using oibaf ppa: https://launchpad.net/~oibaf/+archive/ubuntu/graphics-drivers on Ubuntu 16.04.

I have Dell Inspirion 7548 with Radeon Opal R7 M265 and Broadwell G2, lshw -c video output: http://pastebin.com/kdJzaXNk

DRI_PRIME=1 glxinfo OpenGL renderer: Gallium 0.4 on AMD OLAND (DRM 2.43.0 / 4.4.0-36-generic, LLVM 3.9.0)

DRI_PRIME=1 glxinfo OpenGL version: OpenGL version string: 3.0 Mesa 12.1.0-devel

4.4.0-38-generic Ubuntu 16.04
---

The issues easly can be reproduced, let me know which logs should I submit to help.
Comment 1 Mike Lothian 2016-10-07 15:29:34 UTC
Out of interest which compositor are you using?
Comment 2 Darek Deoniziak 2016-10-07 16:33:10 UTC
"Out of interest which compositor are you using?"
Compiz 0.9.12.2.

One more issue I forgot to mention, 5: while using HDMI monitor and pressing fn buttons to switch screens it sometimes gets buggy - the monitor plugged into hdmi divides itself every time when it happens, so I see main screen and it's smaller copy in left top corner, also screen doesn't react.
Might be this the case of adding custom resolution to monitor in 10-monitor.conf? Monitor was missing at the begining 2k resolution, I've added it manually (monitor supports up to 4k res).

Back about 4th issue: this mostly happens while running Steam, Blender and Atom text editor or Chrome. More native apps like Nautilus, gedit work great using DRI_PRIME=1.

These all issues can be annoying sometimes, especially freezing while closing fullscreen, that's the killer one.
Comment 3 Darek Deoniziak 2016-10-07 16:34:54 UTC
Sorry, in last message while writing 4th problem I meant 3rd, about tearing in programs.
Comment 4 Mike Lothian 2016-10-07 16:55:52 UTC
Also are you using DRI2 or DRI3?

I saw most of those issues with DRI2 but they went away with DRI3

The tearing won't go away until the fencing work lands in the kernel's i915 driver - radeon should work with this but a few things still need to change for amdgpu

I find some of these issues sometimes go away by disabling and enabling the compositor inside the app - in kwin it's Shift + Alt + F12
Comment 5 Darek Deoniziak 2016-10-07 18:27:30 UTC
"Also are you using DRI2 or DRI3?"
Not sure how to check it. The `cat /var/log/Xorg.0.log | grep -i DRI3` command gives me: `[ 40491.158] (==) RADEON(G0): DRI3 enabled` so looks like it is only enabled, but not probably not used, when I look for DRI2 the outpout looks like this: http://pastebin.com/Nevad1GD

Also in xorg.conf.d I have file `10-amdgpu.conf` with content:
Section "OutputClass"
	Identifier "AMDgpu"
	MatchDriver "amdgpu"
	Driver "amdgpu"
EndSection

but in `10-monitor.conf` I have setup at the end of file (which works fine, except for issues I've mention earlier):
...
Section "Device"
    Identifier "Device0"
    Driver "intel"
EndSection

Section "Device"
    Identifier "Device1"
    Driver "radeon"
EndSection

Not sure what's the difference between radeon and amdgpu driver in this case, can 10-amdgpu.conf be related to amdgpu-pro? I've tried amdgpu-pro few weeks ago but that didn't work out at all so I decided to stick with opensource one.

Asking because I would like to try to enable DRI3 and recently it got kind of harder to understand what drivers for radeon are in use (recently I think it was only mesa and fglrx). To use DRI3 should file look like `20-radeon.conf` as filename and inside:
Section "Device"
   Identifier "Radeon"
   Driver "radeon"
   Option "SwapBufferWait" "0"
   Option "DRI" "3"
EndSection
Comment 6 Mike Lothian 2016-10-07 18:46:12 UTC
An easy way to check it to see if DRI_PRIME=1 glxinfo works without issuing any xrandr commands

I don't have individual snippits for the drivers only this:

Section "Device" 
        Identifier      "Graphics"
        Option          "DRI"   "3"
EndSection

Also give it a go with the modesetting driver
Comment 7 Darek Deoniziak 2016-10-07 19:51:15 UTC
Big thanks for help, seems like closing or minimizing fullscreen program doesn't freeze screen anymore (it was biggest issue for me).

I've added 2 files to xorg.conf.d:
20-radeon.conf (this one solved the freezing issue):
Section "Device"
   Identifier "Radeon"
   Driver "radeon"
   Option "SwapBufferWait" "0"
   Option "DRI3" "3"
EndSection

and 20-intel.conf decided to stick with intel driver:
Section "Device"
    Identifier "Intel Graphics"
    Driver "intel"
    Option "DRI" "3"
EndSection

Actually I can't tell if intel is using DRI3, the output from xorg logs is the same. I will also try modesetting driver to see if it does anything.
Comment 8 Darek Deoniziak 2016-10-07 19:53:32 UTC
Woops, of course in xorg.conf.d the radeon conf has Option like this: Option "DRI" "3", I've tried also "DRI3" "1", that's why I wrote it by mistake in last message. Is there any difference by using "DRI3" "1" instead? Both options stopped freezing for me, but again nothing changed in logs.
Comment 9 Mike Lothian 2016-10-10 09:12:43 UTC
I think it was first added as DRI3 when the DRI option was added to bring it inline with other drivers
Comment 10 Michel Dänzer 2016-10-11 07:21:07 UTC
DRI_PRIME=1 LIBGL_DEBUG=verbose glxinfo >/dev/null

prints on stderr whether it's using DRI3 or DRI2.
Comment 11 Darek Deoniziak 2016-10-11 07:32:36 UTC
DRI_PRIME=1 LIBGL_DEBUG=verbose glxinfo >/dev/null:
libGL: screen 0 does not appear to be DRI3 capable
libGL: pci id for fd 4: 1002:6604, driver radeonsi
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/radeonsi_dri.so
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so
libGL: Can't open configuration file /home/darek/.drirc: No such file or directory.
libGL: Can't open configuration file /home/darek/.drirc: No such file or directory.

LIBGL_DEBUG=verbose glxinfo >/dev/null:
libGL: screen 0 does not appear to be DRI3 capable
libGL: pci id for fd 4: 8086:1616, driver i965
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/i965_dri.so
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
libGL: Can't open configuration file /home/darek/.drirc: No such file or directory.
libGL: Using DRI2 for screen 0
libGL: Can't open configuration file /home/darek/.drirc: No such file or directory.
libGL: Can't open configuration file /home/darek/.drirc: No such file or directory.
libGL: Can't open configuration file /home/darek/.drirc: No such file or directory.

It seems that I'm still using DRI2, how can I change that, am I missing some libraries?

I am also using git version of mesa drivers, could closing fullscreen freezing stop after recent updates? I couldn't reproduce freezing (4) and hdmi issues while pressing fn button to change display (5) for last few days.
Comment 12 Michel Dänzer 2016-10-11 07:41:17 UTC
I suspect the intel driver only supports the

 Option "DRI" "3"

notation to enable DRI3 at runtime. If that doesn't work:

* Make sure the Section "Device" with that option is actually being used
* Make sure that DRI3 is enabled in the xf86-video-intel build; if in doubt, try
  passing --enable-dri3 to its configure script
Comment 13 Darek Deoniziak 2016-10-20 19:51:24 UTC
I'm still using DRI2, but the worst thing is the issues I thought were solved are back.

Tried updating drivers (using oibaf ppa all the time) and using single file with settings:
Section "Device" 
        Identifier      "Graphics"
        Option          "DRI"   "3"
EndSection

How can I make sure that it is actually used?
Also couldn't find configure script for intel to pass --enable-dri3.

The output of cat /var/log/Xorg.0.log | grep DRI is:
[     4.875] (II) glamor: EGL version 1.4 (DRI2):
[     4.880] (II) RADEON(G0): [DRI2] Setup complete
[     4.880] (II) RADEON(G0): [DRI2]   DRI driver: radeonsi
[     4.880] (II) RADEON(G0): [DRI2]   VDPAU driver: radeonsi
[     4.881] (==) RADEON(G0): DRI3 enabled
[     5.034] (II) intel(0): [DRI2] Setup complete
[     5.034] (II) intel(0): [DRI2]   DRI driver: i965
[     5.034] (II) intel(0): [DRI2]   VDPAU driver: va_gl
[     5.034] (II) intel(0): direct rendering: DRI2 enabled
[     5.055] (II) GLX: Initialized DRI2 GL provider for screen 0

Sorry for late comment, but I was trying to look around over the web to see if someone had similar issues. Seems like people don't have many problems with switching to DRI3.
Comment 14 Chris Wilson 2016-10-20 20:27:28 UTC
(In reply to Darek Deoniziak from comment #13)
[snips]
> Tried updating drivers (using oibaf ppa all the time) and using single file
> with settings:
> Section "Device" 
>         Identifier      "Graphics"
>         Option          "DRI"   "3"
> EndSection
> 
> How can I make sure that it is actually used?

> [     5.034] (II) intel(0): [DRI2] Setup complete
> [     5.034] (II) intel(0): [DRI2]   DRI driver: i965
> [     5.034] (II) intel(0): [DRI2]   VDPAU driver: va_gl
> [     5.034] (II) intel(0): direct rendering: DRI2 enabled

DRI3 would be mentioned there as well (direct rendering: DRI2 DRI3 enabled).
Check your xorg.conf snippet is being loaded. You can check using xf86-video-intel/tools/dri3info and/or glxinfo.
Comment 15 Darek Deoniziak 2016-10-21 05:33:39 UTC
Thanks, it was my fault after all. As I did mention earlier I had also file called 10-monitor.conf and in that file I had already added section for devices, that file was primarly loaded and overloaded settings from other files.

I moved DRI settings to that file because I was sure it is being loaded:
...

Section "Device"
    Identifier "Device0"
    Driver "intel"
    Option "DRI" "3"
EndSection

Section "Device"
    Identifier "Device1"
    Driver "radeon"
    Option "DRI" "3"
EndSection

Now output of cat /var/log/Xorg.0.log | grep DRI:
[     5.164] (**) intel(0): Option "DRI" "3"
[     5.304] (**) RADEON(G0): Option "DRI" "3"
[     5.390] (II) glamor: EGL version 1.4 (DRI2):
[     5.394] (II) RADEON(G0): [DRI2] Setup complete
[     5.394] (II) RADEON(G0): [DRI2]   DRI driver: radeonsi
[     5.394] (II) RADEON(G0): [DRI2]   VDPAU driver: radeonsi
[     5.395] (**) RADEON(G0): DRI3 enabled
[     5.513] (II) intel(0): [DRI2] Setup complete
[     5.513] (II) intel(0): [DRI2]   DRI driver: i965
[     5.513] (II) intel(0): [DRI2]   VDPAU driver: va_gl
[     5.513] (II) intel(0): direct rendering: DRI2 DRI3 enabled
[     5.528] (II) GLX: Initialized DRI2 GL provider for screen 0

Checked problem:
1 not drawing content until resizing windowed mode applications with DRI_PRIME=1 is solved,
2 did not check yet running fullscreen games
3 programs are still flickering but slightly different and much less,
4 did not check yet running fullscreen games
5 had no chance yet to plug in my external monitor yet

I will be doing some more tests later today and this weekend to see if other problems are solved too, will write info asap. Big thanks for all help so far.
Comment 16 Darek Deoniziak 2016-10-22 16:24:49 UTC
Did some more testing with DRI3 and DRI_PRIME=1 to run programs using radeon.
1. is solved with DRI3 as I did mention in last comment
2. Found big new isse about that, screen is not only cutted to half in some fullscreen games (issue happens while playing Serious Sam 3), but it feels like gpu plays few frames for few milliseconds then it plays these frames again (everything feels worse than small fps). It happens not only in fullscreen applications, if I run genymotion (emulator for Android devices) then the same thing happens. Changing vsync doesn't help. Dota 2 works fine.
3. flickering still happens and additionaly this flashes from time to time, usually when window is not focused: http://i.imgur.com/D0XniPL.png The image also shows cutted screen to half which happens quite often.
4. solved with DRI3, no freezing after closing fullscreen programs
5. solved with DRI3, no issues with external monitor.

What options I could try to solve above issues? 2nd is now the biggest one. Tried for both radeon and intel:
Option "SwapBuffersWait" "0"
Option "TearFree" "true" (also tried "on", is there any difference?)

Noone did help radeon, intel is working fine for both DRI2 and DRI3 (all above issues are related radeon).
Comment 17 Darek Deoniziak 2016-10-22 17:40:34 UTC
Regarding new issue in 2 problem with DRI3. The frame problem is vsync related, after removing Option "SwapBuffersWait" "0" and enabling vsync in Half Life 2 issue is no more, picture is also clear.

Unfortunately in Serious Sam 3 regardless of value of vsync in game options the frames still have issues. In DRI2 Serious Sam 3 has no issues except screen cutted.

What else can I try?
Comment 18 Darek Deoniziak 2016-10-22 20:52:40 UTC
Tried using DRI3 for single GPU with hopes that some issues won't appear.

First made only intel use DRI3 and radeon DRI2 - that felt like when I set both GPUs to use DRI3 (same issues).

Second time I tried DRI3 for radeon and DRI2 for intel (running it currently). It feels like when using DRI2 for both, but closing or minimizing fullscreen application running on radeon doesn't freeze desktop graphics (4), hope it is not temporary. Guess I will stick with that for more because it has no vsync issues at all:
[     4.598] (**) intel(0): Option "DRI" "2"
[     4.752] (**) RADEON(G0): Option "DRI" "3"
[     4.844] (II) glamor: EGL version 1.4 (DRI2):
[     4.849] (II) RADEON(G0): [DRI2] Setup complete
[     4.850] (II) RADEON(G0): [DRI2]   DRI driver: radeonsi
[     4.850] (II) RADEON(G0): [DRI2]   VDPAU driver: radeonsi
[     4.850] (**) RADEON(G0): DRI3 enabled
[     4.968] (II) intel(0): [DRI2] Setup complete
[     4.968] (II) intel(0): [DRI2]   DRI driver: i965
[     4.968] (II) intel(0): [DRI2]   VDPAU driver: va_gl
[     4.968] (II) intel(0): direct rendering: DRI2 enabled
[     4.983] (II) GLX: Initialized DRI2 GL provider for screen 0
Comment 19 Michel Dänzer 2016-10-25 06:35:58 UTC
(In reply to Darek Deoniziak from comment #18)
> First made only intel use DRI3 and radeon DRI2 - that felt like when I set
> both GPUs to use DRI3 (same issues).
> 
> Second time I tried DRI3 for radeon and DRI2 for intel (running it
> currently). It feels like when using DRI2 for both, [...]

Your feeling is correct: The secondary GPU's Xorg driver configuration doesn't matter for this.

Your remaining issues are mostly related to lack of synchronization between the GPUs. This should be better with the i915 driver in recent kernel versions (might require 4.9-rc or newer), see bug 95472.
Comment 20 Darek Deoniziak 2017-06-25 06:42:38 UTC
After switching on the same system from Unity, compiz and lightdm to gnome3 and gdm3, updating drivers (oibaf ppa) the remaining issues are almost gone.

1. I do not notice not drawing content in the windows issue anymore.
2. Tearing is still visible in Steam app, but it is right now just a blink from time to time, hard to notice.
3. Haven't noticed any other heavy tearing and flickering.
...
Rest points were solved previously. I remember I had a lot of tearing while playing SeriousSam3 and STALKER (through wine) on DRI_PRIME=1, will have to check it out again with gnome3 desktop.

If everything will be fine with above, might compiz cause the issues? Or is it because I've up-to-date LLVM and Mesa drivers?

glxinfo:
Gallium 0.4 on AMD OLAND (DRM 2.43.0 / 4.4.0-81-generic, LLVM 4.0.1)
3.0 Mesa 17.2.0-devel
Comment 21 Mike Lothian 2017-06-25 13:35:44 UTC
To stop tearing you'll need to be running kernel 4.10 or newer, as that contains the i915 fences work

You don't need to launch the steam app with DRI_PRIME, you just chance the individual games to launch with it. It'll save you power when you're not gaming
Comment 22 Darek Deoniziak 2017-07-25 12:33:25 UTC
Hi, thanks for the tip to launch only steam game with DRI_PRIME setting enabled, indeed it works.

Also big thanks for making dedicated gpu work without any issues on Linux 4.10 (currently running). Indeed there are no issues whatsoever.

Was testing for few days, both intel and amd gpu:
-Steam app itself,
-few native desktop apps,
-Several games from Steam: Tides of Numenera, Dota2, PAYDAY2, Arma3, Shadow Warrior
-STALKER runned using Wine (previously it was unplayable because of tearing with DRI_PRIME=1, now runs like a charm).

I am basicly forced to close this issue, marking as resolved! Once again thanks.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.