xemu-project / xemu

Original Xbox Emulator for Windows, macOS, and Linux (Active Development)
https://xemu.app
Other
2.85k stars 283 forks source link

Several games hang and crash desktop environment on linux #1656

Open Delta62Arcus opened 6 months ago

Delta62Arcus commented 6 months ago

Bug Description

Several games cause the emulator to crash, and when the emulator crashes, my desktop environment goes black, and then crashes, sending me back to my login manager.

"Outrun 2", "Brute Force", and "Magatama" all crash before the main menu is reached.

"Indycar Series 2005" reaches the main menu, but starting a quick race causes the same issue.

Reattaching to my tmux session and viewing the log shows the following output:

xemu-v0.7.122-x86_64.AppImage: ../hw/xbox/nv2a/pgraph.c:5018: pgraph_gl_fence: Assertion `result == GL_CONDITION_SATISFIED || result == GL_ALREADY_SIGNALED' failed.

zsh: IOT instruction (core dumped)  ./xemu-v0.7.122-x86_64.AppImage

Expected Behavior

Game should not crash.

Desktop environment should not crash.

xemu Version

0.7.122

System Information

CPU: Intel(R) Xeon(R) W-2135 CPU @ 3.70GHz OS Platform: Linux OS Version: Arch Linux Manufacturer: AMD GPU Model: AMD Radeon RX 580 2048SP (radeonsi, polaris10, LLVM 17.0.6, DRM 3.57, 6.9.2-zen1-1-zen) Driver: 4.6 (Core Profile) Mesa 24.1.0-arch1.1 Shader: 4.60

Additional Context

No response

mrcmunir commented 5 months ago

Seems it's related AMD linux driver. With panzer dragon orta has crash. amdgpu_cs_query_fence_status failed. xemu: ../hw/xbox/nv2a/pgraph.c:5018: pgraph_gl_fence: declaratión `result == GL_CONDITION_SATISFIED || result == GL_ALREADY_SIGNALED' return is not fulfilled

LBY-L commented 5 months ago

I have the same problem it seems to be the drivers but idk, i just tested in flatpak and AUR packages and both crashes and get so weird lines into my screen, when appear just log me out and when log me out again they seem persistent or maybe the RX 580 (2048sp) have to do something, i have the same problem with other gpu-virtualized applications like Waydroid but it seem different.

IguanaMeow commented 5 months ago

Posting this to help others not using Discord

I have 2 systems where I tested this exact issue. My specs are AMD Ryzen 2600, RX570, and 32gb of ram running Artix (Arch) on X11 and another system Ryzen 2500u Vega 8 and 16gb ram running Devuan (Debian) also with x11. Both of these systems experience the same result with the system freezing up, gpu going to full blast, crashing, screen artifacts and glitches, and getting thrown back to the login if I'm lucky.

Digging deeper, it indeed seems to be a problem with mesa's amdgpu driver (specifically some implementations of OpenGL). For testing purposes I redirected the crash log to the desktop in this way:

./xemu.AppImage &>> ~/Desktop/bug.txt

