I'm trying to do some ASM for my fixed point multiply. I'm using 16.16, so I need to do some trickery with the resulting 64 bit number. Here is my if-defd C macro, and ASM code:
So, as expected the C macro performs a bit slower than the ASM code. However, I'm getting some weird artifacts in my zbuffering when I compile for ARM at different camera Z positions. I swear, the only way to get rid of the artifacts (disappearing polys) is to turn off the ARM ASM routine and use the macro. FPS drops by 2 in my particular test (1000 polygon flat shaded object), but it looks great at all camera Z positions.
I finally came up with this when I noticed it was working fine on the x86 emulator, but not PPC. So I compiled for ARM with the macro and all was fine... I just don't get it. Is my ARM ASM fmul somehow less accurate than the slower library call?
Chris
- Code:
#ifdef ARM
extern "C" inline long fmul(long f1, long f2);
#else
#define fmul(f1, f2) (long) (((__int64) f1 * (__int64) f2) >> 16)
#endif
// ASM
AREA FIXEDPOINT,CODE,READONLY
EXPORT fmul
fmul
smull r2, r3, r0, r1
mov r0, r2, lsr #16
orr r0, r0, r3, lsl #16
mov pc, lr
END
So, as expected the C macro performs a bit slower than the ASM code. However, I'm getting some weird artifacts in my zbuffering when I compile for ARM at different camera Z positions. I swear, the only way to get rid of the artifacts (disappearing polys) is to turn off the ARM ASM routine and use the macro. FPS drops by 2 in my particular test (1000 polygon flat shaded object), but it looks great at all camera Z positions.
I finally came up with this when I noticed it was working fine on the x86 emulator, but not PPC. So I compiled for ARM with the macro and all was fine... I just don't get it. Is my ARM ASM fmul somehow less accurate than the slower library call?
Chris