libretro / picodrive

Fast MegaDrive/MegaCD/32X emulator
Other
43 stars 64 forks source link

Music & SFX glitching out in Blackthorne #196

Closed DukeSkinny closed 1 year ago

DukeSkinny commented 2 years ago

Occasionally, when blowing up field generators, all SFX and what sounds like most channels of music stop playing until reset. This is with DAC noise and low-pass filter ON, sample rate at 44100 and dynarec OFF.

irixxxx commented 2 years ago

One of the SH2s is crashing due to a stack overwrite. I was asking myself if this might not even happen on the real hardware, albeit probably much more rarely since it doesn't have the scheduling artifacts. Try using the drc, it has a hack for this.

irixxxx commented 2 years ago

@DukeSkinny have you retried this with drc enabled?

DukeSkinny commented 2 years ago

Sorry about not getting back to you.

Well, I didn't manage to reproduce the glitch with drc enabled. Good news, except that the game crashes instead. That is to say, in the same situation with the same frequency of occurrence. The log doesn't seem very helpful, but I'll drop it in just in case:

[INFO] RetroArch 1.10.0 (Git 5f6fc20) [INFO] === Build ======================================= [INFO] CPU Model Name: AMD Ryzen 9 5950X 16-Core Processor
[INFO] Capabilities: MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4 SSE4.2 AES AVX AVX2 [INFO] Built: Jan 21 2022 [INFO] Version: 1.10.0 [INFO] Git: 5f6fc20 [INFO] ================================================= [INFO] [Input]: Found input driver: "raw". [INFO] [Core]: Loading dynamic libretro core from: "cores\picodrive_libretro.dll" [INFO] [Overrides]: Core-specific overrides found at "F:\Emulatorer\RetroArch Data\config\PicoDrive\PicoDrive.cfg". [INFO] [Overrides]: No content-dir-specific overrides found at "F:\Emulatorer\RetroArch Data\config\PicoDrive\Sega 32X.cfg". [INFO] [Overrides]: No game-specific overrides found at "F:\Emulatorer\RetroArch Data\config\PicoDrive\Blackthorne (USA).cfg". [INFO] [Config]: Appending config "F:\Emulatorer\RetroArch Data\config\PicoDrive\PicoDrive.cfg".

[INFO] [Environ]: GET_LANGUAGE: "0".

[INFO] [Content Override]: File Extension: 'gen' - need_fullpath: FALSE, persistent_data: FALSE [INFO] [Content Override]: File Extension: 'smd' - need_fullpath: FALSE, persistent_data: FALSE [INFO] [Content Override]: File Extension: 'md' - need_fullpath: FALSE, persistent_data: FALSE [INFO] [Content Override]: File Extension: '32x' - need_fullpath: FALSE, persistent_data: FALSE [INFO] [Content Override]: File Extension: 'sms' - need_fullpath: FALSE, persistent_data: FALSE [INFO] [Content Override]: File Extension: '68k' - need_fullpath: FALSE, persistent_data: FALSE [INFO] [Content Override]: File Extension: 'sgd' - need_fullpath: FALSE, persistent_data: FALSE [INFO] [Content Override]: File Extension: 'pco' - need_fullpath: FALSE, persistent_data: FALSE [INFO] [Remaps]: Remap directory: "F:\Emulatorer\RetroArch Data\config\remaps". [INFO] [Remaps]: Core-specific remap found at "F:\Emulatorer\RetroArch Data\config\remaps\PicoDrive\PicoDrive.rmp". [INFO] [Overrides]: Redirecting save file to "F:\Emulatorer\RetroArch Data\saves\Blackthorne (USA).srm". [INFO] [Overrides]: Redirecting save state to "F:\Emulatorer\RetroArch Data\states\Blackthorne (USA).state". [INFO] [Environ]: PERFORMANCE_LEVEL: 0.

[INFO] [Content]: Loading content file: "F:\LaunchBox\Games\Sega 32X\Blackthorne (USA).zip#Blackthorne (USA).32x". [INFO] [Content]: Did not find a valid content patch. [INFO] [Content]: CRC32: 0xd1a60a47.

[INFO] [Environ]: SET_PIXEL_FORMAT: RGB565. [INFO] [Environ]: SYSTEM_DIRECTORY: "F:\Emulatorer\RetroArch Data\system". [libretro WARN] warning: wanted to map @02000000, got 0000000007a10000 [libretro INFO] 00000:000: couldn't open carthw.cfg! [libretro INFO] 00000:000: sram: 200000 - 203fff; eeprom: 0

