Jump to content

Wayland support (Linux) and Vulkan renderer


Faalagorn

Recommended Posts

I haven't look very thoroughly whether or not it's possible to add those by manually replacing repsective files from LWJGL, but how hard would be adding support for Wayland on Linux and Vulkan renderer that are provided by LWJGL? I don't know what version of LWJGL PZ currently uses, but Wayland is there since LWJGL 3.1.4 (Nov 20, 2017)  and Vulkan since LWJGL 3.0.0 (Jun 3, 2016)? https://github.com/LWJGL/lwjgl3/releases

 

Both could help with performance on respective platforms (Vulkan is not supported on Mac officially, though they can use MoltenVK for potentially better performance especially as OpenGL is currently being phased out from Macs in favor of Metal) while Wayland could help on newer Linux distros as it's slowly gaining more and more mainstream attention.

Link to comment
Share on other sites

Probably impossible as the game currently stands -- it's still running on LWJGL 2 after it was discovered that there were a ton of OpenGL related errors trying to convert it over in the controller test build (it's also why we still have the alt+tab crash on select hardware/configs). In order to even diagnose those errors, rewriting part of the game's rendering code to utilize a scene graph is necessary. Why? I won't even pretend to understand it.  A useful tool for debugging OpenGL was also bought out and abandoned some years ago, so there's no good option aside from upgrading, anymore.

 

I've seen a few other open-source implementations of Vulkan and Metal for JWLGJ as well as the one linked, but I don't know how far they got with it. But, because most of those are based on LWJGL3, they can't easily be swapped into the game, anyway.

 

Personally, I think the real moral of the story is 'don't use OpenGL directly for your game project; use a api that supports multiple graphics apis from the beginning." But that's hindsight for you.

Link to comment
Share on other sites

2 minutes ago, EnigmaGrey said:

Probably impossible as the game currently stands -- it's still running on LWJGL 2 after it was discovered that there were a ton of OpenGL related errors trying to convert it over in the controller test build (it's also why we still have the alt+tab crash on select hardware/configs). In order to even diagnose those errors, rewriting part of the game's rendering code to utilize a scene graph is necessary.   Why? I won't even pretend to understand it.  A useful tool for debugging OpenGL was also bought out and abandoned, so fml.

 

I've seen a few other open-source implementations of Vulkan and Metal for JWLGJ as well as the one linked, but I don't know how far they got with it. But, because most of those are based on LWJGL3, they can't easily be swapped into the game, anyway.

Oh, so the controller test was running LWJGL3? Or were you trying to do it, but abandoned it quickly? I didn't have occasion to test it, as it was Windows only, but if it was, the wiki says the controller improvements are planned toward 42, is it still the case?

 

Anyway, it's fine if sticking to LWJGL2 is a technical barrier for now, maybe one day someone figures it out but in the meantime, it would require too much effort I guess with other pressing matters to solve before the game release. :)

Link to comment
Share on other sites

1 minute ago, Faalagorn said:

Oh, so the controller test was running LWJGL3? Or were you trying to do it, but abandoned it quickly? I didn't have occasion to test it, as it was Windows only, but if it was, the wiki says the controller improvements are planned toward 42, is it still the case?

 

Anyway, it's fine if sticking to LWJGL2 is a technical barrier for now, maybe one day someone figures it out but in the meantime, it would require too much effort I guess with other pressing matters to solve before the game release. :)

It should be running LJWLG 3, from what I remember. It was just prone to error and limited to Windows only, with no way to debug the OpenGL side.

Link to comment
Share on other sites

On 6/28/2020 at 4:22 PM, EnigmaGrey said:

It should be running LJWLG 3, from what I remember. It was just prone to error and limited to Windows only, with no way to debug the OpenGL side.

Out of curiosity, I tried the controllertest build for the first time on Linux – I'm not sure how the files are compared to Windows depot (I should have checked), but it works and upon adding         "-Dorg.lwjgl.glfw.libname=glfw_wayland" line, to the appopriate place in ProjectZomboid64.json, it didn't work, but due to the error:

 

