Hello All,

I am trying to enable video bgfx for my Android buil of MAME on Ubuntu 18.04 but unfortunately there is a crash (shown below).
I have a reference board with HDMI out and am setting the mame.ini file with the settings from here and MAME documentation -
https://forums.launchbox-app.com/topic/33564-mame-bgfx-shaders-tutorial/
Using clang and have set the NDK/SDK paths.

video auto (software) is working fine. I would like to introduce some shaders and make the output look better.

So I have some doubts -
*************************** (multiplcation effect)
1. Can bgfx get enabled for Android?

2. It needs a backend to execute the same? I guess it is OpenGL? If yes then when I am trying to enable OpenGL with NO_OPENGL=0 MAME is not getting built (I hack the Makefile for this as the default for android-arm64 has NO_OPENGL=1)
/home/yash/Android/Sdk/ndk/21.0.6113669/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lGL
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

ON ANOTHER PLANE
+++++++++++++++++
3. I tried to use video OpenGL but because USE_OPENGL is not defined due to NO_OPENGL (different build) the system falls back to software mode (Video.cpp:242)
Invalid video value opengl; reverting to software
I know the documentation does not say so but the code speaks a different story...

#if (USE_OPENGL)
else if (strcmp(stemp, SDLOPTVAL_OPENGL) == 0)
video_config.mode = VIDEO_MODE_OPENGL;
#endif

