libretro / parallel-n64

Optimized/rewritten Nintendo 64 emulator made specifically for Libretro. Originally based on Mupen64 Plus.
314 stars 128 forks source link

No sound with HAVE_NEON=1 and __ARM_NEON__ defined (Odroid C1) #241

Open t1ddlyw1nks opened 9 years ago

t1ddlyw1nks commented 9 years ago

Hi, I have recreated the same issue described here: https://github.com/libretro/Lakka/issues/163

Basically. If mupen64plus-libretro is built with HAVE_NEON=1 and ARM_NEON__ defined then the audio does not work. There are not errors or segfaults reported, just no sound. Defining HAVE_NEON=0 and undefining ARM_NEON__ produces sound. Tested with most recent commit of repo (as of today) and built on Odroid C1. Did I miss something obvious?

vagabondking commented 9 years ago

Same issue with Cubox-i (IMX.6).

kivutar commented 9 years ago

Same issue on the RPi and RPi2. Neon breaks audio on this repo for more than one year iirc.

rockaddicted commented 8 years ago

I confirm this problem on RPI2. Someone found a solution ?

sergiobenrocha2 commented 8 years ago

I'm getting segfault with NEON enabled:

Program received signal SIGSEGV, Segmentation fault.
resampler_CC_upsample_neon () at mupen64plus-core/src/plugin/audio_libretro/drivers_resampler/cc_resampler_neon.S:343
343 vst1.f32 d20, [r4, :64]!
(gdb) 
(gdb) bt full
#0  resampler_CC_upsample_neon () at mupen64plus-core/src/plugin/audio_libretro/drivers_resampler/cc_resampler_neon.S:343
No locals.
#1  0xaf3b6ebc in resampler_CC_upsample (re_=0x262960, data=0xaf2803f0) at mupen64plus-core/src/plugin/audio_libretro/drivers_resampler/cc_resampler.c:405
No locals.
#2  0xaf3b6f0c in resampler_CC_process (re_=0x262960, data=0xaf2803f0) at mupen64plus-core/src/plugin/audio_libretro/drivers_resampler/cc_resampler.c:527
        re = 0x262960
#3  0xaf3b5bb4 in push_audio_samples_via_libretro (user_data=0x0, buffer=0xb1f44c20 <g_rdram+868992>, size=1984)
    at mupen64plus-core/src/plugin/audio_libretro/audio_backend_libretro.c:156
        out = 0x0
        max_frames = 1336
        remain_frames = 0
        i = 1984
        ratio = 1.5309842041312272
        data = {data_in = 0x262990, data_out = 0x266998, input_frames = 496, output_frames = 0, ratio = 1.5309842041312272}
        len = 1984
        raw_data = 0xb1f44c20 <g_rdram+868992>
        frames = 496
        p = 0xb1f44c20 <g_rdram+868992> ""
        saved_ai_length = 1984
        saved_ai_dram = 868992
#4  0xaf320ed0 in push_audio_samples (backend=0xb1e703a8 <g_ai+52>, buffer=0xb1f44c20 <g_rdram+868992>, size=1984) at mupen64plus-core/src/api/audio_backend.c:79
No locals.
#5  0xaf36ff3c in do_dma (ai=0xb1e70374 <g_ai>, dma=0xb1e7038c <g_ai+24>) at mupen64plus-core/src/ai/ai_controller.c:101
No locals.
#6  0xaf37002c in fifo_push (ai=0xb1e70374 <g_ai>) at mupen64plus-core/src/ai/ai_controller.c:129
        duration = 815158
#7  0xaf370224 in write_ai_regs (opaque=0xb1e70374 <g_ai>, address=2756706308, value=1984, mask=4294967295) at mupen64plus-core/src/ai/ai_controller.c:184
        ai = 0xb1e70374 <g_ai>
        reg = 1
