sp614x / optifine

1.77k stars 420 forks source link

Shaders do not work on Linux with Mesa #420

Open SuicSoft opened 7 years ago

SuicSoft commented 7 years ago

On Mesa (latest) the non-core OpenGL does not support GLSL versions higher than 1.3 (this is intentional).

I asked them on IRC about this and they say that if Minecraft wants a GLSL version higher than 1.3 it should request a for profile. So Optifine should request a core profile when shaders are used.

sp614x commented 7 years ago

How should the profile be requested? Source example for LWJGL? When can it be safely requested (for example OpenGL > 3.0)? What should be the fallback when the profile is not possible?

SuicSoft commented 7 years ago

@sp614x Maybe http://stackoverflow.com/questions/26807573/lwjgl-wont-give-me-an-opengl-context-that-supports-4-1. The fall back should be normal profile (that it currently uses)

sp614x commented 7 years ago

Not having a Linux or OSX machine to test with, this will be hard to test.

SuicSoft commented 7 years ago

@sp614x Send me the forge jar file. I can test it with Sildurs shaders (since they say they work on Linux)

GreyAsteroid commented 7 years ago

I would appreciate it greatly if Optifine requested the OpenGL core profile. Currently the Minecraft launcher goes blank when I override and set the non-core profile to 4.5. However Minecraft seems to run just fine and works with just about any shader I throw at it. It's been a pain having to globally override the non-core profile and then set specific games that have issues back to 3.0 just so I can have working shaders on Minecraft without the launcher breaking. If Optifine fixed this by requesting the OpenGL core profile it would save me a lot of headaches.

SuicSoft commented 7 years ago

@greyasteroid How did you get the shaders to work and are you using Linux. Also I use the new beta Minecraft launcher for Linux (download is on reddit)

GreyAsteroid commented 7 years ago

@SuicSoft export MESA_GL_VERSION_OVERRIDE=4.5 sets the non-core profile to 4.5, bypassing the need for Optifine to request the core profile. I am in fact using Linux. I've tried the new chromium based launcher and it's been giving me issues unfortunately.

SuicSoft commented 7 years ago

@GreyAsteroid I started the launcher with export MESA_GL_VERSION_OVERRIDE=4.5 and now the game goes to a black screen and crashes before the Mojang logo. I also tried export MESA_GL_VERSION_OVERRIDE=4.1 since my drivers only support OpenGL 4.1 but the game still crashes. I also tried the old launcher and it is the same. I had to run unset MESA_GL_VERSION_OVERRIDE to get the game running again.

Maybe requesting a core profile using a forge mod would work (which should be done by Optifine)

GreyAsteroid commented 7 years ago

@SuicSoft MESA_GL_VERSION_OVERRIDE is kind of a dirty hack, it's not surprising that it doesn't work well for you. Having Optifine request your core profile is a safer more reliable way of doing things.

dotModded commented 7 years ago

@SuicSoft I am working on a shader side fix with a library, this will allow all platforms and hardware to work on all platforms with all 450 features. It isn't a hack it is simply taking the driver into my own hands. Shaders will be run on the 120 profile (OGL2.1) it will be great, give the devs some time to flush out bugs

GreyAsteroid commented 7 years ago

Just wanted to report that overriding the default profile (the only workaround I can do to get 4.5 on minecraft) causes the optifine installer to show up blank, same as the java minecraft launcher. Really hoping Optifine requests the core profile in the future so I don't have to break so much to get shaders working.

SuicSoft commented 7 years ago

@GreyAsteioid If I run export MESA_GL_VERSION_OVERRIDE=4.5COMPAT Minecraft opens properly (using new launcher , haven't tested old one) and SFLP shaders work (and I get 50 FPS).But other shaders like Sildurs lite (I can run this at 25 FPS on Windows) don't work and display a black screen but I can see the FPS has decreased to around 30 which shows they are running.

SEUS shaders give an error and show a glitched screen (like normal) Also how did you run Minecraft of the launcher is blank ;)

kamild1996 commented 7 years ago

Ah, I was setting up a fresh installation of Linux today, I could have checked if I'm having the same issue on Mesa... If that helps, shaders are working fine on AMDGPU-PRO. Tested on Chocapic Shaders, Sildur's Shaders, KUDA and SFLP.

SuicSoft commented 7 years ago

@kamild1996 That's because you are using AMDGPU-PRO which is a closed source blob :P

kamild1996 commented 7 years ago

Oh, by the way, by saying "the latest version of Mesa" you meant the stable (1.3) or the development one (1.7)?

SuicSoft commented 7 years ago

@kamild1996 I mean the development one from padoka ppa

SuicSoft commented 7 years ago