[INFO] [SRAM]: Skipping SRAM load. [INFO] [Core]: Version of libretro API: 1, Compiled against API: 1 [INFO] [Audio]: Set audio input rate to: 44100.00 Hz. [INFO] [Video]: Set video size to: fullscreen. [INFO] [Vulkan]: Vulkan dynamic library loaded. [INFO] [Vulkan]: Found vulkan context: "vk_w". [INFO] [Vulkan]: Detecting screen resolution: 1920x240. [INFO] [Video]: Setting fullscreen to 1920x240 @ 240Hz on device \.\DISPLAY1. [INFO] [Vulkan]: Found GPU at index 0: "NVIDIA GeForce GTX 780 Ti". [INFO] [Vulkan]: Using GPU index 0. [INFO] [Vulkan]: Using GPU: "NVIDIA GeForce GTX 780 Ti". [INFO] [Vulkan]: Queue family 0 supports 16 sub-queues. [INFO] [Vulkan]: Using resolution 1920x240. [INFO] [Vulkan]: Using RGB565 format. [INFO] [Shaders]: Specific shader preset found at "F:\Emulatorer\RetroArch Data\config\PicoDrive\PicoDrive.slangp". [INFO] [slang]: Compiling shader: "F:\Emulatorer\RetroArch Data\shaders\shaders_slang\ntsc\shaders\ntsc-pass1-svideo-3phase.slang". [INFO] [slang]: Using render target format R16G16B16A16_SFLOAT for pass output #0. [INFO] [slang]: Compiling shader: "F:\Emulatorer\RetroArch Data\shaders\shaders_slang\ntsc\shaders\ntsc-pass2-3phase.slang". [INFO] [slang]: Using render target format R8G8B8A8_UNORM for pass output #1. [INFO] [slang]: Compiling shader: "F:\Emulatorer\RetroArch Data\shaders\shaders_slang\ntsc\shaders\ntsc-gauss-pass.slang". [INFO] [slang]: Using render target format R8G8B8A8_UNORM for pass output #2. [INFO] [slang]: Compiling shader: "F:\Emulatorer\RetroArch Data\shaders\shaders_slang\ntsc\shaders\ntsc-stock.slang". [INFO] [slang]: Using render target format R8G8B8A8_UNORM for pass output #3. [INFO] [slang]: Compiling shader: "F:\Emulatorer\RetroArch Data\shaders\shaders_slang\sharpen\shaders\adaptive-sharpen.slang". [INFO] [Vulkan filter chain]: Creating framebuffer 2048x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x240 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x240 (max 1 level(s)). [INFO] [WinRaw]: Mouse #0: "USB Gaming Keyboard". [INFO] [WinRaw]: Mouse #1: "HID MOUSE DEVICE". [INFO] [XInput]: Found XInput v1.4. [INFO] [Joypad]: Found joypad driver: "xinput". [INFO] [Font]: Using font rendering backend: "freetype". [INFO] [Video]: Found display server: "win32". [INFO] [XAudio2]: Requesting 32 ms latency, using 32 ms latency. [INFO] [Display]: Found display driver: "vulkan". [INFO] [MIDI]: Output device "Microsoft GS Wavetable Synth". [INFO] Initializing rewind buffer with size: 524 MB [INFO] [Playlist]: Loading history file: "F:\Emulatorer\RetroArch\content_history.lpl". [INFO] [Playlist]: Loading history file: "F:\Emulatorer\RetroArch\content_music_history.lpl". [INFO] [Playlist]: Loading history file: "F:\Emulatorer\RetroArch\content_video_history.lpl". [INFO] [Playlist]: Loading history file: "F:\Emulatorer\RetroArch\content_image_history.lpl". [INFO] [Playlist]: Loading favorites file: "F:\Emulatorer\RetroArch\content_favorites.lpl". [INFO] [Vulkan filter chain]: Creating framebuffer 2048x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x240 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x240 (max 1 level(s)).