#8  0xaf32da78 in writew (write_word=0xaf370194 <write_ai_regs>, opaque=0xb1e70374 <g_ai>, address=2756706308, value=1984)
    at mupen64plus-core/src/memory/m64p_memory.c:159
No locals.
#9  0xaf3300b8 in write_ai () at mupen64plus-core/src/memory/m64p_memory.c:704
No locals.
#10 0xafaf8088 in extra_memory () from /home/odroid/Projects/mupen64plus/mupen64plus-libretro/mupen64plus_libretro.so
No symbol table info available.
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
sergiobenrocha2 commented 8 years ago

I got it working, compiling with clang instead

CC=clang CXX=clang++ make platform="armv gles neon hardfloat"
sergiobenrocha2 commented 8 years ago

I can compile with clang 3.4, but not with 3.6:

clang -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -std=gnu89 -MMD -O2 -DNDEBUG  -DHAVE_NEON -D__LIBRETRO__ -DINLINE="inline" -DM64P_PLUGIN_API -DM64P_CORE_PROTOTYPES -D_ENDUSER_RELEASE -DSDL_VIDEO_OPENGL_ES2=1 -DSINC_LOWER_QUALITY -DHAVE_COMBINE_EXT  -I./mupen64plus-core/src -I./mupen64plus-core/src/api -I./mupen64plus-core/src/plugin/audio_libretro -I./glide2gl/src/Glitch64/inc -I./libretro/libco -I./libretro -DARM -fPIC -DARM  -DNO_ASM -DARM -D__arm__ -DARM_ASM -DNOSSE -marm -D__NEON_OPT -mfpu=neon -mfloat-abi=hard -DGLES -DHAVE_OPENGLES2 -DDISABLE_3POINT -DUSE_GLES  -DNEW_DYNAREC=3 -DDYNAREC -c gles2rice/src/RenderBase_neon.S -o gles2rice/src/RenderBase_neon.o
gles2rice/src/RenderBase_neon.S:205:5: error: instruction requires: armv6t2
    movw r8, #0x0000ffff
    ^
gles2rice/src/RenderBase_neon.S:206:5: error: instruction requires: armv6t2
    movt r8, #0x7f7f @ max normal float, ~3.4e+38
    ^
gles2rice/src/RenderBase_neon.S:248:5: error: instruction requires: armv6t2
    movt r8, #0x437f @ float 255
    ^
gles2rice/src/RenderBase_neon.S:287:5: error: instruction requires: armv6t2
    movw r8, #0
    ^
gles2rice/src/RenderBase_neon.S:288:5: error: instruction requires: armv6t2
    movt r8, #0x4f7f @ r8 = (float)(255<<24)
    ^
oblitum commented 8 years ago

;_; (I just bought a cubox-i to install lakka)

kivutar commented 8 years ago

At least now we know where the bug comes from. There is a report in LLVM https://llvm.org/bugs/show_bug.cgi?id=12926

Why gcc says nothing at compile time?

kivutar commented 8 years ago

Disabling the neon cc ressampler like this:

diff -Naur mupen64plus.git/mupen64plus-core/src/plugin/audio_libretro/audio_backend_libretro.c mupen64plus.patch/mupen64plus-core/src/plugin/audio_libretro/audio_backend_libretro.c
--- mupen64plus.git/mupen64plus-core/src/plugin/audio_libretro/audio_backend_libretro.c 2015-12-23 17:17:21.886100651 +0100
+++ mupen64plus.patch/mupen64plus-core/src/plugin/audio_libretro/audio_backend_libretro.c       2015-12-23 17:53:07.811769131 +0100
@@ -77,7 +77,7 @@

 void init_audio_libretro(unsigned max_audio_frames)
 {
-   rarch_resampler_realloc(&resampler_audio_data, &resampler, "CC", 1.0);
+   rarch_resampler_realloc(&resampler_audio_data, &resampler, "sinc", 1.0);

    MAX_AUDIO_FRAMES = max_audio_frames;

allowed me to play with audio while keeping NEON.