ERROR: General, 1593934335478> [LWJGL] GLFW_PLATFORM_ERROR error
ERROR: General, 1593934335478> 	Description : Wayland: Setting window icon not supported
ERROR: General, 1593934335478> 	Stacktrace  :
ERROR: General, 1593934335478> 		ERROR: General, 1593934335479> org.lwjgl.glfw.GLFW.nglfwSetWindowIcon(GLFW.java:2036)
ERROR: General, 1593934335479> 		ERROR: General, 1593934335479> org.lwjgl.glfw.GLFW.glfwSetWindowIcon(GLFW.java:2068)
ERROR: General, 1593934335479> 		ERROR: General, 1593934335479> org.lwjglx.opengl.Display.create(Display.java:139)
ERROR: General, 1593934335479> 		ERROR: General, 1593934335479> org.lwjglx.opengl.Display.create(Display.java:92)
ERROR: General, 1593934335479> 		ERROR: General, 1593934335479> zombie.core.Core.init(Core.java:2244)
ERROR: General, 1593934335479> 		ERROR: General, 1593934335479> zombie.GameWindow.InitDisplay(GameWindow.java:386)
ERROR: General, 1593934335480> 		ERROR: General, 1593934335480> zombie.core.opengl.RenderThread.renderLoop(RenderThread.java:110)
ERROR: General, 1593934335480> 		ERROR: General, 1593934335480> zombie.gameStates.MainScreenState.main(MainScreenState.java:222)

While I don't know how to check whether it's running LWJGL 3 on Linux and Wayland doesn't work, it seems something that's potentially fixable and possible to get working?

Link to comment
Share on other sites

  • 3 years later...

Out of curiosity, I tried that again, adding the

"-Dorg.lwjgl.glfw.libname=libglfw_wayland.so",

line to the ProjectZomboid64.json under "vmArgs": [ line, so it looks like that now

	"vmArgs": [
		"-Dorg.lwjgl.glfw.libname=libglfw_wayland.so",
		"-Djava.awt.headless=true",
		"-Xmx3072m",
		"-Dzomboid.steam=1",
		"-Dzomboid.znetlog=1",
		"-Djava.library.path=linux64/:.",
		"-Djava.security.egd=file:/dev/./urandom",
		"-XX:+UseZGC",
		"-XX:-OmitStackTraceInFastThrow"
	]

The game doesn't start, as it throws me this error:

./ProjectZomboid64: symbol lookup error: /tmp/lwjglfaalagorn/3.2.3-build-13/libglfw_wayland.so: undefined symbol: __wrap_memcpy

 

Apparently, it's a bug with LWJGL, but it should be fixed in recent version? Unless PZ runs on the version that predates this fix, see http://forum.lwjgl.org/index.php?topic=7086.msg37031#msg37031

 

I can try compiling the missing module too, but I wonder if the engine version will be updated with the upcoming builds, so maybe the Wayland will work?

Link to comment
Share on other sites

If you download the latest version of lwjgl and it’s components, you can replace the game’s jars and dylibs with its contents. It at least works as a drop-in replacement on Windows.

 

I can’t say if that will work for yours, specific issue, but hopefully it’ll I’ll get you started.

Link to comment
Share on other sites

Just adding

-Dorg.lwjgl.glfw.libname=/usr/lib/libglfw.so

to the vm arguments in the json file works to override GLFW on Arch Linux. It works with both glfw-x11 and glfw-wayland from Arch's repos. I can also visually confirm it makes a Wayland window as the icon will be Wayland's instead of Spiffo. Naturally, using glfw-x11 will make it work as expected with the Spiffo icon. I haven't done more than load to the main menu but nothing seems to be off. The settings menu seemed to work just fine.

The GLFW version in Arch repos at current date is 3.3.9

Link to comment
Share on other sites

Okay, it works now, I was dumb, and I didn't have the Wayland version of GLFW installed on my system, I also had the wrong path; should be

"-Dorg.lwjgl.glfw.libname=/usr/lib/libglfw.so",

for those wondering :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...