Open ghost opened 7 years ago
unfortunately its known issue that when using vulkan renderer, cdimage cache has to be enabled
Thats the first time I'm hearing about it, do you have any reference for this?
Also what OS are you using? The Vulkan driver works fine for me on Windows but I did encounter the same issue on Arch when using the Xorg backend, switching to an interface that supports Wayland made the issue disappear though, see https://github.com/libretro/beetle-psx-libretro/issues/219#issuecomment-326749226 and https://github.com/libretro/beetle-psx-libretro/issues/219#issuecomment-326796804
Yeah, there seems to be some severe memory corruption that happens when Vulkan is enabled. It might be a bug in the CD-ROM loading code, but it's hard to pinpoint, and I can only reproduce the issue with Xorg. I can't reproduce it with DRM/KMS, Wayland, and/or Windows.
So interestingly it seems to get further with the CD image cache disabled, however the error still happens. When the cache is enabled it does not make it passed the boot logo. As mentioned this only happens when RetroArch is using the Vulkan driver under X11.
@retro-wertz mentioned its a know issue, does that mean it occurs in other cores as well?
If so then this is probably either an issue in the libchdr dependency or in Retroarch (and considering it only occurs in X11 I'm leaning towards the latter).
@Zapeth known issue to PSX when using vulkan in Xorg. does not happen to windows though(i cant test coz my gpu not vulkan capable in windows) and other cores.
Although enabling cdimage when using vulkan does remedy the issue. not sure if the chd is able to support a similar feature.
Although enabling cdimage when using vulkan does remedy the issue. not sure if the chd is able to support a similar feature.
Ok, I wasn't aware that this isn't actually a CHD-specific issue as it also occurs for raw images when cdimage cache
is disabled.
As for why the option doesn't make a difference with CHD files - that setting isn't actually used at all in the implementation since chd file operations are done by the libchdr library which uses standard file functions instead of mednafens *Stream classes (which are normally used according to the setting).
If the image cache option doesn't make a difference with CHD files then how come it effects the result of this bug?
1) there isn't actually any difference for me with CHD files when changing the option (possibly because I don't skip BIOS loading?)
2) as I said, the option isn't used in the CHD implementation, however there can still be a difference in behavior since the option is used in general to decide whether the cd loading code should be executed in a single- or multithreaded way -> https://github.com/libretro/beetle-psx-libretro/blob/master/mednafen/cdrom/cdromif.cpp#L829-L831
Ah, okay. For reference I don't skip BIOS loading either.
As of 53c6d55a0507334409d02b8e0a346099d953c1bb Enabling the CD image cache completely works around this issue. The bug is still present with the cache disabled but at least CHD games can be played with Vulkan on X11 now.
Current mednafen_psx commit : 53c6d55
With the latest commit of mednafen_psx_hw and the support for cdimage_cache, there is no more chd_read_sector error when loading CHD using Vulkan drivers, but when the core is closed, retroarch also closes with this error:
[INFO] No content, starting dummy core.
[INFO] arg #0: retroarch
[INFO] arg #1: --menu
[INFO] arg #2: -s
[INFO] arg #3: /home/retro/EMULATORS/retroarch/saves
[INFO] arg #4: -S
[INFO] arg #5: /home/retro/EMULATORS/retroarch/states
[INFO] arg #6: -c
[INFO] arg #7: /home/retro/.config/retroarch/retroarch.cfg
[INFO] Saving RAM type #0 to "/home/retro/EMULATORS/retroarch/saves/Beetle PSX HW/Tales of Phantasia (Japan).srm".
[INFO] Saved successfully to "/home/retro/EMULATORS/retroarch/saves/Beetle PSX HW/Tales of Phantasia (Japan).srm".
[INFO] [PulseAudio]: Pausing.
[libretro INFO] [Beetle PSX HW]: Samples / Frame: 736.83255
[libretro INFO] [Thread 0x7fffd63c8700 (LWP 2327) exited]
[Beetle PSX HW]: Estimated FPS: 59.85078
[INFO] Saved core options file to "/home/retro/.config/retroarch/retroarch-core-options.cfg"
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
after 11030 requests (11030 known processed) with 0 events remaining.
[Thread 0x7fffe2431700 (LWP 2370) exited]
[Thread 0x7fffd7fff700 (LWP 2326) exited]
[Inferior 1 (process 1723) exited with code 01]
(gdb) bt full
No stack.
testing with Vulkan drivers + cue file + cdimage_cache and this exits fine when closing the core, its not closing retroarch unlike when using a chd file.
note: the chd file was created using chdman 0.189 from the same cue file.
@retro-wertz I made some quick debugging sessions it and it seems like closing the file descriptor in libchdr causes the XIO error, though there is no return error from the function, so perhaps something still tries to access the descriptor afterwards? (which would be weird, because there shouldn't be anything after that thats still linked to the chd object)
And considering the read_sector issue was resolved with actually caching the file, I'm guessing that this is also a problem somewhere in libchdr, maybe @rtissera can take a look at it?
Nice work with CHD support, unfortunately its known issue that when using vulkan renderer, cdimage cache has to be enabled. CHD does not support this option so we had bad sector issue:
https://hastebin.com/ceniqidoja.vbs