Merge pull request #9203 from dumganhar/arm64-juno

Some updates for neon64 instruction
This commit is contained in:
minggo 2014-11-26 11:46:19 +08:00
commit dbb473fdcb
19 changed files with 670 additions and 18 deletions

View File

@ -2246,6 +2246,8 @@
1A8C5986180E930E00EF57C3 /* CocoStudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocoStudio.h; sourceTree = "<group>"; };
1A8C5989180E930E00EF57C3 /* DictionaryHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DictionaryHelper.cpp; sourceTree = "<group>"; };
1A8C598A180E930E00EF57C3 /* DictionaryHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictionaryHelper.h; sourceTree = "<group>"; };
1A97ABFC1A1D962A0076D9CC /* MathUtilNeon64.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MathUtilNeon64.inl; sourceTree = "<group>"; };
1A97ABFD1A1D962A0076D9CC /* MathUtilSSE.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MathUtilSSE.inl; sourceTree = "<group>"; };
1A9DCA02180E6955007A3AD4 /* CCGLBufferedNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLBufferedNode.cpp; sourceTree = "<group>"; };
1A9DCA03180E6955007A3AD4 /* CCGLBufferedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLBufferedNode.h; sourceTree = "<group>"; };
1AAF5351180E3060000584C8 /* AssetsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AssetsManager.cpp; sourceTree = "<group>"; };
@ -4712,6 +4714,8 @@
50ABBD271925AB0000A911A9 /* MathUtil.h */,
50ABBD281925AB0000A911A9 /* MathUtil.inl */,
50ABBD291925AB0000A911A9 /* MathUtilNeon.inl */,
1A97ABFC1A1D962A0076D9CC /* MathUtilNeon64.inl */,
1A97ABFD1A1D962A0076D9CC /* MathUtilSSE.inl */,
50ABBD2A1925AB0000A911A9 /* Quaternion.cpp */,
50ABBD2B1925AB0000A911A9 /* Quaternion.h */,
50ABBD2C1925AB0000A911A9 /* Quaternion.inl */,

View File

@ -141,6 +141,8 @@
1A1645A9191B6283008C7C7F /* ccs-res in Resources */ = {isa = PBXBuildFile; fileRef = 1A221C9B191771E300FD2BE4 /* ccs-res */; };
1A221C9C191771E300FD2BE4 /* ccs-res in Resources */ = {isa = PBXBuildFile; fileRef = 1A221C9B191771E300FD2BE4 /* ccs-res */; };
1A221C9D191771E400FD2BE4 /* ccs-res in Resources */ = {isa = PBXBuildFile; fileRef = 1A221C9B191771E300FD2BE4 /* ccs-res */; };
1A97AC001A1DC3E30076D9CC /* PerformanceMathTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A97ABFE1A1DC3E30076D9CC /* PerformanceMathTest.cpp */; };
1A97AC011A1DC3E30076D9CC /* PerformanceMathTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A97ABFE1A1DC3E30076D9CC /* PerformanceMathTest.cpp */; };
1A9F808D177E98A600D9A1CB /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; };
1AAF534D180E2F4E000584C8 /* libcocos2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2d Mac.a */; };
1AAF5400180E39D4000584C8 /* libcocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2d iOS.a */; };
@ -1067,6 +1069,8 @@
1A0EE41318CDF775004CD58F /* cpp-empty-test iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "cpp-empty-test iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1A0EE47E18CDF799004CD58F /* lua-empty-test iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "lua-empty-test iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1A221C9B191771E300FD2BE4 /* ccs-res */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "ccs-res"; path = "../tests/cpp-tests/Resources/ccs-res"; sourceTree = "<group>"; };
1A97ABFE1A1DC3E30076D9CC /* PerformanceMathTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceMathTest.cpp; sourceTree = "<group>"; };
1A97ABFF1A1DC3E30076D9CC /* PerformanceMathTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceMathTest.h; sourceTree = "<group>"; };
1A9F808C177E98A600D9A1CB /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; };
1ABCA27618CD90A40087CE3A /* cocos2d_lua_bindings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_lua_bindings.xcodeproj; path = "../cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj"; sourceTree = "<group>"; };
1ABCA28618CD91510087CE3A /* lua-tests Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "lua-tests Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; };
@ -2898,12 +2902,16 @@
children = (
1AC35AC218CECF0C00F37B72 /* PerformanceAllocTest.cpp */,
1AC35AC318CECF0C00F37B72 /* PerformanceAllocTest.h */,
1AF152D718FD252A00A52F3D /* PerformanceCallbackTest.cpp */,
1AF152D818FD252A00A52F3D /* PerformanceCallbackTest.h */,
1AC35AC418CECF0C00F37B72 /* PerformanceContainerTest.cpp */,
1AC35AC518CECF0C00F37B72 /* PerformanceContainerTest.h */,
1AC35AC618CECF0C00F37B72 /* PerformanceEventDispatcherTest.cpp */,
1AC35AC718CECF0C00F37B72 /* PerformanceEventDispatcherTest.h */,
1AC35AC818CECF0C00F37B72 /* PerformanceLabelTest.cpp */,
1AC35AC918CECF0C00F37B72 /* PerformanceLabelTest.h */,
1A97ABFE1A1DC3E30076D9CC /* PerformanceMathTest.cpp */,
1A97ABFF1A1DC3E30076D9CC /* PerformanceMathTest.h */,
1AC35ACA18CECF0C00F37B72 /* PerformanceNodeChildrenTest.cpp */,
1AC35ACB18CECF0C00F37B72 /* PerformanceNodeChildrenTest.h */,
1AC35ACC18CECF0C00F37B72 /* PerformanceParticleTest.cpp */,
@ -2920,8 +2928,6 @@
1AC35AD718CECF0C00F37B72 /* PerformanceTextureTest.h */,
1AC35AD818CECF0C00F37B72 /* PerformanceTouchesTest.cpp */,
1AC35AD918CECF0C00F37B72 /* PerformanceTouchesTest.h */,
1AF152D718FD252A00A52F3D /* PerformanceCallbackTest.cpp */,
1AF152D818FD252A00A52F3D /* PerformanceCallbackTest.h */,
);
path = PerformanceTest;
sourceTree = "<group>";
@ -4840,6 +4846,7 @@
29080DC9191B595E0066F8DF /* UISceneManager_Editor.cpp in Sources */,
1AC35B3F18CECF0C00F37B72 /* Bug-458.cpp in Sources */,
3E2F27B919CFF4AF00E7C490 /* NewAudioEngineTest.cpp in Sources */,
1A97AC001A1DC3E30076D9CC /* PerformanceMathTest.cpp in Sources */,
1AC35C3918CECF0C00F37B72 /* PerformanceTextureTest.cpp in Sources */,
1AC35B5318CECF0C00F37B72 /* CocosDenshionTest.cpp in Sources */,
29080DD3191B595E0066F8DF /* UITextAtlasTest.cpp in Sources */,
@ -5031,6 +5038,7 @@
29080DC8191B595E0066F8DF /* UISceneManager.cpp in Sources */,
1AC35C6A18CECF0C00F37B72 /* VisibleRect.cpp in Sources */,
1AC35C4018CECF0C00F37B72 /* ReleasePoolTest.cpp in Sources */,
1A97AC011A1DC3E30076D9CC /* PerformanceMathTest.cpp in Sources */,
1AC35C5818CECF0C00F37B72 /* TextureCacheTest.cpp in Sources */,
1AC35B6E18CECF0C00F37B72 /* HelloCocosBuilderLayer.cpp in Sources */,
29080D96191B595E0066F8DF /* CustomParticleWidgetTest.cpp in Sources */,

