Bug 89746 - Mesa and LLVM 3.6+ break opengl for genymotion
Summary: Mesa and LLVM 3.6+ break opengl for genymotion
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/radeonsi (show other bugs)
Version: 10.5
Hardware: Other All
: medium normal
Assignee: Default DRI bug account
QA Contact: Default DRI bug account
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-24 10:44 UTC by giuseppe
Modified: 2016-09-01 14:59 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
debug output while crashed (6.80 KB, application/x-bzip2)
2015-03-24 14:55 UTC, Ming-Wei Shih
Details
radeonsi: Cache LLVMTargetMachineRef in context instead of in screen (8.30 KB, patch)
2015-03-26 02:22 UTC, Michel Dänzer
Details | Splinter Review
Radeonsi bug attachment (83.95 KB, text/plain)
2015-03-26 08:20 UTC, giuseppe
Details
[DEBUG] successful launch (13.23 KB, text/plain)
2015-03-26 13:25 UTC, Ming-Wei Shih
Details

Note You need to log in before you can comment on or make changes to this bug.
Description giuseppe 2015-03-24 10:44:17 UTC
I found out LLVM 3.6 + Mesa 10.5 (and newer) might have some sort of regression breaking opengl with radeonsi drivers at least.

I use genymotion (android emulator) which relies on virtualbox and make use of opengl acceleration.
On 2 different machines with 2 different distros (ubuntu 14.10/15.04 and manjaro 0.9 pre4) I had the same problem: as soon as LLVM 3.6 or 3.7git (the latter with utopic when I added paulo dias ppa) gets installed
genymotion stop working (the screen of the vm disappear 1-2 seconds after the machine gets started, and while the screen disappear the machine keeps running in the background).

On the terminal I get this error:
Port 22468 will be used for OpenGL data connections
Unknown TCPCLI command 1003
LLVM ERROR: 'main' label emitted multiple times to assembly file

With LLVM 3.5 genymotion (with the same distros and machines) was working just fine.
Another proof that the issue is with LLVM is that as to temporarily sort this problem out, I installed the proprietary drivers (fgrlx) and the issue vanished (since proprietary drivers do not make use of LLVM).

To reproduce the bug, you need a radeon vga (possibly one using the radeonsi drivers so with GCN architecture) , install vitualbox and genymotion, Setup a virtual device and having installed LLVM 3.6 or newer. Then start the device you created.

I reported this bug to the llvm bug-tracker system and they told me to report it to you.
Comment 1 Ming-Wei Shih 2015-03-24 12:34:03 UTC
I have the exactly the same issue here.

radeonsi + llvm 3.6 gives the exact same error while radeon (and llvm 3.6 installed) or radeonsi + llvm 3.5 never had any issue.

One remark though, it is possible to launch genymotion with the radeonsi + llvm 3.6 combinbation if one tries many times, sometimes it takes 3~5 retries and sometimes 30+. Once started it seems stable.
Comment 2 Tom Stellard 2015-03-24 13:42:41 UTC
Can you set the environment variable R600_DEBUG=ps,vs,gs when you run genymotion and then post the output.
Comment 3 giuseppe 2015-03-24 14:35:27 UTC
I found out that like Ming-Wei Shih reported, if you try several time, sooner or later you'll be able to get the machine started. Unfortunately even then it wasn't stable for me.
Here's the output with the variables indicated by stellard (I ran genymotion with : './genymotion R600_DEBUG=ps,vs,gs'   command )