4. The system folder in the device also does not have a LibGL.so and neither does the NDK (obviously that's the post). The stupid thought of downloading a bionic libGL.so came to my mind and trying to force link it but thought to ask for the right advice before I advent on the journey of insanity.

5. For bgfx enabling I have for testing manually copied the bgfx folder into a place in the device and then give that path in bgfx_path.


Any pointers wud be great help....

Pros - Highly Motivated for resolving this smile
Cons - New to Open Source, First ever Build in Open Source frown


CRASH REPORT for when video bgfx

2019-07-16 13:13:36.965 14064-14159/? V/SDL/APP: Available videodrivers:
2019-07-16 13:13:36.965 14064-14159/? V/SDL/APP: Android
2019-07-16 13:13:36.965 14064-14159/? V/SDL/APP: Current Videodriver: Android
2019-07-16 13:13:36.965 14064-14159/? V/SDL/APP: Display #0
2019-07-16 13:13:36.965 14064-14159/? V/SDL/APP: Renderdrivers:
2019-07-16 13:13:36.965 14064-14159/? V/SDL/APP: opengles2 (0x0)
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: opengles (0x0)
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: software (0x0)
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Available audio drivers:
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: dummy
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: android
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Build version: 0.216 (mame0216-dirty)
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Build architecure:
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Build defines 1:
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: SDLMAME_UNIX=1
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: SDLMAME_LINUX=1
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Build defines 1:
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: LSB_FIRST=1
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: PTR64=1
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: MAME_NOASM=1
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: SDL/OpenGL defines:
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: SDL_COMPILEDVERSION=2005
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: USE_OPENGL=0
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Compiler defines A:
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: __GNUC__=4
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: __GNUC_MINOR__=2
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: __GNUC_PATCHLEVEL__=1
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: __VERSION__="4.2.1 Compatible Android (5900059 based on r365631c) Clang 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 207d7abc1a2abf3ef8d4301736d6a7ebc224a290)"
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Compiler defines B:
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: __unix__=1
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Compiler defines C:
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Enter init_monitors
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Adding monitor screen0 (1920 x 1080)
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Leave init_monitors
2019-07-16 13:13:36.966 14064-14159/? V/SDL/APP: Enter sdlwindow_init
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: Hints:
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_FRAMEBUFFER_ACCELERATION (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_RENDER_DRIVER (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_RENDER_OPENGL_SHADERS (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_RENDER_SCALE_QUALITY (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_RENDER_VSYNC (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_VIDEO_X11_XVIDMODE (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_VIDEO_X11_XINERAMA (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_VIDEO_X11_XRANDR (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_GRAB_KEYBOARD (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_IOS_IDLE_TIMER_DISABLED (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_IOS_ORIENTATIONS (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_XINPUT_ENABLED (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_GAMECONTROLLERCONFIG (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_ALLOW_TOPMOST (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_TIMER_RESOLUTION (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_RENDER_DIRECT3D_THREADSAFE (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_VIDEO_ALLOW_SCREENSAVER (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_ACCELEROMETER_AS_JOYSTICK (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_VIDEO_WIN_D3DCOMPILER (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_VIDEO_MAC_FULLSCREEN_SPACES (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_MOUSE_RELATIVE_MODE_WARP (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_RENDER_DIRECT3D11_DEBUG (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_VIDEO_HIGHDPI_DISABLED (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_WINRT_PRIVACY_POLICY_URL (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_WINRT_PRIVACY_POLICY_LABEL (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: SDL_WINRT_HANDLE_BACK_BUTTON (NULL)
2019-07-16 13:13:36.967 14064-14159/? V/SDL/APP: Leave sdlwindow_init
2019-07-16 13:13:36.968 14064-14159/? V/SDL/APP: Enter sdl_info::create
2019-07-16 13:13:36.970 14064-14159/? V/SDL: getNativeSurface()
2019-07-16 13:13:36.971 14064-14159/? D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000

--------- beginning of crash
2019-07-16 13:13:36.974 14064-14160/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x98 in tid 14160 (SDLThread), pid 14064 (rg.mamedev.mame)
2019-07-16 13:13:37.023 14163-14163/? I/crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
2019-07-16 13:13:37.024 406-406/? I//system/bin/tombstoned: received crash request for pid 14064
2019-07-16 13:13:37.026 14163-14163/? I/crash_dump64: performing dump of process 14064 (target tid = 14160)
2019-07-16 13:13:37.026 14163-14163/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2019-07-16 13:13:37.026 14163-14163/? A/DEBUG: Revision: '0'
2019-07-16 13:13:37.026 14163-14163/? A/DEBUG: ABI: 'arm64'
2019-07-16 13:13:37.026 14163-14163/? A/DEBUG: pid: 14064, tid: 14160, name: SDLThread >>> org.mamedev.mame <<<
2019-07-16 13:13:37.026 14163-14163/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x98
2019-07-16 13:13:37.026 14163-14163/? A/DEBUG: Cause: null pointer dereference
2019-07-16 13:13:37.026 14163-14163/? A/DEBUG: x0 0000000000000000 x1 0000000000000780 x2 0000000000000438 x3 0000000000000001
2019-07-16 13:13:37.026 14163-14163/? A/DEBUG: x4 0000006f27d01d60 x5 0000006f27876510 x6 0000000000003026 x7 0000000003ba6fb2
2019-07-16 13:13:37.026 14163-14163/? A/DEBUG: x8 56dc3bcf91e0ef1c x9 56dc3bcf91e0ef1c x10 0000000000000000 x11 0000000000000001
2019-07-16 13:13:37.027 14163-14163/? A/DEBUG: x12 0000006f3b78c148 x13 0000000000000004 x14 000000000000308f x15 ffffffffffffffff
2019-07-16 13:13:37.027 14163-14163/? A/DEBUG: x16 0000006f2b6ab9a0 x17 0000006f3e116888 x18 0000000000000004 x19 0000000000000000
2019-07-16 13:13:37.027 14163-14163/? A/DEBUG: x20 0000000000000438 x21 0000000000000780 x22 0000000000000780 x23 0000006f3b7af000
2019-07-16 13:13:37.027 14163-14163/? A/DEBUG: x24 0000006f2afef42a x25 0000006f27d02588 x26 0000006f2ae76073 x27 0000006f2b90af58
2019-07-16 13:13:37.027 14163-14163/? A/DEBUG: x28 0000006f27d01fc0 x29 0000006f27d01f10 x30 0000006f2acd69c0
2019-07-16 13:13:37.027 14163-14163/? A/DEBUG: sp 0000006f27d01ef0 pc 0000006f3e1168a4 pstate 0000000060000000
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: backtrace:
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #00 pc 00000000000148a4 /system/lib64/libandroid.so (ANativeWindow_setBuffersGeometry+28)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #01 pc 0000000002ed59bc /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::gl::GlContext::create(unsigned int, unsigned int)+500)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #02 pc 0000000002eba038 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::gl::RendererContextGL::setRenderContextSize(unsigned int, unsigned int, unsigned int)+232)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #03 pc 0000000002ead430 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::gl::RendererContextGL::init(bgfx::Init const&)+160)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #04 pc 0000000002eac9f0 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::gl::rendererCreate(bgfx::Init const&)+100)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #05 pc 0000000002e97afc /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::rendererCreate(bgfx::Init const&)+584)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #06 pc 0000000002e98d90 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::Context::rendererExecCommands(bgfx::CommandBuffer&)+4680)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #07 pc 0000000002e93f98 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::Context::renderFrame(int)+212)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #08 pc 0000000002e93de8 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::renderFrame(int)+48)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #09 pc 0000000002e95130 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::Context::renderThread(bx::Thread*, void*)+12)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #10 pc 0000000002f13164 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bx::ThreadInternal::threadFunc(void*)+36)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #11 pc 0000000000067d80 /system/lib64/libc.so (__pthread_start(void*)+36)
2019-07-16 13:13:37.049 14163-14163/? A/DEBUG: #12 pc 000000000001ec18 /system/lib64/libc.so (__start_thread+68)
2019-07-16 13:13:37.093 14164-14164/? I/sh: type=1400 audit(0.0:73): avc: denied { execute_no_trans } for path="/vendor/bin/toybox_vendor" dev="dm-1" ino=416 scontext=u:r:pwm_fan_autorun:s0 tcontext=u:object_r:vendor_toolbox_exec:s0 tclass=file permissive=1
2019-07-16 13:13:37.785 406-406/? E//system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_39





I did a crash dump with ndk-stack of the tombstone data spit and got this
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

ndk-stack -sym ~/programs/mame/android-project/app/build/intermediates/jniLibs/debug/arm64-v8a -dump tombstone_39
********** Crash dump: **********
Build fingerprint: 'Android/nanopc_t4/nanopc-t4:8.1.0/OPM8.181005.003/144606:userdebug/test-keys'
#00 0x00000000000148a4 /system/lib64/libandroid.so (ANativeWindow_setBuffersGeometry+28)
#01 0x0000000002ed59bc /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::gl::GlContext::create(unsigned int, unsigned int)+500)
device_finder<samples_device, false>::device_finder(device_t&, char const*)
/home/yash/programs/mame/build/projects/sdl/mametiny/gmake-android-arm64/../../../../../src/emu/devfind.h:544:51
#02 0x0000000002eba038 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::gl::RendererContextGL::setRenderContextSize(unsigned int, unsigned int, unsigned int)+232)
ym2610_write(void*, int, unsigned char)
/home/yash/programs/mame/build/projects/sdl/mametiny/gmake-android-arm64/../../../../../src/devices/sound/fm.cpp:3829:20
#03 0x0000000002ead430 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::gl::RendererContextGL::init(bgfx::Init const&)+160)
dac_device<dac_code_twos_complement<8u> >::device_start()
/home/yash/programs/mame/build/projects/sdl/mametiny/gmake-android-arm64/../../../../../src/devices/sound/dac.h:193:3
#04 0x0000000002eac9f0 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::gl::rendererCreate(bgfx::Init const&)+100)
non-virtual thunk to dac_8bit_r2r_device::~dac_8bit_r2r_device()
??:0:0
#05 0x0000000002e97afc /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::rendererCreate(bgfx::Init const&)+584)
std::__ndk1::unique_ptr<ad7521_device, std::__ndk1::default_delete<ad7521_device> >::release()
/home/yash/Android/Sdk/ndk/21.0.6113669/sources/cxx-stl/llvm-libc++/include/memory:2584:20
#06 0x0000000002e98d90 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::Context::rendererExecCommands(bgfx::CommandBuffer&)+4680)
std::__ndk1::unique_ptr<ad7528_device, std::__ndk1::default_delete<ad7528_device> >::release()
/home/yash/Android/Sdk/ndk/21.0.6113669/sources/cxx-stl/llvm-libc++/include/memory:2583:26
#07 0x0000000002e93f98 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::Context::renderFrame(int)+212)
object_finder_base<mc3410_device, true>::end_configuration()
/home/yash/programs/mame/build/projects/sdl/mametiny/gmake-android-arm64/../../../../../src/emu/devfind.h:465:0
#08 0x0000000002e93de8 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::renderFrame(int)+48)
device_finder<mc3408_device, false>::~device_finder()
/home/yash/programs/mame/build/projects/sdl/mametiny/gmake-android-arm64/../../../../../src/devices/sound/dac.h:282:1
#09 0x0000000002e95130 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bgfx::Context::renderThread(bx::Thread*, void*)+12)
object_finder_base<dac_6bit_r2r_device, true>::operator->() const
/home/yash/programs/mame/build/projects/sdl/mametiny/gmake-android-arm64/../../../../../src/emu/devfind.h:491:0
#10 0x0000000002f13164 /data/app/org.mamedev.mame-J9SVJLxhTvGUaAo6KrgXtg==/lib/arm64/libmain.so (bx::ThreadInternal::threadFunc(void*)+36)
util::basic_ovectorstream<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >::off_type util::stream_format<util::basic_ovectorstream<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, char [66]>(util::basic_ovectorstream<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >&, char const (&) [66])
/home/yash/programs/mame/build/projects/sdl/mametiny/gmake-android-arm64/../../../../../src/lib/util/strformat.h:1662:9
#11 0x0000000000067d80 /system/lib64/libc.so (__pthread_start(void*)+36)
#12 0x000000000001ec18 /system/lib64/libc.so (__start_thread+68)
Crash dump is completed


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Thanks for reading.

Regards
Yash