Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add an option to run native games that use OpenGL to run on Vulkan using Zink. #432

Closed
r-vd-woude opened this issue Mar 25, 2022 · 13 comments

Comments

@r-vd-woude
Copy link
Contributor

Thanks for the great work! Been using STL for quite a while now, and it is really helps a lot!

I've been testing some games that use OpenGL and running them on Vulkan using Zink. It works pretty well already.

Would it be an idea to add an option to export that environment variable in Steamtinkerlaunch? Would just be for ease of use.

@frostworx
Copy link
Collaborator

thx for the feedback!
Which variable(s) would that be exactly?
You know that you can already set any variable manually in either global.conf for all games or in the game specifig gameconfig per game, do you? (see here)
I currently take a break on working on steamtinkerlaunch (with open end), but if you like to create a PR it would be very welcome of course.

@r-vd-woude
Copy link
Contributor Author

r-vd-woude commented Mar 26, 2022

Sorry for my late reply.

Of course, if you want or need a break, enjoy it! You have given enough to the community :).

The environment variables are as follows:

__GLX_VENDOR_LIBRARY_NAME=mesa MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink

I will try to see if I can get it in there myself, so will create a PR then!

Edit: I suspect this will only be useful for people running with Mesa (so Intel and AMD gpu's).

@sonic2kk
Copy link
Owner

I think this would be a fantastic idea! However, I am far from an expert here but I wanted to ask: Are all of those environment variables necessary?

When I want to run games with Zink (verified that they are using Zink with MangoHUD and when beneficial, a noticeable performance boost), I typically only need to launch the game with MESA_LOADER_DRIVER_OVERRIDE=zink - In the case of Steam games, this would be MESA_LOADER_DRIVER_OVERRIDE=zink %command%. What are the other variables for out of curiosity?

And also, to @frostworx point, these could just be added as variables, but like with having a friendly UI for enabling Gamescope and GameMode I think this would be great for people that might not even know Zink is a thing! 😄

I think having an option for Zink would be great given how useful it is already and how fast it is maturing. If it is added, there should be some information given that it only applies to Intel/AMD and that it only works for OpenGL games. Maybe Zink could be a checkbox, and it would say something like "Use Zink (AMD/Intel)" and then a tooltip with some extra information on what Zink does and as such that it only works for OpenGL games.

@frostworx
Copy link
Collaborator

As you might have noticed, I decided to add (basic?) SteamDeck support, so I'm working on it anyway.
So, while I'm at it anyway, I'll also add zink support, if you have not started yet.
Would be good to know if @sonic2kk is right here with only one options is already enough.
Either way the option will be behind one boolean/checkbox, but I'd prefer not to override a variable, if it is not needed.

@frostworx
Copy link
Collaborator

frostworx commented Mar 29, 2022

Should be very easy to implement (I'd push it with the first testing Steam Deck support commit)
Do you have a suggestion for a good and useful tooltip?
Maybe something like "Enable Zink to renders OpenGL games in Vulkan (AMD/Intel only)"?

Edit: I'll also add a "Zink" steam category config

@frostworx
Copy link
Collaborator

I just pushed this commit, which should do what you want.
Would be nice if you reported nack if it works, and if the 3 variables are really all required.

@sonic2kk
Copy link
Owner

Thanks for the work! I'm interested in testing this out 😄

I'm having a few problems though, I can't enable MangoHUD when using SteamTinkerLaunch (it lists the driver being used). The option in the menus and the custom command don't seem to work for me. I can use MangoHUD normally even for the same game if I add mangohud %command% as the game's argument to Steam.

I'll keep working at it!

@sonic2kk
Copy link
Owner

sonic2kk commented Mar 29, 2022

I think I may have some problems with mangohud unrelated to STL, however I found something in my research: The extra commands seem to be for NVIDIA: https://forum.manjaro.org/t/how-do-i-force-a-program-to-use-zink/79190/5

There is also a post on GamingOnLinux that claims Zink works on Nvidia: https://www.gamingonlinux.com/2021/06/opengl-over-vulkan-driver-zink-gets-a-huge-performance-boost/

I don't have an Nvidia GPU so I can't test this claim, but I wanted to bring this up just in case :)


FWIW: On my 5700XT, running the command MESA_LOADER_DRIVER_OVERRIDE=zink glxinfo | grep OpenGL and __GLX_VENDOR_LIBRARY_NAME=mesa MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink glxinfo | grep OpenGL give the exact same output:

OpenGL vendor string: Collabora Ltd
OpenGL renderer string: zink (AMD RADV NAVI10)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 21.3.7
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6 (Compatibility Profile) Mesa 21.3.7
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 21.3.7
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

I suppose from here testing would need to be done on Nvidia, to see if the single command is sufficient. If it needs all the flags mentioned, that should be fine, as it does not seem to cause problems at least on AMD. I haven't tested on Intel but I don't see there being any major differences :)

