PDA

View Full Version : Guide Mesa-mild manual compilation instructions



epigramx
27.02.2018, 05:23
Disclaimer: Mesa upstream from v18.2 onwards has OpenGL compatibility profile support which should offer better support than mesa mild for the current OpenGL backend of Cemu. The current guide can still be used partly to compile a Mesa version but most distributions should gradually have an updated Mesa by default or the default compilation instructions should be sufficient.

https://i.imgur.com/MmIShUt.png

For people already familiar with linux' ways, compiling mesa is relatively straightforward (it's a standard ./configure; make; make install thing), however, it does have some caveats mainly during ./configure and keeping it sandboxed from main system mesa and final launching options hence this little guide.

The guide assumes debian sid, but it should be easily equivalent in all distros since the building and launching are basically identical everywhere

1. Get mesa mild: (enter a working dir ideally to not spam your home dir; e.g. mkdir ~/mesa_source; cd ~/mesa_source)

git clone --depth 1 https://github.com/TheYoshiGuy/mesa_mild.git

(--depth 1 kills the git history to get it faster; if it fails, omit that)

If you don't have git, get it from your distro, e.g. sudo apt-get install git

(Note: the original "https://github.com/mikakev1/mesa_mild_compatibility" repo has been deleted by its author)

2. Get the dependencies to build it e.g. on sid:

sudo apt-get build-dep mesa

Note: for a few other distros the equivalent command can be found under "1.2 Requirements" here (https://www.mesa3d.org/install.html) (ignore the rest of that page).

3. Enter mesa_mild_compatibility/ and prepare it with autogen

./autogen.sh

It may fail at first configure (it launches it without asking) but don't care, we need other options anyway

4. Configure it, but not with just a ./configure, it needs some options and to be "sandboxed" with a --prefix to not disrupt system's mesa (it may fail to bring up a windows environment otherwise)

a) Make sure you have:

latest libdrm/libdrm-dev
latest llvm/llvm-dev: preferably version 7 (currently) (it solves bugs with latest AMDs)

b) If you installed any of the tools required to /usr/local/lib (with a standard ./configure; make; make install, e.g. for libdrm if your system didn't have the latest) you might need to point ./configure to it with LD_LIBRARY_PATH.

c) A complete ./configure line as an example:

LD_LIBRARY_PATH=/usr/local/lib ./configure --with-llvm-prefix=/usr/lib/llvm-7/ --with-gallium-drivers=radeonsi --with-dri-drivers=radeon,swrast --enable-texture-float --prefix=$HOME/mesa_mild --with-vulkan-drivers=radeon

($HOME instead of "~" above is usually a requirement)

That line basically "sandboxes" mesa later on to ~/mesa_mild/ so it doesn't disrupt the main mesa (we'll tell wine/cemu where to find it later), it instructs it to use llvm-7 (try to install the latest in any case), it compiles only the radeonsi gallium driver (old AMD cards may need another), dri drivers are included, and it includes the buggy (currently) vulkan driver as a bonus (unnecessary for Cemu but you may want it).

Note: To detect llvm on some systems, it might be only a matter of not using --with-llvm-prefix=[..] at all since llvm-config might reside in the expected path (/usr/bin/) (even if it's the latest).

Absolutely crucial (on current mesa at least) is that --enable-texture-float is included(at least BotW will fail to render properly without it) (the above line includes it). In case you wonder why the hell isn't that the default, it's apparently because of patenting issues.

Addendum: That option might be gone on current versions of the source.

Scroll up slightly after configuration to make sure it got what you need:
https://i.imgur.com/treeN53.png
(e.g. here we see llvm 7 being properly detected, as well as radeonsi gallium will be built for newer AMD cards)

5. Just build and install now

make -j 8 install (not even root is needed because we install to a --prefix that points to home in this example; -j 8 instructs it to use 8 threads).

(Note: if you hit a quirk that the above line restarts a vanilla ./configure, cancel it and do 'make -j 8' and 'make install' separately)

Now, before final launching:

6. You may need a new-ish linux kernel (ideally) and in the case of newer AMD cards to restrict it to using AMDGPU instead of the radeon module if your distro doesn't do that otherwise already.

e.g. for an R9 290, and with grub on sid edit /etc/default/grub, and edit/make the line:

GRUB_CMDLINE_LINUX="radeon.si_support=0 radeon.cik_support=0 amdgpu.si_support=1 amdgpu.cik_support=1"

and then

update-grub

and reboot (which will instruct the kernel to only go with amdgpu instead of radeon)

7. In case you haven't done that already or your distro hasn't, you may need to get a firmware-amd-graphics (or equivalent) package

In the case of debian sid that is required to be done manually at some point because it considers it "non-free".

so install firmware-amd-graphics, after you have included non-free in apt's sources list (google how)/reboot.

8. If you haven't done that already, edit Cemu.exe from #version 420 to #version 450 (search "version 420" in a text editor) per the main mesa mild readme (https://github.com/mikakev1/mesa_mild_compatibility/blob/master/README.md) and while you're at it keep in mind the info of that readme in general.

9. And a magic line to launch Cemu (this line includes the required driconf settings on top so no need to fiddle with those either and you may want to not fiddle with .drirc at all to begin with to not disrupt the main system).

allow_minus_one_index_uniform=true allow_extended_primitive_type=true allow_gl_extensions_in_core=true allow_relaxed_vbo_validation=true mesa_glthread=true force_glsl_extensions_warn=true allow_relaxed_core_profile=true allow_higher_compat_version=true LD_LIBRARY_PATH=~/mesa_mild/lib/ MESA_GL_VERSION_OVERRIDE=4.5COMPAT wine64 Cemu.exe

The first few variables are basically a replacement to a .drirc/driconf in the form of env vars, then there is a LD_LIBRARY_PATH to point to our "sandboxed" mesa

You can obviously turn that line into a script by putting it into an .sh and chmod +x that .sh, but if you do, you might want to also add on top a "cd <PATH TO CEMU>"(change that to a path to cemu) so that you don't have to run it only when inside that dir.

This guide assumes you already had a recent wine, but if you don't e.g. for debian get it from here https://wiki.winehq.org/Debian (But in general Cemu isn't very picky about wine versions, it works with the stable version too, no need for staging or -devel etc.).

10. Enjoy. If you didn't 'enjoy', just go through the steps carefully and change what you need for your system (e.g. user name and paths and dependencies needed to be installed) because this guide isn't meant to show the basics of linux (that can be googled very easily) but the quirks specifically about Cemu and mesa mild that can't be googled almost at all.

