05 optimization of cocos2d-x games on x86 architecture
DESCRIPTION
zhuoshi sun (intel)TRANSCRIPT
1
Software Service Group
Optimization Notice
2
Software Service Group
Legal Disclaimer INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL
OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL'S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
A "Mission Critical Application" is any application in which failure of the Intel Product could result, directly or indirectly, in personal injury or death. SHOULD YOU PURCHASE OR USE INTEL'S PRODUCTS FOR ANY SUCH MISSION CRITICAL APPLICATION, YOU SHALL INDEMNIFY AND HOLD INTEL AND ITS SUBSIDIARIES, SUBCONTRACTORS AND AFFILIATES, AND THE DIRECTORS, OFFICERS, AND EMPLOYEES OF EACH, HARMLESS AGAINST ALL CLAIMS COSTS, DAMAGES, AND EXPENSES AND REASONABLE ATTORNEYS' FEES ARISING OUT OF, DIRECTLY OR INDIRECTLY, ANY CLAIM OF PRODUCT LIABILITY, PERSONAL INJURY, OR DEATH ARISING IN ANY WAY OUT OF SUCH MISSION CRITICAL APPLICATION, WHETHER OR NOT INTEL OR ITS SUBCONTRACTOR WAS NEGLIGENT IN THE DESIGN, MANUFACTURE, OR WARNING OF THE INTEL PRODUCT OR ANY OF ITS PARTS.
Intel may make changes to specifications and product descriptions at any time, without notice. Designers must not rely on the absence or characteristics of any features or instructions marked "reserved" or "undefined". Intel reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them. The information here is subject to change without notice. Do not finalize a design with this information. The products described in this document may contain design defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request.
Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark and MobileMark, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products.
Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order. Copies of documents which have an order number and are referenced in this document, or other Intel literature, may be obtained by calling 1-800-548-4725, or go to: http://www.intel.com/design/literature.htm
Intel, the Intel logo, Intel Atom, Intel Core are trademarks of Intel Corporation in the U.S. and other countries.
*Other names and brands may be claimed as the property of others.
Copyright © 2012. Intel Corporation.
3
Software Service Group
x86架构上基于cocos2d-x的游戏开发与优化
孙卓识,郭胜
2012.03.31
4
Software Service Group
日程
合作历史
x86上的cocos2d-x游戏开发
– Android x86
x86上的cocos2d-x游戏优化
– 《捕鱼达人》
– Intel® VTune™性能分析器
– Intel®图形性能分析器(GPA)
下一步
5
Software Service Group
合作历史
11.05
cocos2d-x MeeGo
添加了Android x86支持
《捕鱼达人》支持Android x86
《捕鱼达人》优化
cocos2d-x优化
6
Software Service Group
Android x86 -真的很简单
使用NDK r6b及更高版本
打开android/jni/Application.mk
APP_ABI := x86
或者
APP_ABI := armeabi x86
发布打包
一个apk包同时支持多种CPU架构
7
Software Service Group
《捕鱼达人》Android x86
环境:Medfield平板, Android 4.0.3
8
Software Service Group
《捕鱼达人》Android x86性能分析
关闭垂直同步(vsync)
结论
– GPU是瓶颈
可优化内容
– 减少应用alpha blending
– 减小纹理尺寸与数量
Experiments Normal Disable Draw Calls
1x1 Scissor Rect
2x2 Texture
Simple Fragment Shader
Disable Z-Test
Disable Alpha Blending
FPS 50 75 70 62 50 50 69
9
Software Service Group
《捕鱼达人》(Windows)优化前
10
Software Service Group
《捕鱼达人》(Windows)优化后
11
Software Service Group
《捕鱼达人》(Windows)优化对比
FPS提升:15%左右
Function CPU Time CPU Time
cocos2d::CCMutableDictionary<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class SPActor *>::allKeys 17.70% 0%
cocos2d::CCMutableDictionary<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class SPActor *>::objectForKey 17.00% 0%
cocos2d::CCMutableDictionary<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class SPActor *>::next 0.00% 6.30%
glColorMask 11.00% 18.80% SPScene::getActors 8.10% 3.40%
cocos2d::CCMutableDictionary<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class cocos2d::CCTexture2D *>::objectForKey 5.60% 9.20%
cocos2d::CCMutableDictionary<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class cocos2d::CCTexture2D *>::allKeys 5.00% 8.60%
GuiAddVertexShaderInfo 4.90% 7.90% cocos2d::CCUserDefault::isXMLFileExist 3.90% 6.00% split 3.70% 5.90%
12
Software Service Group
Cocos2d-x(Windows)优化前
13
Software Service Group
Cocos2d-x(Windows)优化后
14
Software Service Group
Cocos2d-x(Windows)优化对比 Function CPU Time CPU Time Module
glColorMask 15.60% 20.00% libGLES_CM.dll
cocos2d::CCMutableDictionary<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class cocos2d::CCTexture2D *>::allKeys 8.70% 0.00% libcocos2d.dll
cocos2d::CCMutableDictionary<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class cocos2d::CCTexture2D *>::objectForKey 8.50% 0.00% libcocos2d.dll
cocos2d::CCMutableDictionary<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class cocos2d::CCTexture2D *>::next 0.00% 2.90% libcocos2d.dll
GuiAddVertexShaderInfo 7.60% 8.90% libEGL.dll
split 6.80% 7.70% FishingJoy_mobile.exe
cocos2d::CCMutableDictionary<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class SPActor *>::next 6.40% 8.20% FishingJoy_mobile.exe
xmlCleanupOutputCallbacks 5.60% 6.50% libxml2.dll
cocos2d::CCUserDefault::isXMLFileExist 5.60% 6.20% libcocos2d.dll
SPGameObject::getGroup 4.20% 5.10% FishingJoy_mobile.exe
SPScene::getActors 3.60% 4.30% FishingJoy_mobile.exe
优化后FPS提升:20%左右
15
Software Service Group
优化代码
16
Software Service Group
优化小结
优化方案可能很简单,定位很关键
对待优化的态度
工具很重要
17
Software Service Group
Intel® VTune™性能分析器
主要特性
– 性能热点分析
– 并发分析
– 锁分析
操作简单
无须源码
支持Windows, Linux
IDE集成
30天免费试用
18
Software Service Group
Intel®图形性能分析器(GPA)
免费
– www.intel.com/software/GPA
支持Android x86
帧分析器 平台分析器
系统分析器(HUD)
19
Software Service Group
下一步:Android x86移动设备
Lenovo 手机
Lenovo 平板
Lava (印度), 中兴通讯,
Orange ( 欧洲) Motorola 手机
20
Software Service Group
下一步:Ultrabook
更轻,更薄,更长的续航时间,更快的响应速度
触摸支持*
加速度计,GPS等感应器*支持
近场通信支持*
*Recommended, not required
21
Software Service Group
Q & A
我们提供
– 开发样机支持
– 技术支持
– 应用工程师支持
联系方式
– 客户经理: 陈景伟
电话:130 1109 1109, 电邮:[email protected]
– 应用工程师:孙卓识
电话:186 1651 3251, 电邮:[email protected]
谢谢!
问题?
22
Software Service Group
Backup
23
Software Service Group
VTune™ Call Stack