EDIT: The Arch Wiki makes note that on Nvidia GPUs, Zink may not be as performant: https://wiki.archlinux.org/title/OpenGL#OpenGL_over_Vulkan_(Zink) - This was also mentioned in a GamingOnLinux comment from the linked post. I guess further testing on Nvidia would dictate how this could be conveyed to the user in the menu, if deemed necessary at all.

@sonic2kk
Copy link
Owner

I wasn't able to get MangoHUD to display Zink as the render engine for some reason, and I wasn't able to get MangoHUD to work with SteamTinkerLaunch (probably a separate issue as it seems to work with Vulkan games) but I went ahead and tested BioShock Infinite (a native Linux OpenGL game) anyway.

  • When testing with Zink disabled in SteamTinkerLaunch's menu, the game ran as expected.
  • When testing with Zink enabled in SteamTinkerLaunch's menu, there were some visual artifacts
  • When testing with Zink enabled as a launch option in Steam without SteamTinkerLaunch, the same visual atrifacts were present
    • I launched the game twice like this, once with MESA_LOADER_DRIVER_OVERRIDE=zink %command% and once with __GLX_VENDOR_LIBRARY_NAME=mesa MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink %command.

Given the behaviour is the same with Zink enabled in SteamTinkerLaunch and with a launch option set from Steam without STL, I am inclined to say that the Zink option is working. I would've liked more solid evidence that Zink is definitely being used, but this and also my above test with glxinfo, I think Zink is working here 😄

System Information:

  • OS: Arch Linux running KDE Plasma Wayland
  • GPU: AMD 5700XT 8GB
  • Driver: Mesa 22.0.1
  • Kernel: 5.17.1-arch1-1

@frostworx
Copy link
Collaborator

Thanks a lot for testing and investigation!
So as nvidia gpus require those variables and they don't have any negative impact on AMD (and likely Intel), it should be fine to use them all.

I'll leave this issue open as a reminder for me to remove the (AMD/Intel) note from the description and add your manjaro/arch urls into the wiki.

@r-vd-woude
Copy link
Contributor Author

r-vd-woude commented Mar 31, 2022

Sorry for not contributing, was gonna take a look this weekend (busy with other coding project). But I see it is already implemented, great stuff. Thanks!

EDIT: Just tested this with Stellaris (native OpenGL 2.1 game) No visual artifact or anything, performance was good, but game started to hang after a minute of so and crashed. No way related to Steamtinkerlaunch, just Zink being immature. But it works, thanks a lot!

@r-vd-woude
Copy link
Contributor Author

I wasn't able to get MangoHUD to display Zink as the render engine for some reason, and I wasn't able to get MangoHUD to work with SteamTinkerLaunch (probably a separate issue as it seems to work with Vulkan games) but I went ahead and tested BioShock Infinite (a native Linux OpenGL game) anyway.

* When testing with Zink disabled in SteamTinkerLaunch's menu, the game ran as expected.

* When testing with Zink enabled in SteamTinkerLaunch's menu, there were some visual artifacts

* When testing with Zink enabled as a launch option in Steam **without SteamTinkerLaunch**, the same visual atrifacts were present
  
  * I launched the game twice like this, once with  `MESA_LOADER_DRIVER_OVERRIDE=zink %command%` and once with `__GLX_VENDOR_LIBRARY_NAME=mesa MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink %command`.

Given the behaviour is the same with Zink enabled in SteamTinkerLaunch and with a launch option set from Steam without STL, I am inclined to say that the Zink option is working. I would've liked more solid evidence that Zink is definitely being used, but this and also my above test with glxinfo, I think Zink is working here smile

System Information:

* OS: Arch Linux running KDE Plasma Wayland

* GPU: AMD 5700XT 8GB

* Driver: Mesa 22.0.1

* Kernel: 5.17.1-arch1-1

You can see what libraries a process uses, you are using KDE, so if you start KSysGuard, right click a program you can find detailed memory information. Zink should be listed under shared libraries. Easy way to see if a program uses Zink.

@frostworx
Copy link
Collaborator

just removed the AMD/Intel notes in the language files
thx for testing again.
I guess zink_dri.so should also show up in lsof when it is used.

Regarding mangohud issues: iirc this was already once reported before:
This can't really be a steamtinkerlaunch issue though, because steamtinkerlaunch only offers the option to set the MANGOHUD variable, which is used by mangohud itself and not by steamtinkerlaunch. So if it works correctly when the mangohud command is used directly using mangohud %command%, but does not when enabling its own variable, I'd assume this is some mangohud-internal problem.

I'll close here anyway, as the original feature request is implemented. If you think this is a steamtinkerlaunch issue, feel free to open a separete issue (or reopen a possibly existing one, which got closed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants