rt64 / rt64

RT64 is an N64 graphics renderer for playing with enhancements in emulators and native ports.
MIT License
918 stars 40 forks source link

Native Wayland Support #19

Open boomshroom opened 2 weeks ago

boomshroom commented 2 weeks ago

Attempting to run the current build of Zelda64Recomp under Wayland results in SDL creating a Wayland handle, and then RT64 misinterpreting it as an X11 handle before passing it into X11. This ultimately results in a segfault within X11 as it tries to operate on a foreign object.

This can be worked around by forcing SDL to use the X11 backend by setting the SDL_VIDEODRIVER environment variable to x11, which allows Zelda64Recomp to run.

DarioSamo commented 2 weeks ago

Hello, thanks for the detailed report!

Unfortunately, RT64 is not responsible for the window creation so it can't be fixed here. You should open this suggestion on https://github.com/Mr-Wiseguy/Zelda64Recomp.

boomshroom commented 2 weeks ago

My inspection of the code made it seem like the cause was RT64's HLE, specifically src/hle/application_window.cpp. Initially, the segfault was triggered by ApplicationWindow::detectRefreshRate calling XRRGetScreenResources, though bypassing that just manifested the same error elsewhere in the same file.

Zelda64Recomp would be able to implement the work-around by forcing SDL_VIDEODRIVER to x11 on Linux, but properly resolving the issue appears to be in the domain of RT64.

DarioSamo commented 2 weeks ago

Zelda64Recomp would be able to implement the work-around by forcing SDL_VIDEODRIVER to x11 on Linux, but properly resolving the issue appears to be in the domain of RT64.

It's still not in the domain of RT64 until Wayland support is implemented. If you wish to resolve this now, the one responsible for creating the window on X11 is Zelda64Recomp.

The few pieces of code in application_window.cpp responsible for Window creation are just for use on emulator plugins, which currently go unused when used by Recomp. In the case of Recomp, the one responsible for window creation is the application that uses RT64 as a library.

If you feel RT64 instead should handle Wayland support, I'm afraid that's out of my possibilities at the moment as Linux is not my primary platform and neither is a distro that uses Wayland. I'd rather leave that to people familiar with the platform as I'm unlikely to be able to solve it myself.