View File

@ -42,7 +42,8 @@ This file was modified to fit the cocos2d-x project
#else
#endif
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#if defined (__arm64__)
#if defined (__arm64__) || defined (__aarch64__)
#define USE_NEON64
#define INCLUDE_NEON64
#elif defined (__ARM_NEON__)
#define INCLUDE_NEON32

View File

@ -225,23 +225,34 @@ inline void MathUtilNeon64::transformVec4(const float* m, const float* v, float*
inline void MathUtilNeon64::crossVec3(const float* v1, const float* v2, float* dst)
{
asm volatile(
"ld1 {v0.2s}, [%2] \n\t" //
"ld1 {v0.s}[3], [%1] \n\t" //
"mov v0.s[2], v0.s[1] \n\t" // q0 = (v1y, v1z, v1z, v1x)
asm volatile(
"ld1 {v0.2s}, [%2] \n\t"
"ld1 {v0.s}[2], [%1] \n\t"
"mov v0.s[3], v0.s[0] \n\t" // q0 = (v1y, v1z, v1x, v1x)
"ld1 {v1.s}[1], [%3] \n\t" //
"ld1 {v1.s}[2], [%4], 4 \n\t" //
"ld1 {v1.s}[3], [%4] \n\t" //
"mov v1.s[0], v1.s[3] \n\t" // q1 = (v2z, v2x, v2y, v2z)
"ld1 {v1.4s}, [%3] \n\t"
"mov v1.s[3], v1.s[0] \n\t" // q1 = (v2x, v2y, v2z, v2x)
"fmul v2.4s, v0.4s, v1.4s \n\t" // x = v1y * v2z, y = v1z * v2x
"fsub s8, s8, s10 \n\t"
"fsub s9, s9, s11 \n\t" // x -= v1z * v2y, y-= v1x - v2z
"fmul s10, s3, s6 \n\t" // z = v1x * v2y
"fmul s11, s0, s5 \n\t" // z-= v1y * vx
"fsub s10, s10, s11 \n\t"
"mov v0.s[0], v0.s[1] \n\t"
"mov v0.s[1], v0.s[2] \n\t"
"mov v0.s[2], v0.s[3] \n\t"
"mov v1.s[3], v1.s[2] \n\t"
"fmul v0.4s, v0.4s, v1.4s \n\t"
"mov v0.s[3], v0.s[1] \n\t"
"mov v0.s[1], v0.s[2] \n\t"
"mov v0.s[2], v0.s[0] \n\t"
"fsub v2.4s, v0.4s, v2.4s \n\t"
"mov v2.s[0], v2.s[1] \n\t"
"mov v2.s[1], v2.s[2] \n\t"
"mov v2.s[2], v2.s[3] \n\t"
"st1 {v2.2s}, [%0], 8 \n\t" // V[x, y]
"st1 {v2.s}[2], [%0] \n\t" // V[z]

View File

@ -37,6 +37,14 @@ THE SOFTWARE.
#define LOG_TAG "CCApplication_android Debug"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
// FIXME: using ndk-r10c will cause the next function could not be found. It may be a bug of ndk-r10c.
// Here is the workaround method to fix the problem.
#ifdef __aarch64__
extern "C" size_t __ctype_get_mb_cur_max(void) {
return (size_t) sizeof(wchar_t);
}
#endif
NS_CC_BEGIN
// sharedApplication pointer

View File

@ -155,6 +155,7 @@ set(TESTS_SRC
Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp
Classes/PerformanceTest/PerformanceScenarioTest.cpp
Classes/PerformanceTest/PerformanceCallbackTest.cpp
Classes/PerformanceTest/PerformanceMathTest.cpp
Classes/PhysicsTest/PhysicsTest.cpp
Classes/ReleasePoolTest/ReleasePoolTest.cpp
Classes/RenderTextureTest/RenderTextureTest.cpp

View File

@ -0,0 +1,193 @@
#include "PerformanceMathTest.h"
// Enable profiles for this file
#undef CC_PROFILER_DISPLAY_TIMERS
#define CC_PROFILER_DISPLAY_TIMERS() Profiler::getInstance()->displayTimers()
#undef CC_PROFILER_PURGE_ALL
#define CC_PROFILER_PURGE_ALL() Profiler::getInstance()->releaseAllTimers()
#undef CC_PROFILER_START
#define CC_PROFILER_START(__name__) ProfilingBeginTimingBlock(__name__)
#undef CC_PROFILER_STOP
#define CC_PROFILER_STOP(__name__) ProfilingEndTimingBlock(__name__)
#undef CC_PROFILER_RESET
#define CC_PROFILER_RESET(__name__) ProfilingResetTimingBlock(__name__)
#undef CC_PROFILER_START_CATEGORY
#define CC_PROFILER_START_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingBeginTimingBlock(__name__); } while(0)
#undef CC_PROFILER_STOP_CATEGORY
#define CC_PROFILER_STOP_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingEndTimingBlock(__name__); } while(0)
#undef CC_PROFILER_RESET_CATEGORY
#define CC_PROFILER_RESET_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingResetTimingBlock(__name__); } while(0)
#undef CC_PROFILER_START_INSTANCE
#define CC_PROFILER_START_INSTANCE(__id__, __name__) do{ ProfilingBeginTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0)
#undef CC_PROFILER_STOP_INSTANCE
#define CC_PROFILER_STOP_INSTANCE(__id__, __name__) do{ ProfilingEndTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0)
#undef CC_PROFILER_RESET_INSTANCE
#define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0)
static const int TEST_COUNT = 2;
static int s_nTouchCurCase = 0;
static const int K_INFO_LOOP_TAG = 1581;
static PerformanceMathLayer* createLayer()
{
s_nTouchCurCase = s_nTouchCurCase % TEST_COUNT;
PerformanceMathLayer* result = nullptr;
switch (s_nTouchCurCase) {
case 0:
result = new PerformanceMathLayer1(true, TEST_COUNT, s_nTouchCurCase);
break;
case 1:
result = new PerformanceMathLayer2(true, TEST_COUNT, s_nTouchCurCase);
break;
default:
result = new PerformanceMathLayer1(true, TEST_COUNT, s_nTouchCurCase);
break;
}
if(result)
{
result->autorelease();
return result;
}
else
{
return nullptr;
}
}
void PerformanceMathLayer::onEnter()
{
PerformBasicLayer::onEnter();
_loopCount = 10000;
_stepCount = 10000;
CC_PROFILER_PURGE_ALL();
auto s = Director::getInstance()->getWinSize();
// Title
auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32);
addChild(label, 1);
label->setPosition(Vec2(s.width/2, s.height-50));
// Subtitle
std::string strSubTitle = subtitle();
if(strSubTitle.length())
{
auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16);
addChild(l, 1);
l->setPosition(Vec2(s.width/2, s.height-80));
}
MenuItemFont::setFontSize(65);
auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(PerformanceMathLayer::subLoopCount, this));
decrease->setColor(Color3B(0,200,20));
auto increase = MenuItemFont::create(" + ", CC_CALLBACK_1(PerformanceMathLayer::addLoopCount, this));
increase->setColor(Color3B(0,200,20));
auto menu = Menu::create(decrease, increase, nullptr);
menu->alignItemsHorizontally();
menu->setPosition(Vec2(s.width/2, s.height/2));
addChild(menu, 1);
auto infoLabel = Label::createWithTTF("0", "fonts/Marker Felt.ttf", 30);
infoLabel->setColor(Color3B(0,200,20));
infoLabel->setPosition(Vec2(s.width/2, s.height/2 + 40));
addChild(infoLabel, 1, K_INFO_LOOP_TAG);
updateLoopLabel();
getScheduler()->schedule(schedule_selector(PerformanceMathLayer::doPerformanceTest), this, 0.0f, false);
getScheduler()->schedule(schedule_selector(PerformanceMathLayer::dumpProfilerInfo), this, 2, false);
}
void PerformanceMathLayer::addLoopCount(Ref *sender)
{
_loopCount += _stepCount;
updateLoopLabel();
}
void PerformanceMathLayer::subLoopCount(Ref *sender)
{
_loopCount -= _stepCount;
_loopCount = std::max(_loopCount, 0);
updateLoopLabel();
}
void PerformanceMathLayer::updateLoopLabel()
{
auto infoLabel = (Label *) getChildByTag(K_INFO_LOOP_TAG);
char str[16] = {0};
sprintf(str, "%u", _loopCount);
infoLabel->setString(str);
}
void PerformanceMathLayer::restartCallback(Ref* sender)
{
s_nTouchCurCase = 0;
runMathPerformanceTest();
}
void PerformanceMathLayer::nextCallback(Ref* sender)
{
++s_nTouchCurCase;
s_nTouchCurCase = s_nTouchCurCase % TEST_COUNT;
runMathPerformanceTest();
}
void PerformanceMathLayer::backCallback(Ref* sender)
{
s_nTouchCurCase = s_nTouchCurCase + TEST_COUNT -1;
s_nTouchCurCase = s_nTouchCurCase % TEST_COUNT;
runMathPerformanceTest();
}
void PerformanceMathLayer::dumpProfilerInfo(float dt)
{
CC_PROFILER_DISPLAY_TIMERS();
}
void PerformanceMathLayer1::doPerformanceTest(float dt)
{
Mat4 dst = Mat4::IDENTITY;
Mat4 src;
Mat4::createRotation(Vec3(1,1,1), 10, &src);
CC_PROFILER_START(_profileName.c_str());
for (int i = 0; i < _loopCount; ++i)
{
dst = dst * src;
}
CC_PROFILER_STOP(_profileName.c_str());
}
void PerformanceMathLayer2::doPerformanceTest(float dt)
{
Vec4 dst(1,3,4,1);
Mat4 src;
Mat4::createRotation(Vec3(1,1,1), 10, &src);
CC_PROFILER_START(_profileName.c_str());
for (int i = 0; i < _loopCount; ++i)
{
dst = src * dst;
}
CC_PROFILER_STOP(_profileName.c_str());
}
void runMathPerformanceTest()
{
auto scene = Scene::create();
auto layer = createLayer();
scene->addChild(layer);
Director::getInstance()->replaceScene(scene);
}

View File

@ -0,0 +1,73 @@
#ifndef __PERFORMANCE_MATH_TEST_H__
#define __PERFORMANCE_MATH_TEST_H__
#include "PerformanceTest.h"
class PerformanceMathLayer : public PerformBasicLayer
{
public:
PerformanceMathLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0):
PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase)
, _loopCount(1000)
, _stepCount(500)
, _profileName("")
{
}
virtual void onEnter() override;
virtual void restartCallback(Ref* sender);
virtual void nextCallback(Ref* sender);
virtual void backCallback(Ref* sender);
virtual void showCurrentTest() {}
virtual std::string title() const { return "Math Performance Test"; }
virtual std::string subtitle() const { return "PerformanceMathLayer subTitle"; }
void addLoopCount(Ref* sender);
void subLoopCount(Ref* sender);
protected:
virtual void doPerformanceTest(float dt) {};
void dumpProfilerInfo(float dt);
void updateLoopLabel();
protected:
int _loopCount;
int _stepCount;
std::string _profileName;
};
class PerformanceMathLayer1 : public PerformanceMathLayer
{
public:
PerformanceMathLayer1(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0):
PerformanceMathLayer(bControlMenuVisible, nMaxCases, nCurCase)
{
_profileName = "profile_Mat4*Mat4";
}
virtual void doPerformanceTest(float dt) override;
virtual std::string subtitle() const { return "Mat4 * Mat4"; }
private:
};
class PerformanceMathLayer2 : public PerformanceMathLayer
{
public:
PerformanceMathLayer2(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0):
PerformanceMathLayer(bControlMenuVisible, nMaxCases, nCurCase)
{
_profileName = "profile_MatTransformVec4";
}
virtual void doPerformanceTest(float dt) override;
virtual std::string subtitle() const { return "Mat4 TransformVec4"; }
};
void runMathPerformanceTest();
#endif //__PERFORMANCE_MATH_TEST_H__