PS. For information regarding specific GPU models and specific games see this reply (https://forum.cemu.info/showthread.php/492-Mesa-mild-manual-compilation-instructions-(to-avoid-docker-and-the-like)?p=2013&viewfull=1#post2013).

NoskLo
27.02.2018, 14:47
Excellent guide! Thanks for that!

Zacharybinx34
01.03.2018, 20:32
Hey, thanks for the guide!
However, how did you get llvm-7 installed? I am on latest Manjaro Distro.

Thanks!

epigramx
02.03.2018, 05:02
See if there is a package available or compile it yourself (but that might be daunting). I'm gonna be honest here; I don't get why people use novel distros like that and not something very established like debian sid before going there. Is it because they were told by the mesa mild maintainer in this case?

In any case, it's linux, even if it doesn't exist precompiled, it's compilable.

Granted, in this case it is cutting edge, since 7 is unreleased.

Xalphenos
02.03.2018, 07:06
Hey, thanks for the guide!
However, how did you get llvm-7 installed? I am on latest Manjaro Distro.

Thanks!

IIRC Add the following to pacman.conf. And install llvm-svn.
[mesa-git]
Server = http://pkgbuild.com/~lcarlier/$repo/$arch
SigLevel = Never


I don't get why people use novel distros like that ...
Welcome to Linux. And no he only advises to use arch.

epigramx
02.03.2018, 07:09
I've been using linux for many years. The comment is mainly in reference to new users of it that seem to often go to very immature distros, when they could start first on something more established.

Main problem is I guess that they don't know often what is more established and go with what is (ephemerally) popular or what they are told to.


There's often also the misconception that linux has "very easy" and "very hard" distros only when most of the established ones are similarly easy to use anyway but at the same time ALL distros require from their users to become eventually power users in order to take full advantage of it anyway. So, one would ideally want the widest support of packaging from a well established distro community and shouldn't rely much on what is "easy to install at first" because that's a very small part of it.

Zacharybinx34
03.03.2018, 02:43
I've been using linux for many years. The comment is mainly in reference to new users of it that seem to often go to very immature distros, when they could start first on something more established.

Main problem is I guess that they don't know often what is more established and go with what is (ephemerally) popular or what they are told to.


There's often also the misconception that linux has "very easy" and "very hard" distros only when most of the established ones are similarly easy to use anyway but at the same time ALL distros require from their users to become eventually power users in order to take full advantage of it anyway. So, one would ideally want the widest support of packaging from a well established distro community and shouldn't rely much on what is "easy to install at first" because that's a very small part of it.

When running the command

LD_LIBRARY_PATH=/usr/local/lib ./configure --with-llvm-prefix=/usr/lib/llvm-7/ --with-gallium-drivers=radeonsi --with-dri-drivers=radeon,swrast --enable-texture-float --prefix=/home/Zach/mesa_mild --with-vulkan-drivers=radeon

I get the error:
configure: error: --enable-llvm selected but llvm-config is not found

Any ideas?

epigramx
03.03.2018, 05:49
When running the command

LD_LIBRARY_PATH=/usr/local/lib ./configure --with-llvm-prefix=/usr/lib/llvm-7/ --with-gallium-drivers=radeonsi --with-dri-drivers=radeon,swrast --enable-texture-float --prefix=/home/Zach/mesa_mild --with-vulkan-drivers=radeon

I get the error:
configure: error: --enable-llvm selected but llvm-config is not found

Any ideas?
Yes, that's simply that it doesn't find llvm at /usr/lib/llvm-7/ which is the location debian sid installs llvm 7 (if those packages are installed). If what Xalphenos suggested to you does work, it might be at another location.

By a quick look at a URL included in his post, it seems to be at /usr/lib (so you could replace to that at the ./configure line you posted here) but I can't be certain it's enough.


edit: If it resides in /usr/lib, it's probably that that arch set simply overrides the system llvm entirely. Kinda crude if you ask me but it might work without side-effects.

Zacharybinx34
03.03.2018, 06:43
Yes, that's simply that it doesn't find llvm at /usr/lib/llvm-7/ which is the location debian sid installs llvm 7 (if those packages are installed). If what Xalphenos suggested to you does work, it might be at another location.

By a quick look at a URL included in his post, it seems to be at /usr/lib (so you could replace to that at the ./configure line you posted here) but I can't be certain it's enough.


edit: If it resides in /usr/lib, it's probably that that arch set simply overrides the system llvm entirely. Kinda crude if you ask me but it might work without side-effects.


I am on Manjaro, and to be honest, I'm not sure what you're suggesting. Could you be a little more specific plz?

Thanks

epigramx
03.03.2018, 06:50
If you read the ./configure line you'll notice it includes a --with-llvm-prefix=/usr/lib/llvm-7 which points to llvm's installation location. Try to point it to /usr/lib instead in your case.

Read also what Xalphenos said to you in case you haven't (it will probably install latest llvm in /usr/lib).

Zacharybinx34
03.03.2018, 07:03
If you read the ./configure line you'll notice it includes a --with-llvm-prefix=/usr/lib/llvm-7 which points to llvm's installation location. Try to point it to /usr/lib instead in your case.

Read also what Xalphenos said to you in case you haven't (it will probably install latest llvm in /usr/lib).


Yep - I did that part.

I appreciate your patience and help here btw!

epigramx
03.03.2018, 07:37
Yep - I did that part.

I appreciate your patience and help here btw!
Closer inspection indicates it needs --with-llvm-prefix=/usr/ (without the lib). PS. There's a chance the LD_LIBRARY_PATH in front is unnecessary in this case and disrupts it (in which case it might work without a --with-llvm-prefix= at all without it).


update: Even closer inspection indicates that even with an LD_LIBRARY_PATH pointing to /usr/local/lib and no --with-llvm-prefix at all it should work fine on that system since it has an llvm-config in /usr/bin. On debian at least I can imitate that behavior by symlinking /usr/bin/llvm-config-7 to /usr/bin/llvm-config.

Gamedev1909
03.03.2018, 11:31
worked on antergos with a few extra files needed and fedora no gfx issues using llvm 5 as 7 wouldnt install device ran out of memory error

Zacharybinx34
04.03.2018, 03:24
At this point, while I really appreciate what you're going for here, it's just far to advanced for the average (or even above average) user to do. The guide needs to be far more specific for each step - especially being written for a far more uncommon distro like Debian.

Maybe if you worked through some more of the LLVM-7 step it might be more doable, but I'm asking some pretty advanced Linux users who honestly don't know themselves how to get through that step.

Just some feedback!
But thanks again for the attempted effort!

epigramx
04.03.2018, 05:03
thanks again for the attempted effort
As I said, I don't believe linux is for the common user (unless maybe it's Android); they will have to become power users eventually if they're going to survive. That step you are scared of is nothing hard, and I already explained it should work on your distro if you completely omit the llvm prefix line (I wonder if you read that reply fully).