[p@pop genymotion]$ ./genymotion
Logging activities to file: /home/p/.Genymobile/genymotion.log                                                                    
Logging activities to file: /home/p/.Genymobile/genymotion.log                                                                      
Logging activities to file: /home/p/.Genymobile/Genymotion/deployed/Custom Phone - 4.2.2 - API 17 - 768x1280/genymotion-player.log  
OpenGL connected to 192.168.56.101:25000                                                                                              
Port 22468 will be used for OpenGL data connections
Unknown TCPCLI command 1003
Logging activities to file: /home/p/.Genymobile/genymotion.log
Logging activities to file: /home/p/.Genymobile/Genymotion/deployed/Custom Phone - 4.2.2 - API 17 - 768x1280/genymotion-player.log
OpenGL connected to 192.168.56.101:25000
Port 22468 will be used for OpenGL data connections
Unknown TCPCLI command 1003
Logging activities to file: /home/p/.Genymobile/genymotion.log
Logging activities to file: /home/p/.Genymobile/Genymotion/deployed/Custom Phone - 4.2.2 - API 17 - 768x1280/genymotion-player.log
OpenGL connected to 192.168.56.101:25000
Port 22468 will be used for OpenGL data connections
Unknown TCPCLI command 1003
Unknown TCPCLI command 1003
radeon: Failed to allocate a buffer:
radeon:    size      : 0 bytes
radeon:    alignment : 4096 bytes
radeon:    domains   : 4
radeon:    flags     : 4
radeon: Failed to allocate a buffer:
radeon:    size      : 0 bytes
radeon:    alignment : 4096 bytes
radeon:    domains   : 4
radeon:    flags     : 4
LLVM failed to compile shader
EE si_state_shaders.c:443 si_shader_select - Failed to build shader variant (type=0) -12
Comment 4 Ilia Mirkin 2015-03-24 14:37:58 UTC
(In reply to giuseppe from comment #3)
> (I ran genymotion with : './genymotion R600_DEBUG=ps,vs,gs'   command )

I believe the suggestion was to run it was

R600_DEBUG=ps,vs,gs ./genymotion

That way R600_DEBUG is in genymotion's environment. You should expect to see a ton of output.
Comment 5 Ming-Wei Shih 2015-03-24 14:55:34 UTC
Created attachment 114583 [details]
debug output while crashed

debugging output attached.
Comment 6 Tom Stellard 2015-03-25 21:05:29 UTC
(In reply to Ming-Wei Shih from comment #5)
> Created attachment 114583 [details]
> debug output while crashed
> 
> debugging output attached.

Based on the output it looks like there may be multiple threads compiling shaders.  Do you know if genymotion is multi-threaded?  If it is, is there some way to force it to use only one thread?
Comment 7 Michel Dänzer 2015-03-26 02:22:39 UTC
Created attachment 114629 [details] [review]
radeonsi: Cache LLVMTargetMachineRef in context instead of in screen

Does this patch help?
Comment 8 giuseppe 2015-03-26 08:20:29 UTC
Created attachment 114641 [details]
Radeonsi  bug attachment

THis is the output when I ran:

R600_DEBUG=ps,vs,gs ./genymotion
Comment 9 Michel Dänzer 2015-03-26 08:33:57 UTC
(In reply to giuseppe from comment #8)
> Radeonsi  bug attachment

Is that from running with the patch applied?
Comment 10 Ming-Wei Shih 2015-03-26 13:25:21 UTC
Created attachment 114646 [details]
[DEBUG] successful launch
Comment 11 Ming-Wei Shih 2015-03-26 13:31:03 UTC
It not solved with #7, but things behave differently now.

It's still hit and miss to get it running but when it fails it doesn't crash any more, just gives an error that it cannot connect to the vm.

What's strange though is that when it fails I don't get any debugging at all, so that that means there is a problem with genymotion itself? But then why this never happens with llvm 3.5?

As far as I can tell genymotion's player (the part using OpenGL) is multi-threaded and I can't find a way to disabled it.

Attached a successful run in #10, don't know if that's helpful at all.
Comment 12 Ming-Wei Shih 2015-03-26 16:14:46 UTC
My bad, the patch in #7 fixed the regression for me.

I was having issues earlier because an other user had genymotion running and locked on the same machine, genymotion sometimes has issues to find the correct session and times out when there are multiple users (uid) using it.
Comment 13 giuseppe 2015-03-26 18:33:07 UTC
How do I apply the patch? Can anyone help me indicating the command pls?
Comment 14 Ming-Wei Shih 2015-03-27 12:19:55 UTC
I don't know if here is the best place to do this, in short

- download the patch
- download mesa (either git or tarball), unpack, cd into that dir
- patch -p1 < /path/to/the/patch
- compile & install
Comment 15 giuseppe 2015-03-30 12:43:47 UTC
patch at #7 seemed to have solved the issue with genymotion for me too
Comment 16 Ming-Wei Shih 2015-03-30 16:51:25 UTC
patch applied cleanly against 10.5.2, been running this for almost 2 days.
Comment 17 Michel Dänzer 2015-03-31 01:32:43 UTC
Module: Mesa
Branch: master
Commit: d64adc3a79e419062432cfa8d1cbc437676a3fbd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d64adc3a79e419062432cfa8d1cbc437676a3fbd

Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Mar 26 11:32:59 2015 +0900

radeonsi: Cache LLVMTargetMachineRef in context instead of in screen

Fixes a crash in genymotion with several threads compiling shaders
concurrently.
Comment 18 Kevin McCormack 2015-04-04 22:19:15 UTC
I think this goes along with my issue in this bug report https://bugs.freedesktop.org/show_bug.cgi?id=89685
Comment 19 Darek Deoniziak 2016-09-01 14:14:00 UTC
Hi, not really sure if my issue is related to this one.

The problem with genymotion occured to me while using DRI_PRIME=1 genymotion 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. Genymotion on Intel 5500 Broadwell G2 still works.

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

I know it is newer LLVM and probably problem was fixed in the past, not sure what version of LLVM is used in stock 16.04.

While running genymotion with DRI_PRIME=1 I am getting these errors:
libGL error: unable to load driver: radeonsi_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: radeonsi
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast

I've searched around the web and added this to my .profile:
export LD_PRELOAD='/usr/$LIB/libstdc++.so.6'
export DISPLAY=:0

That helped with running steam but not genymotion. But actually I am not sure if this is related to the emulator issue itself, I might have been getting these error messages too before I've updated oibaf drivers. The genymotion main menu panel to run emulators work, but emulators won't display.

The genymotion emulator log gives me: [Genymotion Player] [Warning] Unrecognized OpenGL version
Comment 20 Emil Velikov 2016-09-01 14:59:29 UTC
Darek, please open a separate bug for your issue.

In general using "export LIBGL_DEBUG=verbose" and/or "export LD_DEBUG=libs" allows everyone to see a bit more about which libraries are picked and why things are failing. It's worth adding some of that in the report.


bug/show.html.tmpl processed on Feb 27, 2017 at 15:45:31.
(provided by the Example extension).