flathub / org.yuzu_emu.yuzu

https://flathub.org/apps/details/org.yuzu_emu.yuzu
20 stars 43 forks source link

Game Crashes on Vulkan #309

Closed avocaderino closed 2 years ago

avocaderino commented 2 years ago

Pokemon Shield crashes when using certain moves(Waterfall) or performing certain actions(Dynamaxing) on Vulkan. OpenGL works fine but hogs too much memory for my low end system and crashes. Attaching log file and system specifications below.

yuzu_log.txt

System specifications:

liushuyu commented 2 years ago

Can you try the app image version and see whether the issue persists? https://github.com/yuzu-emu/yuzu-mainline/releases/download/mainline-0-906/yuzu-20220202-17d378353.AppImage

That way I would know where to forward your issue because it seems like this might be out of my control.

See the comment below.

FernandoS27 commented 2 years ago

Install the Vulkan SDK and run the game with graphics debugging on (on debug tab of Configurations). Then pass forward a log.

avocaderino commented 2 years ago

Could you point me to a tutorial on how to install it?

liushuyu commented 2 years ago

Could you point me to a tutorial on how to install it?

Just use the following command:

apt install llvm-12-dev vulkan-tools llvm-spirv spirv-cross spirv-tools
avocaderino commented 2 years ago

Here you go yuzu_log.txt

liushuyu commented 2 years ago

Here you go yuzu_log.txt

According to your log, /usr/lib/libSPIRV-Tools-opt.so is missing and the debug mode can't be enabled. It seems like Ubuntu/Pop_OS! made a packaging mistake and did not include this file in their software package.

Do you have other Linux distribution installed or this is the only one you have?

avocaderino commented 2 years ago

I don't have any other linux distribution installed

liushuyu commented 2 years ago

I don't have any other linux distribution installed

Hmm. In which case, I need to come up with a way to get those files for your system. Before that, you need to install mesa-vulkan-drivers additionally to support debugging in Mesa.

avocaderino commented 2 years ago

you need to install mesa-vulkan-drivers additionally to support debugging in Mesa.

It's already installed apparently.

liushuyu commented 2 years ago

you need to install mesa-vulkan-drivers additionally to support debugging in Mesa.

It's already installed apparently.

Sorry for the late reply. Please download the file spirv-tools-hirsute-shared.tar.gz and run the following commands:

pushd /usr/lib/x86_64-linux-gnu/
sudo tar xvf spirv-tools-hirsute-shared.tar.gz
popd

This will fill the previously missing files.


If you want to remove these files from your device after finishing debugging, run the following command:

sudo rm -v /usr/lib/x86_64-linux-gnu/libSPIRV-Tools.so /usr/lib/x86_64-linux-gnu/libSPIRV-Tools-{link,opt,reduce}.so
avocaderino commented 2 years ago

Tried running those commands, but when decompressing the files I get this error message:

$ pushd /usr/lib/x86_64-linux-gnu/
/usr/lib/x86_64-linux-gnu ~/Downloads

$ sudo tar xvf spirv-tools-hirsute-shared.tar.gz
tar: spirv-tools-hirsute-shared.tar.gz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

$ popd
~/Downloads

$ ls /usr/lib | grep SPIRV
libLLVMSPIRVLib.so.12

Edit: Mistake on my side, I was looking for the files in /usr/lib/, when I should have been looking in /usr/lib/x86_64-linux-gnu/. Note that file extensions are .a not .so

$ ls /usr/lib/x86_64-linux-gnu/ | grep SPIRV
libSPIRV-Tools.a
libSPIRV-Tools-link.a
libSPIRV-Tools-opt.a
libSPIRV-Tools-reduce.a
avocaderino commented 2 years ago

But these files were present on my system since yesterday.

$ stat /usr/lib/x86_64-linux-gnu/libSPIRV-Tools.a 
  File: /usr/lib/x86_64-linux-gnu/libSPIRV-Tools.a
  Size: 2479868     Blocks: 4848       IO Block: 4096   regular file
Device: 10303h/66307d   Inode: 7478835     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-02-03 16:58:10.000000000 +0530
Modify: 2021-07-21 12:45:48.000000000 +0530
Change: 2022-02-03 16:58:12.056426460 +0530
 Birth: 2022-02-03 16:58:12.044426484 +0530
liushuyu commented 2 years ago

But these files were present on my system since yesterday.

Sorry, I did not make the instructions clear enough.

pushd /usr/lib/x86_64-linux-gnu/
# Please replace the filename with the one you downloaded to your device
# e.g. ~/Downloads/spirv-tools-hirsute-shared.tar.gz
sudo tar xvf /path/to/spirv-tools-hirsute-shared.tar.gz
popd

So you need to replace /path/to/spirv-tools-hirsute-shared.tar.gz with the actual path that the file you downloaded on your device.

avocaderino commented 2 years ago

Done.

$ ls -a /usr/lib/x86_64-linux-gnu/ | grep SPIRV
libSPIRV-Tools.a
libSPIRV-Tools-link.a
libSPIRV-Tools-link.so
libSPIRV-Tools-opt.a
libSPIRV-Tools-opt.so
libSPIRV-Tools-reduce.a
libSPIRV-Tools-reduce.so
libSPIRV-Tools.so
avocaderino commented 2 years ago

Should I try debugging again?

avocaderino commented 2 years ago

I tried debugging again, but I again found this line in the log.

[  13.033206] Render.Vulkan <Critical> video_core/vulkan_common/vulkan_debug_callback.cpp:Callback:26: libSPIRV-Tools-opt.so: cannot open shared object file: No such file or directory
mluizvitor commented 2 years ago

I'm facing issues running on Vulkan. Before update 907 Pokémon Legends Arceus was runing all good. I tried downgrading Yuzu, but it didn't help. I followed the steps to get a good log, but spirv-cross is not present in my system repository, but installed the .tar.gz content.

yuzu_log.txt

System:    Host: eOSVitor Kernel: 5.13.0-28-generic x86_64 bits: 64 compiler: N/A 
           Desktop: Pantheon Distro: elementary OS 6.1 Jólnir 

Machine:   Type: Laptop System: LENOVO product: 81V7 v: Lenovo IdeaPad S145-15API 
           serial: <superuser/root required> 
           Mobo: LENOVO model: LNVNB161216 v: SDK0J40688WIN 
           serial: <superuser/root required> UEFI: LENOVO v: BUCN29WW date: 05/14/2021 

Battery:   ID-1: BAT0 charge: 11.2 Wh condition: 24.2/30.0 Wh (81%) model: LGC L16L2PB2 
           status: Charging 

CPU:       Topology: Quad Core model: AMD Ryzen 7 3700U with Radeon Vega Mobile Gfx 
           bits: 64 type: MT MCP arch: Zen+ rev: 1 L2 cache: 2048 KiB 
           flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm 
           bogomips: 36731 
           Speed: 1131 MHz min/max: 1400/2300 MHz Core speeds (MHz): 1: 1193 2: 1274 
           3: 1589 4: 1680 5: 1214 6: 1131 7: 1598 8: 1445 

Graphics:  Device-1: AMD Picasso vendor: Lenovo driver: amdgpu v: kernel bus ID: 03:00.0 
           Display: x11 server: X.Org 1.20.13 driver: amdgpu,ati 
           unloaded: fbdev,modesetting,vesa resolution: 1920x1080~60Hz 
           OpenGL: renderer: AMD Radeon Vega 10 Graphics (RAVEN DRM 3.41.0 
           5.13.0-28-generic LLVM 12.0.0) 
           v: 4.6 Mesa 21.0.3 direct render: Yes 

Network:   Device-1: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter 
           vendor: Lenovo driver: ath10k_pci v: kernel bus ID: 02:00.0 
           IF: wlp2s0 state: up mac: a4:63:a1:51:a6:74 
           Device-2: Qualcomm Atheros type: USB driver: btusb bus ID: 3-2:3 

Drives:    Local Storage: total: 476.95 GiB used: 150.81 GiB (31.6%) 

Info:      Processes: 317 Uptime: 1h 21m Memory: 5.67 GiB used: 1.99 GiB (35.1%) 
           Init: systemd runlevel: 5 Compilers: gcc: 9.3.0 Shell: zsh v: 5.8 inxi: 3.0.38
mluizvitor commented 2 years ago

The most recent AppImage build work flawlesly. But the Flatpak build does not recognizes Vulkan devices.

Flatpak build screenshot. Captura de tela de 2022-02-04 12-04-02

rmnscnce commented 2 years ago

After a short investigation, looks like the Freedesktop Mesa drivers are currently broken, since the Dolphin emulator Flatpak is also unable to initialize the Vulkan session: image

My host system details: Fedora Workstation 35 x86_64 GNOME 41.3 Wayland Host's vulkaninfo details

rmnscnce commented 2 years ago

Issue confirmed, Freedesktop Platform 21.08 Mesa drivers commit e9fde4c03364608fdad1f6bd5d794089e4c41e37e40ec496a49d15c290b682a6 is causing the issue.

Mitigation:

This issue is ultimately external to this package.

avocaderino commented 2 years ago

So I shouldn't upgrade?

$ flatpak update
Looking for updates…

        ID                                   Branch Op Remote  Download
 1.     org.freedesktop.Platform.GL.default  21.08  u  flathub < 131.2 MB
 2.     org.freedesktop.Platform.Locale      21.08  u  flathub < 325.8 MB (partial)
 3.     org.freedesktop.Platform.VAAPI.Intel 21.08  u  flathub  < 11.7 MB
 4.     org.freedesktop.Platform             21.08  u  flathub < 199.6 MB
 5.     org.yuzu_emu.yuzu.Locale             stable u  flathub  < 55.3 MB (partial)
 6.     org.yuzu_emu.yuzu                    stable u  flathub  < 87.8 MB

Proceed with these changes to the user installation? [Y/n]: n
liushuyu commented 2 years ago

So I shouldn't upgrade?

You should first upgrade and then run

sudo flatpak update --commit=86a1c8526bda603bdfadaaa0c3c76a1afcebf75ad1706c25fee3160765650a13 org.freedesktop.Platform.GL.default//21.08

To downgrade a certain component (Mesa driver).

avocaderino commented 2 years ago

The game still crashes.

yuzu_log.txt

rmnscnce commented 2 years ago

The game still crashes.

yuzu_log.txt

Oops, just found out that your problem has never been about the broken Freedesktop Platform Mesa drivers. I'm sorry for hijacking the ticket, then.

Also CC-ing @mluizvitor because the Freedesktop Platform Mesa drivers are indeed the cause of their problems (and it's not related to this ticket).

avocaderino commented 2 years ago

Could you point me to a tutorial on how to install it?

Just use the following command:

apt install llvm-12-dev vulkan-tools llvm-spirv spirv-cross spirv-tools

Wait, flatpak applications can't access system libraries right? I have yuzu installed as user.

liushuyu commented 2 years ago

Could you point me to a tutorial on how to install it?

Just use the following command:

apt install llvm-12-dev vulkan-tools llvm-spirv spirv-cross spirv-tools

Wait, flatpak applications can't access system libraries right? I have yuzu installed as user.

Indeed. No need to apologies though, we all make mistakes. Download the AppImage version and try again.

avocaderino commented 2 years ago

Here you go

yuzu_log.txt

liushuyu commented 2 years ago

Here you go

yuzu_log.txt

Seems like you need to install vulkan-validationlayers-dev libvulkan-dev via apt as well. Validation layers were not loaded in this run, but no other system related errors were spotted.

avocaderino commented 2 years ago

After installing the packages you mentioned, the appimage took a long time to load the shaders, and then crashed. Here is the log:

yuzu_log.zip

Github didn't allow me to upload the decompressed version so here's a compressed one.

Edit: Tried it again, the reason it crashed was because my system ran out of memory.

avocaderino commented 2 years ago

Is there any way I could temporarily increase my swap size by creating a swap file or something, since that might help?

liushuyu commented 2 years ago

After installing the packages you mentioned, the appimage took a long time to load the shaders, and then crashed. Here is the log:

yuzu_log.zip

Github didn't allow me to upload the decompressed version so here's a compressed one.

Edit: Tried it again, the reason it crashed was because my system ran out of memory.

Enabling validation will certainly increase memory usage. But your log surely started to contain some interesting information.

Is there any way I could temporarily increase my swap size by creating a swap file or something, since that might help?

It should work. You can either create a swap file or create a swap partition for this purpose.

If creating a swap file, you can follow this tutorial: https://linuxize.com/post/create-a-linux-swap-file/

avocaderino commented 2 years ago

Would creating the swap partition on an HDD be detrimental?

liushuyu commented 2 years ago

Would creating the swap partition on an HDD be detrimental?

It will obviously slow down your system, even on SSD. So this is the last resort.

avocaderino commented 2 years ago

So please correct me if there are any mistakes in what I'm about to do.

$ lsblk /dev/sda
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0 867.5G  0 part 
└─sda2   8:2    0    64G  0 part 
  1. I shrink /dev/sda1(which is empty anyway) and free around 16GiB(I use 4GiB currently) of space using GParted.
  2. I make a new partition /dev/sda3 of size 16GiB.
  3. I then run the following commands to temporarily mount /dev/sda3 as swap:
    $ sudo swapoff -a
    $ sudo swapon /dev/sda3
  4. I debug.
  5. I reboot the system, delete the /dev/sda3 partition and enlarge the /dev/sda1 partition to its original size.

PS: I use encrypted swap because Pop!_OS encrypts the swap partition by default during installation. Will this cause any problems?

liushuyu commented 2 years ago

So please correct me if there are any mistakes in what I'm about to do. ... PS: I use encrypted swap because Pop!_OS encrypts the swap partition by default during installation. Will this cause any problems?

Looks good to me.

avocaderino commented 2 years ago

Before doing that, I tried running the game after a reboot, and it worked! Sorry for not trying that out earlier. Here's the log, hope you find the things that you need in it.

yuzu_log.zip

liushuyu commented 2 years ago

Before doing that, I tried running the game after a reboot, and it worked! Sorry for not trying that out earlier. Here's the log, hope you find the things that you need in it.

yuzu_log.zip

Thank you! I will forward the log content to a GPU expert in the team.

avocaderino commented 2 years ago

Thank you too for putting up with me and my insecure edits so patiently!

Edit: lol

FernandoS27 commented 2 years ago

uhm here's the issue:

[ 192.194735] Debug <Critical> video_core/vulkan_common/vulkan_device.cpp:operator():674: Unreachable code!
Format=5 with usage=49153 and type=1 has no defined alternatives and host hardware does not support it

Do you have a save? I'de like to see if the propietary Windows driver supports this. If not I'll make an issue in ANV.

avocaderino commented 2 years ago

Here's the save:

main.zip

ColinKinloch commented 2 years ago

Downgrading org.freedesktop.Platform.GL.default//21.08 for the user installation fixed it for me.

This will do both system and user:

flatpak --user update --commit=86a1c8526bda603bdfadaaa0c3c76a1afcebf75ad1706c25fee3160765650a13 org.freedesktop.Platform.GL.default//21.08
sudo flatpak --system update --commit=86a1c8526bda603bdfadaaa0c3c76a1afcebf75ad1706c25fee3160765650a13 org.freedesktop.Platform.GL.default//21.08

then block updates for both with:

flatpak --user mask org.freedesktop.Platform.GL.default//21.08
sudo flatpak --system mask org.freedesktop.Platform.GL.default//21.08
avocaderino commented 2 years ago

Downgrading org.freedesktop.Platform.GL.default//21.08 for the user installation fixed it for me.

This will do both system and user:

flatpak --user update --commit=86a1c8526bda603bdfadaaa0c3c76a1afcebf75ad1706c25fee3160765650a13 org.freedesktop.Platform.GL.default//21.08
sudo flatpak --system update --commit=86a1c8526bda603bdfadaaa0c3c76a1afcebf75ad1706c25fee3160765650a13 org.freedesktop.Platform.GL.default//21.08

then block updates for both with:

flatpak --user mask org.freedesktop.Platform.GL.default//21.08
sudo flatpak --system mask org.freedesktop.Platform.GL.default//21.08

That is a different issue unrelated to this one, it has been mentioned before here too.

ColinKinloch commented 2 years ago

I understand. I was just elaborating on @liushuyu's solution to the other issue. It fixed my problem I was having, but failed on another machine where yuzu was installed under user.

avocaderino commented 2 years ago

I'de like to see if the propietary Windows driver supports this.

@FernandoS27 could you update the results here?

FernandoS27 commented 2 years ago

It tells me the save data is corrupted.

avocaderino commented 2 years ago

I tried downloading it and using the save file on the appimage, and it works as expected. Note that I compressed it using tar -czvf(gzip). Do you want me to compress it using p7zip as .rar?

avocaderino commented 2 years ago

I think I might have made some mistake trying to do it through the CLI, so here's one compressed using my file manager main.zip

FernandoS27 commented 2 years ago

It's not happening on Windows and after further look, it seems it's an ANV bug.

Go to their issue page and ask them implement this:

Support for format: B5G6R5_UNORM_PACK16

Features: VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT VK_FORMAT_FEATURE_TRANSFER_SRC_BIT VK_FORMAT_FEATURE_TRANSFER_DST_BIT

Windows Intel Driver supports it in every device, so they should be able to support it. Sadly there are no good alternatives for this format, so it's not easy for me to workaround it.

rmnscnce commented 2 years ago

ANV have had the support for it, but apparently it broke other features.

Here's a commit in Mesa @ Freedesktop.org GitLab that disabled support for the format: https://gitlab.freedesktop.org/mesa/mesa/-/commit/32d631dcd250bdfa0c8089921b50544988ee8f8b (which is related to this MR)

FernandoS27 commented 2 years ago

ANV have had the support for it, but apparently it broke other features.

Here's a commit in Mesa @ Freedesktop.org GitLab that disabled support for the format: https://gitlab.freedesktop.org/mesa/mesa/-/commit/32d631dcd250bdfa0c8089921b50544988ee8f8b (which is related to this MR)

I can't do much about it though. It's not an easy format to emulate. t also seems to be that they are activating all the features for every format, instead of limiting the features. It's likely that format has issues with blits which is not supported in Windows. The thing (from skimming the code) it seems that ANV only activates a format for transfer, sample and blits, instead of just some flags.