Those "easy to use" distros are harder to use! They only are - and only even if they are done well at that - "easy" to install and they leave it at that. When a more mature distro has better package repositories, that makes it "easy", because it helps to not compile everything manually but even then it's not a panacea.

PS. Besides, debian is extremely easy to install already (and then it can stay stable or testing or upgraded to testing or sid).

Zacharybinx34
04.03.2018, 06:20
As I said, I don't believe linux is for the common user (unless maybe it's Android); they will have to become power users eventually if they're going to survive. That step you are scared of is nothing hard, and I already explained it should work on your distro if you completely omit the llvm prefix line (I wonder if you read that reply fully).

Those "easy to use" distros are harder to use! They only are - and only even if they are done well at that - "easy" to install and they leave it at that. When a more mature distro has better package repositories, that makes it "easy", because it helps to not compile everything manually but even then it's not a panacea.

PS. Besides, debian is extremely easy to install already (and then it can stay stable or testing or upgraded to testing or sid).

I did what you suggested.
Resulted in hearing sound and seeing some major graphical glitches. Not sure what else I can do.

epigramx
04.03.2018, 06:26
A lot can go wrong here and it depends on the specific hardware and kernel module used for it. Don't ask me for details on that because not even the mesa mild maintainer knows fully what GPU list is supported.

PS. That is assuming no mistakes were made at installation.


update: I know now he has almost identical GPU to mine so the software I run should run his hardware fine. He either didn't follow each step correctly or that distro has a severe issue with a software package but I doubt it's the latter.


update: For the record, a power user is not anything too extraordinary; no programming knowledge is needed for example. See the wikipedia page about it; it mainly refers to users clearly above the involvement of a common user.

Zacharybinx34
05.03.2018, 19:32
A lot can go wrong here and it depends on the specific hardware and kernel module used for it. Don't ask me for details on that because not even the mesa mild maintainer knows fully what GPU list is supported.

PS. That is assuming no mistakes were made at installation.


update: I know now he has almost identical GPU to mine so the software I run should run his hardware fine. He either didn't follow each step correctly or that distro has a severe issue with a software package but I doubt it's the latter.


