From 09c02348215efcd8967bac2c7bf0da5184cd1a35 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 30 Aug 2013 20:59:01 -0700 Subject: [PATCH 1/2] Ooops, reverting optimization for C still valid for Neon, but the current optimization is not valid for C. Please, apply this patch otherwise cocos2d won't work correctly on simulator, windows, linux, mac, etc... --- cocos2dx/kazmath/src/mat4.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos2dx/kazmath/src/mat4.c b/cocos2dx/kazmath/src/mat4.c index c1c5e65112..d1ced65603 100644 --- a/cocos2dx/kazmath/src/mat4.c +++ b/cocos2dx/kazmath/src/mat4.c @@ -218,13 +218,14 @@ kmMat4* const kmMat4Multiply(kmMat4* pOut, const kmMat4* pM1, const kmMat4* pM2) { #if defined(__ARM_NEON__) - float *mat = pOut->mat; + float mat[16]; +// float *mat = pOut->mat; // Invert column-order with row-order NEON_Matrix4Mul( &pM2->mat[0], &pM1->mat[0], &mat[0] ); #else - float *mat = pOut->mat; + float mat[16]; const float *m1 = pM1->mat, *m2 = pM2->mat; @@ -248,6 +249,8 @@ kmMat4* const kmMat4Multiply(kmMat4* pOut, const kmMat4* pM1, const kmMat4* pM2) mat[14] = m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15]; mat[15] = m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15]; + memcpy(pOut->mat, mat, sizeof(pOut->mat)); + #endif return pOut; From 9ad1ab50fd69c9f3fb4f68c18412876e0b4cd360 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 30 Aug 2013 21:08:28 -0700 Subject: [PATCH 2/2] compiles on ARM --- cocos2dx/kazmath/src/mat4.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos2dx/kazmath/src/mat4.c b/cocos2dx/kazmath/src/mat4.c index d1ced65603..77495cfdaa 100644 --- a/cocos2dx/kazmath/src/mat4.c +++ b/cocos2dx/kazmath/src/mat4.c @@ -218,8 +218,9 @@ kmMat4* const kmMat4Multiply(kmMat4* pOut, const kmMat4* pM1, const kmMat4* pM2) { #if defined(__ARM_NEON__) - float mat[16]; -// float *mat = pOut->mat; + // It is possible to skip the memcpy() since "out" does not overwrite p1 or p2. + // otherwise a temp must be needed. + float *mat = pOut->mat; // Invert column-order with row-order NEON_Matrix4Mul( &pM2->mat[0], &pM1->mat[0], &mat[0] );