[INFO] [Environ]: SET_GEOMETRY: 320x224, Aspect: 1.429. [INFO] [Vulkan filter chain]: Updating framebuffer size 1280x224 (format: 97). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Creating framebuffer 2048x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)). [INFO] [CRT]: Requested Resolution: 320x224@60.000000 [INFO] [CRT]: CRT Mode: 3 - pc_31_120 [INFO] [CRT]: RA Monitor Index Auto: auto [INFO] Video chipset is not compatible. [INFO] [CRT]: SR Disp Monitor Index Auto: Auto
[INFO] [CRT]: SR rtn 1 [INFO] [CRT]: Current running core PicoDrive [INFO] Switchres: Modeline "1920x224_120 0.000000KHz 120.000000Hz" 0.000000 1920 0 0 0 224 0 0 0 -hsync -vsync [INFO] sr_refresh_display: no refresh required [INFO] set_desktop_mode: \.\DISPLAY1 (1920x224@120) flags(0) [INFO] sr_switch_to_mode: successfully switched to 1920x224@120.000000 [INFO] [CRT]: Super resolution detected. Fractal scaling @ X:6.000000 Y:1 [INFO] [CRT]: Setting Aspect Ratio: 8.571428 [INFO] [CRT]: Setting Video Screen Size to: 1920x224 [INFO] [Video]: Setting refresh rate to: 120.000 Hz. [libretro INFO] 00003:124: 32X startup [libretro INFO] 00003:124: drc_cmn_init: 00007ffe34b09000, 140728902615040 bytes: 1 [libretro WARN] warning: wanted to map @06000000, got 0000000031830000

[INFO] [Vulkan filter chain]: Updating framebuffer size 1280x224 (format: 97). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan]: QueuePresent failed, destroying swapchain. [INFO] [Vulkan filter chain]: Creating framebuffer 2048x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)).

[libretro ERROR] savestate error: 140525/140524 [libretro ERROR] savestate error: 140528/140524 [libretro ERROR] savestate error: 140684/140524 [WARN] [Run-Ahead]: Failed to save state. Run-Ahead has been disabled. [INFO] [Vulkan filter chain]: Updating framebuffer size 1280x224 (format: 97). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [libretro INFO] 00148:224: msh2 drc: branch in DS @ 0205dee2 [INFO] [State]: Loading state "F:\Emulatorer\RetroArch Data\states\Blackthorne (USA).state", 678544 bytes. [INFO] [State]: Saving state "RAM", 678544 bytes. [INFO] [State]: State slot: 1 [INFO] [State]: State slot: 2 [INFO] [State]: State slot: 3 [INFO] [State]: State slot: 4 [INFO] [State]: State slot: 5 [INFO] [State]: Loading state "F:\Emulatorer\RetroArch Data\states\Blackthorne (USA).state5", 678544 bytes. [INFO] [State]: Saving state "RAM", 678544 bytes. [INFO] [Vulkan filter chain]: Creating framebuffer 2048x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)). [INFO] [Vulkan filter chain]: Updating framebuffer size 1280x224 (format: 97). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Video]: Setting refresh rate to: 120.000 Hz. [INFO] [Vulkan]: QueuePresent failed, destroying swapchain. [INFO] [Vulkan filter chain]: Creating framebuffer 2048x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)). [INFO] [Vulkan filter chain]: Updating framebuffer size 1280x224 (format: 97). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Creating framebuffer 2048x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x240 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x240 (max 1 level(s)). [INFO] [Vulkan filter chain]: Updating framebuffer size 1280x224 (format: 97). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Creating framebuffer 2048x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x240 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x240 (max 1 level(s)). [INFO] [Vulkan filter chain]: Updating framebuffer size 1024x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 1024x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 1280x224 (format: 97). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Creating framebuffer 2048x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)). [INFO] [Vulkan filter chain]: Updating framebuffer size 1280x224 (format: 97). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Creating framebuffer 2048x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x512 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)). [INFO] [Vulkan filter chain]: Creating framebuffer 1024x224 (max 1 level(s)). [INFO] [Vulkan filter chain]: Updating framebuffer size 1280x224 (format: 97). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [Vulkan filter chain]: Updating framebuffer size 640x224 (format: 37). [INFO] [State]: Loading state "F:\Emulatorer\RetroArch Data\states\Blackthorne (USA).state5", 678544 bytes. [INFO] [State]: Saving state "RAM", 678544 bytes. [INFO] [State]: Loading state "F:\Emulatorer\RetroArch Data\states\Blackthorne (USA).state5", 678544 bytes. [INFO] [State]: Saving state "RAM", 678544 bytes. [INFO] [State]: Loading state "F:\Emulatorer\RetroArch Data\states\Blackthorne (USA).state5", 678544 bytes. [INFO] [State]: Saving state "RAM", 678544 bytes. [INFO] [State]: Loading state "F:\Emulatorer\RetroArch Data\states\Blackthorne (USA).state5", 678544 bytes. [INFO] [State]: Saving state "RAM", 678544 bytes. [INFO] [State]: Loading state "F:\Emulatorer\RetroArch Data\states\Blackthorne (USA).state5", 678544 bytes. [INFO] [State]: Saving state "RAM", 678544 bytes. [INFO] [State]: Loading state "F:\Emulatorer\RetroArch Data\states\Blackthorne (USA).state5", 678544 bytes. [INFO] [State]: Saving state "RAM", 678544 bytes.