update: For the record, a power user is not anything too extraordinary; no programming knowledge is needed for example. See the wikipedia page about it; it mainly refers to users clearly above the involvement of a common user.

I have spent hours talking to VERY Advanced Linux power users who have no idea whatsoever how to get LLVM 7 installed on any distro.

Could you please explain this part?

Xalphenos
05.03.2018, 22:05
how to get LLVM 7 installed on any distro.

Could you please explain this part?

It's been a few weeks but IIRC; After adding the lines to pacman.conf. I'm pretty sure all I did was "sudo pacman -S mesa-git" LLVM-svn was installed as a dependency. My goal at the time was not to install mesa mild though. I was just installing the latest mesa which was I think 18.0.3 at the time. That should work on any arch based distro. And I may have done -Syyu. I don't really remember.

epigramx
07.03.2018, 07:02
Since I've been the subject of personal attacks in relation to this guide - which were rather hypocritical since the same person copy pasted verbatim from this guide for the use of his videos and reddit comments while concealing that fact - I'd like to clarify something again, even though I did mention it in other words at the end of the guide:

This guide is not meant to teach you the basics of linux. It's meant to mainly show the caveats and quirks in relation to Cemu and mesa mild only. However, I do believe linux is mainly an OS for power users and it's a relatively easy installation for most of them. PS. Notice that a power user is not anything extraordinary.

epigramx
14.03.2018, 01:43
Note that the state of support in this area is relatively unknown and possibly fast-changing due to unpredictable upstream changes.

What we know from Xalphenos' testing is that Polaris cards might work on llvm7 but not for BotW and XCX properly.

PS. If you want to try your luck on Intel iGPUs, notice the main README of mesa mild.

Zacharybinx34
14.03.2018, 02:07
I can confirm that BOTW works with this on Vega, but most other games completely crash Linux with a hard lock up.

epigramx
14.03.2018, 02:48
On a R9 290 everything I tried works perfectly.

Zacharybinx34
14.03.2018, 02:56
On a R9 290 everything I tried works perfectly.

Right.
Vega is not R9 290 though.

epigramx
14.03.2018, 02:58
It's separate information; never said it is.

Luxed
07.04.2018, 23:22
On a R9 290 everything I tried works perfectly.

Unfortunately, it is not working on my RX 580, here is what I see (view from the shrine to the kakariko village):
325

I am running Arch Linux with the LLVM-svn repo and Mesa-git (latest version there is for both: llvm7 and mesa 18).

I did everything for the mesa mild, the comand is a little bit different as I compile with the llvm present on my computer (I just remove what you used for LLVM and add '--enable-llvm').
I can see that it works better than the mesa on my computer because it doesn't even give me an image.

