lujuemin
lujuemin

Reputation: 21

enable arm neon for bullet physics engine demo on android

I'm building a demo with bullet physics engine library for android phone(NDK). From 2.81 version, Bullet physics engine supports arm neon optimization, but only for apple devices. My question is how to enable arm neon for android? The flag for arm neon is defined in btScalar.h file, code is as below:

#if (defined (__APPLE__) && (!defined (BT_USE_DOUBLE_PRECISION)))
   #if defined (__i386__) || defined (__x86_64__)
             #define BT_USE_SSE
             #define BT_USE_SSE_IN_AP
   #elif defined( __armv7__ )
             #ifdef __clang__
             #define BT_USE_NEON 1
             #if defined BT_USE_NEON && defined (__clang__)
             #include <arm_neon.h>
             ……

As we can see in the code, flag BT_USE_NEON is defined in the condition of it is compiled for apple device, if I drop this code and define this flag by myself, some error occurs when compiling, something like bad alignment--vld1.f32 {d26},[r4:128].

What should I do for my demo to enable arm neon?

Upvotes: 0

Views: 638

Answers (1)

choi
choi

Reputation: 1

I had the same issues few days ago:) The problem was assembly code defined in btVector3 (vld1q_f32_aligned_postincrement). As far as I know, syntax such as [r3, :128] is used in GAS - I guess it is used in iOS environment, but not sure. Modifying it to [%1, #128] may remove those errors. By the way, from my experience, it is usually slow than plain implementation. I think the bullet neon intrinsics are not optimized for android, as you can see an assembly code(probably optimized) on the other side(defined as APPLE).

Upvotes: 0

Related Questions