irixxxx commented 2 years ago

Could you give some more details? At which point in the game does it crash? what needs to be done to provoke the crash? Is there a save file?

irixxxx commented 2 years ago

Oh, one more question: Is run-ahead enabled?

DukeSkinny commented 2 years ago

As stated, the audio glitch/crash occurs when blowing up force field generators using remote wasps. This happens as part of most, if not all levels. If I had to hazard a guess, I'd say it's in the range of every 1 in 4-8 attempts. Here's a save state which places you right by a generator.

Run-ahead is left enabled by default, but I'd assumed that wouldn't come into play due to: [WARN] [Run-Ahead]: Failed to save state. Run-Ahead has been disabled.

irixxxx commented 2 years ago

I've taken some time for analysis. Master sh2 overwrites slave sh2 stack, which leads to a crash. On real hardware this might never occur due to caching in the slave sh2 which leads to reading the old value, but I can't verify this anymore since my 32X lamentably gave up the ghost. Picodrive doesn't emulate caching, so it wouldn't be possible to solve this in a clean way if the theory holds.

I have a working patch for this by moving the scratch memory used by master sh2, but it's an ugly hack and I hesitate to put this in. Maybe automatically patching the rom on load would be a solution. If you want to try it out, in the uncompressed rom change the values at 0x66dba and 0x66ee6 from 0xf6 to 0xf5.

irixxxx commented 1 year ago

I've put in an automatic rom patch to cover for this problem. I'm however not sure if this patch produces problems later on in the game. @DukeSkinny could you please test this again?

DukeSkinny commented 1 year ago

Hiya @irixxxx. No problem. I may be able to take a look at it later today, otherwise I'll give it a go tomorrow for sure.

DukeSkinny commented 1 year ago

Sad to say, using the latest core from the online updater I am still able to trigger the crashes. I tried two scenarios: first using the savestate I provided earlier, and secondly playing a new game up to the first generator. Seems I'm on the right version. (97fa8bc)

irixxxx commented 1 year ago

It's maybe rom-related. Which image are you using (Name and md5sum)?

DukeSkinny commented 1 year ago

That would be:

Blackthorne (USA).32x C238B112113B0297B2B9F4F618D56598

irixxxx commented 1 year ago

Is this still with the recompiler turned off? Could you please try the opposite? Which architecture are you using?

DukeSkinny commented 1 year ago

Sorry for the delay. I've injured my arm, but I may be able to dig deeper into this shortly. Anyway, as I remember, I crashed with or without the dynarec. On Zen 3 (5950X).

DrUm78 commented 1 year ago

My 2 cents: as discussed with irixxxx previously, I have the crash when blowing up force field generators too on armv7 32-bit (FunKey S handheld) but ONLY when enabling the dynarec. I tried many times with and without it and the issue seems to come from the arm dynarec on my side.

irixxxx commented 1 year ago

@DukeSkinny I and @DrUm78 have tested this with the latest and found it to be working. Could you please check again with the latest build from the buildbot?

KamiLordus commented 1 year ago

@irixxxx For me the game has completely broken sound. I made a separate report, didn't notice this entry. Everything worked fine before last update.

DrUm78 commented 1 year ago

Indeed, I have the same issue. See https://github.com/libretro/picodrive/issues/217#issuecomment-1584086166.

irixxxx commented 1 year ago

compile a core from the repo or get the latest from https://git.libretro.com/libretro/picodrive/-/pipelines for testing.

irixxxx commented 1 year ago

Anyone, is the behaviour originally reported in this ticket still happening with the latest code?

DrUm78 commented 1 year ago

No, that's now fixed on x86_64 and armv7 for me. 👍

irixxxx commented 1 year ago

Well then, fixed with fe8f2d9 and f81718c.