Mario Kart 8 and Super Mario Bros U work really well ! (even though I haven't really tested them enough), actually they work better than on windows for me.

Specs:
CPU: i5 3570k @ 4.9ghz
GPU: AMD RX 580 (Saphirre Nitro +)
RAM: 16gb

Luxed
09.04.2018, 00:14
Yes, I built with the "--enable-texture-float" activated.
Here is the complete line:
334
And here is the link to the config's output: https://pastebin.com/LDP3PR0s
And the make output: https://pastebin.com/9eTjUQi1

Everything seems fine, I even get warned about the use of floating textures.
After a quick test with "glxinfo", I can grep the "texture_float" and see that it is present (in my mesa driver and mesa mild using the same command that you give to launch wine).

Since I am currently learning OpenGL, I have gone into my learning project and changed the internal texture format to GL_RGB32F and there it is, black textures. I will go and test this on Windows too to see how it goes, I will edit this post to let you know if it works there (which I suppose it should).

EDIT: Well no, it doesn't work on windows either :/

EDIT 2 ! :
After checking my code in Windows and trying to find if I didn't make an error I realized that I did (of course). After correcting that error, I can now safely say that floating textures work under windows and under Linux for me (if my testing is correct).

rawsh
10.04.2018, 00:23
When I compile mesa mild with the llvm-svn repo on arch I get the following:



See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make[5]: Leaving directory '/home/robert/Documents/Programs/mesa_mild_compatibility/src/egl'
make[4]: Leaving directory '/home/robert/Documents/Programs/mesa_mild_compatibility/src/egl'
make[3]: Leaving directory '/home/robert/Documents/Programs/mesa_mild_compatibility/src/egl'
Making install in amd/vulkan
make[3]: Entering directory '/home/robert/Documents/Programs/mesa_mild_compatibility/src/amd/vulkan'
make install-am
make[4]: Entering directory '/home/robert/Documents/Programs/mesa_mild_compatibility/src/amd/vulkan'
CC radv_nir_to_llvm.lo
radv_nir_to_llvm.c: In function ‘ac_llvm_finalize_module’:
radv_nir_to_llvm.c:2874:2: error: implicit declaration of function ‘LLVMAddPromoteMemoryToRegisterPass’; did you mean ‘LLVMAddDemoteMemoryToRegisterPass’? [-Werror=implicit-function-declaration]
LLVMAddPromoteMemoryToRegisterPass(passmgr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LLVMAddDemoteMemoryToRegisterPass
cc1: some warnings being treated as errors
make[4]: *** [Makefile:983: radv_nir_to_llvm.lo] Error 1
make[4]: Leaving directory '/home/robert/Documents/Programs/mesa_mild_compatibility/src/amd/vulkan'
make[3]: *** [Makefile:1135: install] Error 2
make[3]: Leaving directory '/home/robert/Documents/Programs/mesa_mild_compatibility/src/amd/vulkan'
make[2]: *** [Makefile:869: install-recursive] Error 1
make[2]: Leaving directory '/home/robert/Documents/Programs/mesa_mild_compatibility/src'
make[1]: *** [Makefile:1026: install] Error 2
make[1]: Leaving directory '/home/robert/Documents/Programs/mesa_mild_compatibility/src'
make: *** [Makefile:675: install-recursive] Error 1


Anyone else have this?

Xalphenos
10.04.2018, 02:03
Perhaps it's a new regression in llvm? I did not have that issue when I installed mesa mild with llvm-svn a while back.

Luxed
10.04.2018, 02:45
I don't know if it's a regression but I had the issue too. I fixed it by modifying the makefiles myself but I really don't think it's something that anyone should have to do. I wasn't able to find anything about this on the internet either.

rawsh
10.04.2018, 03:04
Perhaps it's a new regression in llvm? I did not have that issue when I installed mesa mild with llvm-svn a while back.

I fixed it by installing mesa-git, turns out I had llvm-svn but not mesa-git. Problem is vega 64 performance is fairly bad at 40fps ryzen 1800x, with 1060 I had in the hundreds. Are there any other improvements to make?

Luxed
10.04.2018, 04:32
I fixed it by installing mesa-git, turns out I had llvm-svn but not mesa-git. Problem is vega 64 performance is fairly bad at 40fps ryzen 1800x, with 1060 I had in the hundreds. Are there any other improvements to make?

Mesa-git installs llvm-svn as it is a requirement (I tried running mesa normal with llvm-svn and it didn't go too well as I had major glitches and a lot of opengl features missing).

Also, on a separate note, this is what happens if I am under water:
333

Xalphenos
10.04.2018, 04:36
If you use the shieka scope you character will be visible when he is semi transparent when exiting the scope.

Luxed
10.04.2018, 15:22
If you use the shieka scope you character will be visible when he is semi transparent when exiting the scope.

Yes, exactly. I still don't understand what is causing this issue :( Did I set something up wrong ?


What we know from Xalphenos' testing is that Polaris cards might work on llvm7 but not for BotW and XCX properly.

Am I trying something that simply doesn't work here ?
And just to add to my issues, I tried with llvm6 too. But it crashed when compiling shaders every time.