@sp614x @dotModded any progress ?

I looked in the console for MrMeepz lite shaders and I see GPR limit exceeded which relates to https://bugs.freedesktop.org/show_bug.cgi?id=85596. If I increase the GPR limit to 128 I can run these shaders (will try the medium too)

Will try to see what Sildurs and SEUS shaders say in the console. Also if I make the GPR limit too high it will result in a GPU lockup.

Seil0 commented 7 years ago

@SuicSoft Dedelner's kuda shader is working with latest mesa 17.1 on openGL 3.0, working well as far as i noticed. I'm using Kernel 4.11.1 and mesa 17.1 (rx 480, radeonsi). 2017-05-25_11 12 11

embasoft commented 6 years ago

Any progress on this?

samis commented 6 years ago

Did a test run to see how many shaders emit errors. My local system runs Linux with an RX480 and Mesa 17.3. Test set:

To expose the most errors, I tested on very high settings.

There were various degrees of brokenness, but I'd say the majority or close to it had some form of error. This is with the default Mesa settings, I plan to do a 2nd test after tweaking them.

It should be noted that no errors were encountered under an AMDGPU-PRO test.

some-username-here1 commented 6 years ago

Apologies for replying to a months old issue, but how do you run Minecraft with export MESA_GL_VERSION_OVERRIDE=4.5COMPAT?

I'd like to be able to play Minecraft with KUDA shaders and haven't been able to figure it out by myself, unfortunately, and I currently have a Intel HD Graphics 4600 iGPU.

Seil0 commented 6 years ago

@some-username-here1 MESA_GL_VERSION_OVERRIDE=4.5COMPAT should work.

some-username-here1 commented 6 years ago

@Seil0 I don't mean that, I meant on how do you run Minecraft with that line of code?

Do you add it to JVM Arguments, into the lines in the shortcut properties, or something else? Apologies.

Seil0 commented 6 years ago

@some-username-here1 MESA_GL_VERSION_OVERRIDE=4.5COMPAT java -jar launcher.jar is the command to start the launcher via the terminal.

some-username-here1 commented 6 years ago

@Seil0 Thank you! Didn't know that that line had to be first before the java argument

some-username-here1 commented 6 years ago

If this is okay to post, but if anyone in the future sees this and wants to run OpenGL 4.5 in Minecraft via commands and with just a file for easy everyday use, create a document named Minecraft with OpenGL 4.5, or any other name you would like to call it, then copy and paste these into the document:

#!/bin/sh
MESA_GL_VERSION_OVERRIDE=4.5COMPAT java -jar "/usr/share/minecraft/minecraft.jar"

then Ctrl+S to save the document, you then go into the file's properties, go under Permissions, and make sure that Allow executing file as a program is selected.

Done! (Apologies if this isn't the best place to post this...)

stubkan commented 5 years ago

See my thread for a up-to-date workaround. The old workaround posted above does not work anymore as the launcher is set up differently.

https://www.opengl.org/discussion_boards/showthread.php/200945-OpenGL-issues-with-Mint?p=1292283#post1292283

Also, In my case I had to declare both values - Including MESA_GLSL_VERSION_OVERRIDE to actually use GLSL shaders. As even if I declared the basic OpenGL value as 4.5 it still left GLSL at 1.3, so I had to declare both.

Actually I'll just post the instructions here, to save you a click.

Assuming you downloaded the 'other' Linux launcher here - https://minecraft.net/en-us/download/alternative - which should work on any distribution and put it anywhere you like.

Add the variables to the minecraft-launcher.sh script as follows :

#!/bin/sh
cd "$(dirname "$(realpath $0)")"
MESA_GL_VERSION_OVERRIDE=4.5COMPAT MESA_GLSL_VERSION_OVERRIDE=450 exec ./launcher "$@"

Use this command to check your versions are working

MESA_GL_VERSION_OVERRIDE=4.5COMPAT MESA_GLSL_VERSION_OVERRIDE=450 glxinfo | grep version
some-username-here1 commented 5 years ago

@stubkan the old post I made above still does work, just from what I know, you're using Linux Mint 19 instead of 18.3 (or Ubuntu 18.04 instead of 16.04.x, if that's how it works)

so for it to be up-to-date, it would have to be, on Ubuntu 16.04.x/Linux Mint 18.x:

java -jar "/usr/share/minecraft/minecraft.jar" MESA_GL_VERSION_OVERRIDE=4.6COMPAT MESA_GLSL_VERSION_OVERRIDE=460

Now if the highest version of OpenGL that your GPU supports is different from the code above, feel free to change it, than save it as whatever you would like to name it and make sure to enable Allow executing file as program in it's properties.

For Ubuntu 18.04.x/Linux Mint 19.x, it would be:

MESA_GL_VERSION_OVERRIDE=4.6COMPAT MESA_GLSL_VERSION_OVERRIDE=460 java -jar "/usr/share/minecraft/minecraft.jar"

OR

MESA_GL_VERSION_OVERRIDE=4.6COMPAT MESA_GLSL_VERSION_OVERRIDE=460 minecraft

NOTE: "/usr/share/minecraft/minecraft.jar" can be replaced to be linked to wherever your minecraft.jar file is, making sure to not forget to double-quote your path, as this path would be the default path if you have this PPA installed

some-username-here1 commented 5 years ago

@sp614x would you mind if you can make the above post somewhere where Linux users are able to easily find it and/or have it be easier to read (if it isn't already)? thanks!

stubkan commented 5 years ago

@some-username-here1 - It does 'still work' if you use the unoffical PPA you linked, Mojang no longer supports it. - the last update was 113 weeks ago. I don't know if it will allow you to authenticate so you can play online?

See here - https://minecraft.net/en-us/download/alternative - There is no launcher jar file anymore. The launcher system now no longer uses it. Likewise, you can't just launch a game version .jar file as it fails to start properly without help from the launcher.

some-username-here1 commented 5 years ago

@stubkan what do you mean? that minecraft.jar I have isn't just a game version .jar, it's an old file where you would need Java to run it as a launcher (and the location of the .minecraft folder being in my User directory)

and it still does, so I'm kinda confused on what's going on here, also Minecraft was able to boot up normally, having no issues, online or offline, whatsoever. But I'm sure that the .jar I have is no longer available on the Download section, as I checked, for whatever reason, which is a shame.

stubkan commented 5 years ago

@some-username-here1 Yep, thats what I mean - You have it because you kept it - it's no longer available for new users to find and download.

Mojang no longer supports or produces that type of launcher so it could break anytime Mojang decides to change the launcher protocols, and new users would have to search to find the launcher jar... They might end up getting it from a malicious site that has a modified .jar that steals their username and password.

So it would be best to endorse a method that works with the current official launcher.

Alexmitter commented 5 years ago

Hey guys. I have the issue we are all talking about, most of the shaders result in a black screen with the classical "bit-wise operations are forbidden in GLSL 1.20 (GLSL 1.30 or GLSL ES 3.00 required)" in the logs. But non of your guys workarounds help, not with the old nor the new launcher. Here is a log of a not loading shader pack: https://pastebin.com/KJYXDvWz Here is my glxinfo: https://pastebin.com/702BGqWt

Is there any progress on the issue, any solution?

carriongoat commented 5 years ago

same issue, have never had luck getting continuum shaders and many others to run in linux. i have used the commands here, the game says that it's using the 4.5 compatibility profile, but no dice. using an rx 580 and an r5 1600, kubuntu 18.10, latest mesa builds from the oibaf ppa screenshot of what the game looks like with continuum: https://imgur.com/49HLcEs whole game log: https://pastebin.com/X1FvSWun glxinfo: https://pastebin.com/qprtt7fE ill give any other information needed and test stuff

miiichael commented 5 years ago

I'm hoping https://bugs.freedesktop.org/show_bug.cgi?id=110431 will improve the situation for Mesa users, by increasing the likelihood of GL_EXT_gpu_shader4 (which seems to currently be the main impediment for most Minecraft shaders) being available.

SergeyKasmy commented 5 years ago

@miiichael I'm running Mesa 19.1.1 on an RX 580 and that change did not impove the situation at all. At least not for Continuum shaders

stubkan commented 5 years ago

I can confirm if you use the latest mesa that shader support is good now. The support for GL_EXT_gpu_shader4 has been merged as of 2 months ago, so depending on your distribution it may not be up to the latest mesa with this recent change.

Try using a cutting edge repository as the stable mesa releases are often older releases. Search them for the latest version you can find - I got 19.0.2 off a cutting edge repository as the standard ones seemed to still be on version 18

OpenGL core profile version string: 4.5 (Core Profile) Mesa 19.0.2 OpenGL version string: 3.0 Mesa 19.0.2 OpenGL ES profile version string: OpenGL ES 3.2 Mesa 19.0.2

Secondly, from testing, it appears old shaders do NOT work, I suspect functions from years ago are not used anymore and will break support - however every single newly released shader I tested from up to a year ago works flawlessly.

JAicewizard commented 4 years ago

19.1.2-1 is not working neither is 19.2.0-devel (git-11aa32a447) later is AUR mesa-git.

tried contiuum 2.0.2 and SUES renewed 1.0.0

JAicewizard commented 4 years ago

For some reason the shaders are invalid, even though using opengl version 4.5 for the continuum shaders I updated all the versions in the shader files, this made this error go away, but it intruded a whole bunch of other errors and syntax issues.

dark-penguin commented 4 years ago

I have found that Sildur's shaders (all of them, and only them) work on Linux with radeon. Disable "Sky and lighting" - "Sky blur" to get rid of "shining" edges ("Cloudsblur=false" in the config).

However, they are slower than on Windows, and slower than on AMDGPU-PRO (which is also slower than on Windows).

Also, apparently there is a bug I could reproduce only on Radeon RX550: if you set the draw distance to anything larger than 6 and wait for enough things to load (at 7 you would have to spin around a little), suddenly you get a massive FPS drop (from "playable" to "slideshow"), which is too sudden to be explained with a distance increase from 6 to 7. This happens even on "Enhanced Default"! So you can watch a pretty high FPS drop to very low, which can not be explained on "Enhanced Default".

stubkan commented 4 years ago

Support is much better now - ALL shaders work for me. You have to make sure your mesa drivers are up to date (or cutting edge)


From: dark-penguin notifications@github.com Sent: Saturday, 16 May 2020 10:03 PM To: sp614x/optifine optifine@noreply.github.com Cc: stubkan subnormalx@hotmail.com; Mention mention@noreply.github.com Subject: Re: [sp614x/optifine] Shaders do not work on Linux with Mesa (#420)

I have found that Sildur's shaders (all of them, and only them) work on Linux with radeon. Disable "Sky and lighting" - "Sky blur" to get rid of "shining" edges ("Cloudsblur=false" in the config).

However, they are slower than on Windows, and slower than on AMDGPU-PRO (which is also slower than on Windows).

Also, apparently there is a bug I could reproduce only on Radeon RX550: if you set the draw distance to anything larger than 6 and wait for enough things to load (at 7 you would have to spin around a little), suddenly you get a drop to 1-2 FPS. It is too sudden to be explained with a distance increase from 6 to 7.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/sp614x/optifine/issues/420#issuecomment-629635134, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIGFB6GIEWUIDXFZL5KUNMDRRZ6ITANCNFSM4C4OHUPA.

aduskett commented 4 years ago

Shaders still not working for me on a Radeon 560x with Fedora 32 using 4.6 compatibility mode. Tons of "Invalid program" errors.

dark-penguin commented 4 years ago

"All" shaders don't work for me (with radeon driver) on Ubuntu Focal (with R9 290), but I did not add "cutting edge" Mesa PPA - apparently, that would help. However, Sildur's shaders work even on Debian Buster (with RX 550, radeon driver) - all of them, even the "volumetric lighting" ones.

miiichael commented 4 years ago

You will probably want to try the amdgpu driver, not radeon. Generally speaking, the newer the kernel (preferably version 5.something) and mesa (at least 19.1), the better. Though I think Ubuntu 20.04 definitely has that aspect covered...

Users of GCN1 (HD7x00 series) and GCN2 (Rx 2xx) cards might need to set some kernel parameters, and/or blacklist the radeon module to coax the kernel into using the newer driver. For kernels before 5.6, you might need to fiddle with fan control too, if the fans don't spool up until it hits 96°C.

dark-penguin commented 4 years ago

Ubuntu 20.04 has Mesa 20.0.4 (funny numeric coincidence!).

With AMDGPU, shaders work correctly even on 18.04 (but for some reason the game runs still slower than on Windows, which was a surprise to me). But AMDGPU is something most people want to avoid - yes, you would need to do things to make it work, and hope you won't have to sacrifice too much (and usually you will - like with most non-free software).

miiichael commented 4 years ago

But AMDGPU isn't non-free? Are you getting confused with AMDGPU-Pro, which is a proprietary component that sits on top of AMDGPU?

dark-penguin commented 4 years ago

Oh, yes, I meant that. "Driver" becomes confusing when there is a kernel driver and an OpenGL driver. :) Of course I'm using AMDGPU with a kernel parameter for my GCN2 card.

williambl commented 4 years ago

Yeah, I can confirm that with newer versions of AMDGPU and mesa, this is no longer an issue (for me at least).

dark-penguin commented 4 years ago

"Newer" versions meaning which exactly? Apparently, from the oibaf PPA?

williambl commented 4 years ago

dpkg -l tells me that libdrm-amdgpu is version 2.4.99-1ubuntu1~18.04.2, xserver-xorg-video-amdgpu is version 18.0.1-1, and most of the mesa packages are 19.2.8-0ubuntu0~18.04.3.

I'm not using any PPAs that serve graphics-related packages (I used to use one of them a year or so ago (in an attempt to solve this issue (it didn't work))), and I'm on kubuntu 18.04.