View File

@ -12,6 +12,7 @@
#include "PerformanceEventDispatcherTest.h"
#include "PerformanceScenarioTest.h"
#include "PerformanceCallbackTest.h"
#include "PerformanceMathTest.h"
enum
{
@ -36,6 +37,7 @@ struct {
{ "EventDispatcher Perf Test", [](Ref* sender ) { runEventDispatcherPerformanceTest(); } },
{ "Scenario Perf Test", [](Ref* sender ) { runScenarioTest(); } },
{ "Callback Perf Test", [](Ref* sender ) { runCallbackPerformanceTest(); } },
{ "Math Perf Test", [](Ref* sender ) { runMathPerformanceTest(); } },
};
static const int g_testMax = sizeof(g_testsName)/sizeof(g_testsName[0]);

View File

@ -1,6 +1,37 @@
#include "UnitTest.h"
#include "RefPtrTest.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#if defined (__arm64__)
#define USE_NEON64
#define INCLUDE_NEON64
#elif defined (__ARM_NEON__)
#define USE_NEON32
#define INCLUDE_NEON32
#else
#endif
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#if defined (__arm64__) || defined (__aarch64__)
#define USE_NEON64
#define INCLUDE_NEON64
#elif defined (__ARM_NEON__)
#define INCLUDE_NEON32
#else
#endif
#else
#endif
#if defined (__SSE__)
#define USE_SSE
#define INCLUDE_SSE
#endif
#if (defined INCLUDE_NEON64) || (defined INCLUDE_NEON32) // FIXME: || (defined INCLUDE_SSE)
#define UNIT_TEST_FOR_OPTIMIZED_MATH_UTIL
#endif
// For ' < o > ' multiply test scene.
static std::function<Layer*()> createFunctions[] = {
@ -8,7 +39,10 @@ static std::function<Layer*()> createFunctions[] = {
CL(TemplateMapTest),
CL(ValueTest),
CL(RefPtrTest),
CL(UTFConversionTest)
CL(UTFConversionTest),
#ifdef UNIT_TEST_FOR_OPTIMIZED_MATH_UTIL
CL(MathUtilTest)
#endif
};
static int sceneIdx = -1;
@ -816,3 +850,287 @@ std::string UTFConversionTest::subtitle() const
{
return "UTF8 <-> UTF16 Conversion Test, no crash";
}
// MathUtilTest
namespace UnitTest {
#ifdef INCLUDE_NEON32
#include "math/MathUtilNeon.inl"
#endif
#ifdef INCLUDE_NEON64
#include "math/MathUtilNeon64.inl"
#endif
#ifdef INCLUDE_SSE
//FIXME: #include "math/MathUtilSSE.inl"
#endif
#include "math/MathUtil.inl"
} // namespace UnitTest {
// I know the next line looks ugly, but it's a way to test MathUtil. :)
using namespace UnitTest::cocos2d;
static void __checkMathUtilResult(const char* description, const float* a1, const float* a2, int size)
{
log("-------------checking %s ----------------------------", description);
// Check whether the result of the optimized instruction is the same as which is implemented in C
for (int i = 0; i < size; ++i)
{
bool r = fabs(a1[i] - a2[i]) < 0.00001f;//FLT_EPSILON;
if (r)
{
log("Correct: a1[%d]=%f, a2[%d]=%f", i, a1[i], i, a2[i]);
}
else
{
log("Wrong: a1[%d]=%f, a2[%d]=%f", i, a1[i], i, a2[i]);
}
CCASSERT(r, "The optimized instruction is implemented in a wrong way, please check it!");
}
}
void MathUtilTest::onEnter()
{
UnitTestDemo::onEnter();
const int MAT4_SIZE = 16;
const int VEC4_SIZE = 4;
const float inMat41[MAT4_SIZE] = {
0.234023f, 2.472349f, 1.984244f, 2.23348f,
0.634124f, 0.234975f, 6.384572f, 0.82368f,
0.738028f, 1.845237f, 1.934721f, 1.62343f,
0.339023f, 3.472452f, 1.324714f, 4.23852f,
};
const float inMat42[MAT4_SIZE] = {
1.640232f, 4.472349f, 0.983244f, 1.23343f,
2.834124f, 8.234975f, 0.082572f, 3.82464f,
3.238028f, 2.845237f, 0.331721f, 4.62544f,
4.539023f, 9.472452f, 3.520714f, 2.23252f,
};
const float scalar = 1.323298f;
const float x = 0.432234f;
const float y = 1.333229f;
const float z = 2.535292f;
const float w = 4.632234f;
const float inVec4[VEC4_SIZE] = {2.323478f, 0.238482f, 4.223783f, 7.238238f};
const float inVec42[VEC4_SIZE] = {0.322374f, 8.258883f, 3.293683f, 2.838337f};
float outMat4Opt[MAT4_SIZE] = {0};
float outMat4C[MAT4_SIZE] = {0};
float outVec4Opt[VEC4_SIZE] = {0};
float outVec4C[VEC4_SIZE] = {0};
// inline static void addMatrix(const float* m, float scalar, float* dst);
MathUtilC::addMatrix(inMat41, scalar, outMat4C);
#ifdef INCLUDE_NEON32
MathUtilNeon::addMatrix(inMat41, scalar, outMat4Opt);
#endif
#ifdef INCLUDE_NEON64
MathUtilNeon64::addMatrix(inMat41, scalar, outMat4Opt);
#endif
#ifdef INCLUDE_SSE
// FIXME:
#endif
__checkMathUtilResult("inline static void addMatrix(const float* m, float scalar, float* dst);", outMat4C, outMat4Opt, MAT4_SIZE);
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
// inline static void addMatrix(const float* m1, const float* m2, float* dst);
MathUtilC::addMatrix(inMat41, inMat42, outMat4C);
#ifdef INCLUDE_NEON32
MathUtilNeon::addMatrix(inMat41, inMat42, outMat4Opt);
#endif
#ifdef INCLUDE_NEON64
MathUtilNeon64::addMatrix(inMat41, inMat42, outMat4Opt);
#endif
#ifdef INCLUDE_SSE
// FIXME:
#endif
__checkMathUtilResult("inline static void addMatrix(const float* m1, const float* m2, float* dst);", outMat4C, outMat4Opt, MAT4_SIZE);
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
// inline static void subtractMatrix(const float* m1, const float* m2, float* dst);
MathUtilC::subtractMatrix(inMat41, inMat42, outMat4C);
#ifdef INCLUDE_NEON32
MathUtilNeon::subtractMatrix(inMat41, inMat42, outMat4Opt);
#endif
#ifdef INCLUDE_NEON64
MathUtilNeon64::subtractMatrix(inMat41, inMat42, outMat4Opt);
#endif
#ifdef INCLUDE_SSE
// FIXME:
#endif
__checkMathUtilResult("inline static void subtractMatrix(const float* m1, const float* m2, float* dst);", outMat4C, outMat4Opt, MAT4_SIZE);
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
// inline static void multiplyMatrix(const float* m, float scalar, float* dst);
MathUtilC::multiplyMatrix(inMat41, scalar, outMat4C);
#ifdef INCLUDE_NEON32
MathUtilNeon::multiplyMatrix(inMat41, scalar, outMat4Opt);
#endif
#ifdef INCLUDE_NEON64
MathUtilNeon64::multiplyMatrix(inMat41, scalar, outMat4Opt);
#endif
#ifdef INCLUDE_SSE
// FIXME:
#endif
__checkMathUtilResult("inline static void multiplyMatrix(const float* m, float scalar, float* dst);", outMat4C, outMat4Opt, MAT4_SIZE);
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
// inline static void multiplyMatrix(const float* m1, const float* m2, float* dst);
MathUtilC::multiplyMatrix(inMat41, inMat42, outMat4C);
#ifdef INCLUDE_NEON32
MathUtilNeon::multiplyMatrix(inMat41, inMat42, outMat4Opt);
#endif
#ifdef INCLUDE_NEON64
MathUtilNeon64::multiplyMatrix(inMat41, inMat42, outMat4Opt);
#endif
#ifdef INCLUDE_SSE
// FIXME:
#endif
__checkMathUtilResult("inline static void multiplyMatrix(const float* m1, const float* m2, float* dst);", outMat4C, outMat4Opt, MAT4_SIZE);
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
// inline static void negateMatrix(const float* m, float* dst);
MathUtilC::negateMatrix(inMat41, outMat4C);
#ifdef INCLUDE_NEON32
MathUtilNeon::negateMatrix(inMat41, outMat4Opt);
#endif
#ifdef INCLUDE_NEON64
MathUtilNeon64::negateMatrix(inMat41, outMat4Opt);
#endif
#ifdef INCLUDE_SSE
// FIXME:
#endif
__checkMathUtilResult("inline static void negateMatrix(const float* m, float* dst);", outMat4C, outMat4Opt, MAT4_SIZE);
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
// inline static void transposeMatrix(const float* m, float* dst);
MathUtilC::transposeMatrix(inMat41, outMat4C);
#ifdef INCLUDE_NEON32
MathUtilNeon::transposeMatrix(inMat41, outMat4Opt);
#endif
#ifdef INCLUDE_NEON64
MathUtilNeon64::transposeMatrix(inMat41, outMat4Opt);
#endif
#ifdef INCLUDE_SSE
// FIXME:
#endif
__checkMathUtilResult("inline static void transposeMatrix(const float* m, float* dst);", outMat4C, outMat4Opt, MAT4_SIZE);
// Clean
memset(outMat4C, 0, sizeof(outMat4C));
memset(outMat4Opt, 0, sizeof(outMat4Opt));
// inline static void transformVec4(const float* m, float x, float y, float z, float w, float* dst);
MathUtilC::transformVec4(inMat41, x, y, z, w, outVec4C);
#ifdef INCLUDE_NEON32
MathUtilNeon::transformVec4(inMat41, x, y, z, w, outVec4Opt);
#endif
#ifdef INCLUDE_NEON64
MathUtilNeon64::transformVec4(inMat41, x, y, z, w, outVec4Opt);
#endif
#ifdef INCLUDE_SSE
// FIXME:
#endif
__checkMathUtilResult("inline static void transformVec4(const float* m, float x, float y, float z, float w, float* dst);", outVec4C, outVec4Opt, VEC4_SIZE);
// Clean
memset(outVec4C, 0, sizeof(outVec4C));
memset(outVec4Opt, 0, sizeof(outVec4Opt));
// inline static void transformVec4(const float* m, const float* v, float* dst);
MathUtilC::transformVec4(inMat41, inVec4, outVec4C);
#ifdef INCLUDE_NEON32
MathUtilNeon::transformVec4(inMat41, inVec4, outVec4Opt);
#endif
#ifdef INCLUDE_NEON64
MathUtilNeon64::transformVec4(inMat41, inVec4, outVec4Opt);
#endif
#ifdef INCLUDE_SSE
// FIXME:
#endif
__checkMathUtilResult("inline static void transformVec4(const float* m, const float* v, float* dst);", outVec4C, outVec4Opt, VEC4_SIZE);
// Clean
memset(outVec4C, 0, sizeof(outVec4C));
memset(outVec4Opt, 0, sizeof(outVec4Opt));
// inline static void crossVec3(const float* v1, const float* v2, float* dst);
MathUtilC::crossVec3(inVec4, inVec42, outVec4C);
#ifdef INCLUDE_NEON32
MathUtilNeon::crossVec3(inVec4, inVec42, outVec4Opt);
#endif
#ifdef INCLUDE_NEON64
MathUtilNeon64::crossVec3(inVec4, inVec42, outVec4Opt);
#endif
#ifdef INCLUDE_SSE
// FIXME:
#endif
__checkMathUtilResult("inline static void crossVec3(const float* v1, const float* v2, float* dst);", outVec4C, outVec4Opt, VEC4_SIZE);
// Clean
memset(outVec4C, 0, sizeof(outVec4C));
memset(outVec4Opt, 0, sizeof(outVec4Opt));
}
std::string MathUtilTest::subtitle() const
{
return "MathUtilTest";
}

View File

@ -61,4 +61,12 @@ public:
virtual std::string subtitle() const override;
};
class MathUtilTest : public UnitTestDemo
{
public:
CREATE_FUNC(MathUtilTest);
virtual void onEnter() override;
virtual std::string subtitle() const override;
};
#endif /* __UNIT_TEST__ */

View File

@ -84,7 +84,7 @@ Controller g_aTestNames[] = {
{ "Node: Text Input", [](){return new TextInputTestScene(); } },
{ "Node: UI", [](){ return new UITestScene(); }},
{ "Mouse", []() { return new MouseTestScene(); } },
{ "MutiTouch", []() { return new MutiTouchTestScene(); } },
{ "MultiTouch", []() { return new MutiTouchTestScene(); } },
{ "Performance tests", []() { return new PerformanceTestScene(); } },
{ "Renderer", []() { return new NewRendererTestScene(); } },
{ "ReleasePool", [](){ return new ReleasePoolTestScene(); } },

View File

@ -162,6 +162,7 @@ LOCAL_SRC_FILES := main.cpp \
../../Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp \
../../Classes/PerformanceTest/PerformanceScenarioTest.cpp \
../../Classes/PerformanceTest/PerformanceCallbackTest.cpp \
../../Classes/PerformanceTest/PerformanceMathTest.cpp \
../../Classes/PhysicsTest/PhysicsTest.cpp \
../../Classes/ReleasePoolTest/ReleasePoolTest.cpp \
../../Classes/RenderTextureTest/RenderTextureTest.cpp \

View File

@ -177,6 +177,7 @@
<ClCompile Include="..\Classes\PerformanceTest\PerformanceContainerTest.cpp" />
<ClCompile Include="..\Classes\PerformanceTest\PerformanceEventDispatcherTest.cpp" />
<ClCompile Include="..\Classes\PerformanceTest\PerformanceLabelTest.cpp" />
<ClCompile Include="..\Classes\PerformanceTest\PerformanceMathTest.cpp" />
<ClCompile Include="..\Classes\PerformanceTest\PerformanceRendererTest.cpp" />
<ClCompile Include="..\Classes\PerformanceTest\PerformanceScenarioTest.cpp" />
<ClCompile Include="..\Classes\PhysicsTest\PhysicsTest.cpp" />
@ -369,6 +370,7 @@
<ClInclude Include="..\Classes\PerformanceTest\PerformanceContainerTest.h" />
<ClInclude Include="..\Classes\PerformanceTest\PerformanceEventDispatcherTest.h" />
<ClInclude Include="..\Classes\PerformanceTest\PerformanceLabelTest.h" />
<ClInclude Include="..\Classes\PerformanceTest\PerformanceMathTest.h" />
<ClInclude Include="..\Classes\PerformanceTest\PerformanceRendererTest.h" />
<ClInclude Include="..\Classes\PerformanceTest\PerformanceScenarioTest.h" />
<ClInclude Include="..\Classes\PhysicsTest\PhysicsTest.h" />

View File

@ -888,6 +888,9 @@
<ClCompile Include="..\Classes\OpenURLTest\OpenURLTest.cpp">
<Filter>Classes\OpenURLTest</Filter>
</ClCompile>
<ClCompile Include="..\Classes\PerformanceTest\PerformanceMathTest.cpp">
<Filter>Classes\PerformanceTest</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h">
@ -1634,5 +1637,8 @@
<ClInclude Include="..\Classes\OpenURLTest\OpenURLTest.h">
<Filter>Classes\OpenURLTest</Filter>
</ClInclude>
<ClInclude Include="..\Classes\PerformanceTest\PerformanceMathTest.h">
<Filter>Classes\PerformanceTest</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -119,6 +119,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceContainerTest.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceEventDispatcherTest.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceLabelTest.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceMathTest.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceNodeChildrenTest.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceParticleTest.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceRendererTest.cpp" />
@ -372,6 +373,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceContainerTest.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceEventDispatcherTest.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceLabelTest.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceMathTest.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceNodeChildrenTest.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceParticleTest.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceRendererTest.h" />

View File

@ -751,6 +751,9 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\UITest\CocoStudioGUITest\UITextFieldTest\UITextFieldTest_Editor.cpp">
<Filter>Classes\UITest\CocostudioGUISceneTest\UITextFieldTest</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceMathTest.cpp">
<Filter>Classes\PerformanceTest</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\ActionManagerTest\ActionManagerTest.cpp">
@ -1647,5 +1650,8 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\testBasic.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\PerformanceTest\PerformanceMathTest.h">
<Filter>Classes\PerformanceTest</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -235,6 +235,7 @@
<ClCompile Include="..\..\Classes\PerformanceTest\PerformanceContainerTest.cpp" />
<ClCompile Include="..\..\Classes\PerformanceTest\PerformanceEventDispatcherTest.cpp" />
<ClCompile Include="..\..\Classes\PerformanceTest\PerformanceLabelTest.cpp" />
<ClCompile Include="..\..\Classes\PerformanceTest\PerformanceMathTest.cpp" />
<ClCompile Include="..\..\Classes\PerformanceTest\PerformanceRendererTest.cpp" />
<ClCompile Include="..\..\Classes\PerformanceTest\PerformanceScenarioTest.cpp" />
<ClCompile Include="..\..\Classes\PhysicsTest\PhysicsTest.cpp" />
@ -432,6 +433,7 @@
<ClInclude Include="..\..\Classes\PerformanceTest\PerformanceContainerTest.h" />
<ClInclude Include="..\..\Classes\PerformanceTest\PerformanceEventDispatcherTest.h" />
<ClInclude Include="..\..\Classes\PerformanceTest\PerformanceLabelTest.h" />
<ClInclude Include="..\..\Classes\PerformanceTest\PerformanceMathTest.h" />
<ClInclude Include="..\..\Classes\PerformanceTest\PerformanceRendererTest.h" />
<ClInclude Include="..\..\Classes\PerformanceTest\PerformanceScenarioTest.h" />
<ClInclude Include="..\..\Classes\PhysicsTest\PhysicsTest.h" />

View File

@ -885,6 +885,9 @@
<ClCompile Include="..\..\Classes\ExtensionsTest\AssetsManagerExTest\AssetsManagerExTest.cpp">
<Filter>Classes\ExtensionsTest\AssetsManagerExLoaderScene</Filter>
</ClCompile>
<ClCompile Include="..\..\Classes\PerformanceTest\PerformanceMathTest.cpp">
<Filter>Classes\PerformanceTest</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\Classes\AppDelegate.h">
@ -1632,6 +1635,9 @@
<ClInclude Include="..\..\Classes\ExtensionsTest\AssetsManagerExTest\AssetsManagerExTest.h">
<Filter>Classes\ExtensionsTest\AssetsManagerExLoaderScene</Filter>
</ClInclude>
<ClInclude Include="..\..\Classes\PerformanceTest\PerformanceMathTest.h">
<Filter>Classes\PerformanceTest</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="$(AngleBinPath)libEGL_phone.dll" />