Ended up with this error when running the AppImage and the same when compiling from Git (ignore the date/version numbers it doesn't matter for this issue):

xemu_version: 0.7.118
xemu_branch: master
xemu_commit: 03f40b1d8e873b57eab68dc66ae9892aa5e39f89
xemu_date: Mon Dec 18 06:07:22 UTC 2023
xemu_settings_get_base_path: base path: /home/iguana/.local/share/xemu/xemu/
xemu_settings_get_path: config path: /home/iguana/.local/share/xemu/xemu/xemu.toml
CPU: AMD Ryzen 5 2600 Six-Core Processor            
OS_Version: Artix Linux
GL_VENDOR: AMD
GL_RENDERER: AMD Radeon RX 570 Series (radeonsi, polaris10, LLVM 16.0.6, DRM 3.57, 6.7.5-1-cachyos-bore)
GL_VERSION: 4.6 (Core Profile) Mesa 24.0.1-arch1.1
GL_SHADING_LANGUAGE_VERSION: 4.60
amdgpu: amdgpu_cs_query_fence_status failed.
amdgpu: The CS has been rejected (-125).

When I ran with with zink (OpenGL to Vulkan translation layer):

xemu_version: 0.7.118
xemu_branch: master
xemu_commit: 03f40b1d8e873b57eab68dc66ae9892aa5e39f89
xemu_date: Mon Dec 18 06:07:22 UTC 2023
xemu_settings_get_base_path: base path: /home/iguana/.local/share/xemu/xemu/
xemu_settings_get_path: config path: /home/iguana/.local/share/xemu/xemu/xemu.toml
DRI3 not available
failed to load driver: zink
DRI3 not available
failed to load driver: zink
DRI3 not available
failed to load driver: zink
DRI3 not available
failed to load driver: zink
DRI3 not available
failed to load driver: zink
DRI3 not available
failed to load driver: zink
Failed to create main window

I do have one more log but I'm not sure how exactly I triggered this one:

xemu_version: 0.7.118
xemu_branch: master
xemu_commit: 03f40b1d8e873b57eab68dc66ae9892aa5e39f89
xemu_date: Mon Dec 18 06:07:22 UTC 2023
xemu_settings_get_base_path: base path: /home/iguana/.local/share/xemu/xemu/
xemu_settings_get_path: config path: /home/iguana/.local/share/xemu/xemu/xemu.toml
CPU: AMD Ryzen 5 2600 Six-Core Processor            
OS_Version: Artix Linux
GL_VENDOR: AMD
GL_RENDERER: AMD Radeon RX 570 Series (radeonsi, polaris10, LLVM 16.0.6, DRM 3.57, 6.7.5-1-cachyos-bore)
GL_VERSION: 4.6 (Core Profile) Mesa 24.0.1-arch1.1
GL_SHADING_LANGUAGE_VERSION: 4.60
XEMU-x86_64.AppImage: ../hw/xbox/nv2a/pgraph.c:5018: pgraph_gl_fence: Assertion `result == GL_CONDITION_SATISFIED || result == GL_ALREADY_SIGNALED' failed.

The last mesa version where it worked on Arch for me at least was on 23.3.5-1, but its not possible to go back to that version without downgrading a whole bunch of other core system dependencies.. I concluded that xemu works with some older versions of mesa and error out like the logs above in the current/other versions.

So what is the solution?

To put it simply don't use amdgpu and instead switch to modesetting and use zink.

For this to work you'll need to remove the amdgpu driver (example with Arch):

pacman -R xf86-video-amdgpu

By removing the amdgpu driver you will be using the Linux kernel provided modesetting driver automatically. Now your AMD gpu will have access to DRI3 and zink. All other amdgpu configurations such as radeon si/cik can be left alone because the modesetting driver translates and uses them the same way the amdgpu driver does.

To check that you are using the modesetting driver execute: inxi -G and look for the currently loaded driver.

Afterwards, launch xemu with zink as so:

env __GLX_VENDOR_LIBRARY_NAME=mesa MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink ./xemu.AppImage

References:

https://www.supergoodcode.com/preemptive/ https://www.reddit.com/r/linux_gaming/comments/1bic54p/amdgpu_dri3zink_dont_work_on_my_igpu/

LBY-L commented 5 months ago

In my case this is the log:

xemu_version: 0.7.127
xemu_branch: master
xemu_commit: b4ce2b58d09baa6dfd17c0bcab2e505df9f310e4
xemu_date: Sun Jun 16 00:18:00 UTC 2024
xemu_settings_get_base_path: base path: /home/lbyl/.local/share/xemu/xemu/
xemu_settings_get_path: config path: /home/lbyl/.local/share/xemu/xemu/xemu.toml
CPU: AMD Ryzen 5 5600G with Radeon Graphics         
OS_Version: Arch Linux
GL_VENDOR: AMD
GL_RENDERER: AMD Radeon RX 580 2048SP (radeonsi, polaris10, LLVM 17.0.6, DRM 3.57, 6.9.6-zen1-1-zen)
GL_VERSION: 4.6 (Core Profile) Mesa 24.1.2-arch1.1
GL_SHADING_LANGUAGE_VERSION: 4.60
Created QEMU launch parameters: ./xemu-v0.7.127-x86_64.AppImage -machine xbox,bootrom=/home/lbyl/Documentos/XEMU/BIOS/mcpx_1.0.bin,kernel-irqchip=off,avpack=hdtv -device smbus-storage,file=/home/lbyl/.local/share/xemu/xemu/eeprom.bin -bios /home/lbyl/Documentos/XEMU/BIOS/Complex_4627.bin -m 64 -drive index=0,media=disk,file=/home/lbyl/Descargas/xbox_hdd.qcow2,locked=on -drive index=1,media=cdrom,file=/home/lbyl/Descargas/GAMES.xiso.iso -display xemu -device usb-hub,port=1,ports=4 
xemu_version: 0.7.127
xemu_branch: master
xemu_commit: b4ce2b58d09baa6dfd17c0bcab2e505df9f310e4
xemu_date: Sun Jun 16 00:18:00 UTC 2024
xemu_settings_get_base_path: base path: /home/lbyl/.local/share/xemu/xemu/
xemu_settings_get_path: config path: /home/lbyl/.local/share/xemu/xemu/xemu.toml
CPU: AMD Ryzen 5 5600G with Radeon Graphics         
OS_Version: Arch Linux
GL_VENDOR: AMD
GL_RENDERER: AMD Radeon RX 580 2048SP (radeonsi, polaris10, LLVM 17.0.6, DRM 3.57, 6.9.6-zen1-1-zen)
GL_VERSION: 4.6 (Core Profile) Mesa 24.1.2-arch1.1
GL_SHADING_LANGUAGE_VERSION: 4.60
amdgpu: The CS has cancelled because the context is lost. This context is innocent.

Previusly i tested the Flatpak version with no graphics acceleration, that was a little glitchy but i managed to play

I put the flags that @IguanaMeow used but i get this:

xemu_version: 0.7.127
xemu_branch: master
xemu_commit: b4ce2b58d09baa6dfd17c0bcab2e505df9f310e4
xemu_date: Sun Jun 16 00:18:00 UTC 2024
xemu_settings_get_base_path: base path: /home/lbyl/.local/share/xemu/xemu/
xemu_settings_get_path: config path: /home/lbyl/.local/share/xemu/xemu/xemu.toml
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
Failed to create main window

And Xemu even don't show up

LBY-L commented 5 months ago

NOTE: I used it in wayland and xorg but the error is the exactly same

LBY-L commented 5 months ago

IDK but i installed fedora and magicly i get it, i saw in the discord this flag, and worked for me: ZINK_DESCRIPTORS=lazy __GLX_VENDOR_LIBRARY_NAME=mesa MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink

LBY-L commented 5 months ago

It works for both of the flags but i noticed a little bit of extra performance in the @IguanaMeow flag, thanks Fedora now i can play whaterver i want 🫠

IguanaMeow commented 4 months ago

Updated my Artix system a week ago and now I'm getting this same crash that @LBY-L had when trying to run xemu. The scenario for the issue remains the same. Use amdgpu as the driver and the whole system freezes, graphics glitches, logout and even crashes. If you remove amdgpu and use modesetting instead then you will get results like these:

My log when using the modesetting driver running xemu with zink (xemu crashes/doesn't start)

xemu_version: 0.7.120
xemu_branch: master
xemu_commit: 94d826a4f125d755d6d37069ad7084bfde33d650
xemu_date: Sat Mar 23 21:01:10 UTC 2024
xemu_settings_get_base_path: base path: /home/iguana/.local/share/xemu/xemu/
xemu_settings_get_path: config path: /home/iguana/.local/share/xemu/xemu/xemu.toml
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
glx: failed to create drisw screen
failed to load driver: zink
Failed to create main window

Without zink (system freezes and logs out user)

xemu_version: 0.7.120
xemu_branch: master
xemu_commit: 94d826a4f125d755d6d37069ad7084bfde33d650
xemu_date: Sat Mar 23 21:01:10 UTC 2024
xemu_settings_get_base_path: base path: /home/iguana/.local/share/xemu/xemu/
xemu_settings_get_path: config path: /home/iguana/.local/share/xemu/xemu/xemu.toml
CPU: AMD Ryzen 5 2600 Six-Core Processor            
OS_Version: Artix Linux
GL_VENDOR: AMD
GL_RENDERER: AMD Radeon RX 570 Series (radeonsi, polaris10, LLVM 18.1.8, DRM 3.57, 6.9.9-1-cachyos-bore)
GL_VERSION: 4.6 (Core Profile) Mesa 24.1.3-arch1.1
GL_SHADING_LANGUAGE_VERSION: 4.60
xemu-v0.7.120-x86_64.AppImage: ../hw/xbox/nv2a/pgraph.c:5018: pgraph_gl_fence: Assertion `result == GL_CONDITION_SATISFIED || result == GL_ALREADY_SIGNALED' failed.
mrcmunir commented 4 months ago

One bad commit from amd mesa3d driver it's https://gitlab.freedesktop.org/mesa/mesa/-/commit/e2b817b948a3ad15f163135459b388aaef4eeec3

IguanaMeow commented 3 months ago

Wanted to post a workaround I found in getting zink with OpenGL along with the Vulkan test build from Github Actions working/again for Arch based distros.

This relates to my previous post as the situation remains the same. Anyway the workaround that works for me is to run xemu with zink + mangohud. I'm unsure why this works but i suspect that mangohud somehow passes the OpenGL API from zink to xemu. I've tried running xemu with just mangohud but then my system freezes and logs me out again..

The command I use to get it running for OpenGL:

env __GLX_VENDOR_LIBRARY_NAME=mesa MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink mangohud ./xemu.AppImage

In regards to the Vulkan build, If I simply run xemu my system freezes and logs me out yet again. BUT when I run xemu with mangohud it launches (both modesetting and amdgpu driver):

mangohud ./xemu.AppImage

You'll need to add this to your xemu.toml to use Vulkan:

[display]
renderer = 'VULKAN'

Lastly I want to touch upon other distros such as Ubuntu, etc... I have another system running Debian unstable (latest software) that I use from time to time where I experience the same behavior. I've noticed.. or maybe I should say I haven't found a way to switch to the modesetting driver so OpenGL with xemu is broken and zink doesn't load due to missing DRI3 support in the amdgpu driver.. Surprisingly with the Vulkan build on the amgdpu driver I do not need to run mangohud to get xemu running like with Arch. Just simply need to set Vulkan as the renderer in xemu.toml and run xemu as is.

barf commented 1 month ago

I think there's a related crash in the XMB I have reported as #1778 however none of these workarounds have helped on Ubuntu with the official AMD driver, because zink is not provided here (other games like X-Plane are bundling their own zink AFAIK). MESA-LOADER: failed to open zink: /opt/amdgpu/lib/x86_64-linux-gnu/dri/zink_dri.so: cannot open shared object file: No such file or directory (search paths /opt/amdgpu/lib/x86_64-linux-gnu/dri, suffix _dri) failed to load driver: zink

dekay commented 1 month ago

@IguanaMeow @barf I was having GPU resets with both X and Wayland on Arch when trying to run xemu with my AMD 560 GPU and mesa's amdgpu driver that resulted in problems like those described in this bug. So I filed a bug with mesa.

I did a pacman -Syu the other day and that pulled in Mesa 24.2.3-1. xemu now runs fine without the zink workaround I was having to use before. Try mesa 24.2 and see if that fixes the problems you are seeing.

Link4Electronics commented 2 weeks ago

I'm on Arch linux, mesa 24.2.6 with an AMD gpu and still has this issue. Using the Vulkan branch with vulkan render is fine though, OpenGL crashes.