MyException - 我的异常网
当前位置:我的异常网» 操作系统 » Cocos2d (v.3.0) rendering pipeline road地图

Cocos2d (v.3.0) rendering pipeline road地图

www.MyException.Cn  网友分享于:2013-09-29  浏览:8次
Cocos2d (v.3.0) rendering pipeline roadmap

Why (the vision)

 


The way currently Cocos2d does rendering is good but it is beginning to feel somehow antiquate and moreover it doesn’t actually leverage modern multi core CPUs so popular nowadays on most modern tablets and mobile phones.

So we want to re design Cocos renderer, for making it more performing, elegant, scalable, flexible but still simple to use and to understand. Also we want to maintain that same familiar API that current Cocos2d users will feel immediately comfortable with, without having to bother about what’s changed or new under the hood.

We will do this maintaining the same key cornerstone concepts Cocos2d users get to know and like as Scenes, Nodes, Layers, Sprites.  




What (the goals)

 

Here is a high level view of the new features and improvements we would like to achieve in Cocos2d v.3.0:

 

Decouple the scene graph from the renderer

Visiting nodes issues graphics commands and put them on a queue, but doesn’t actually invoke any OpenGL rendering code  

 

Viewing frustum Geometry culling

Sprites (and geometries more in general) not visible from the camera’s point of view be automatically removed from the current frame and not rendered

 

Rendering on a thread

The execution of all the rendering commands (i.e. OpenGL calls) will be moved to different thread than the main one (this will allow for better parallelism and usage of more than one CPUs cores where possible)

 

Automatic batching

Efficiently reduces the number of draw calls (automatically) batching them together when possible (i.e. sprites using the same material)

 

(Node based) Customizable rendering

As in the current version of Cocos, users will still be able (if needed) to customize rendering on a per node basis, calling OpenGL commands directly, disregarding the official renderer (but possibly incurring on worst performances)




How (the plan)


Central to the new design is the notion CommandQueue. While visiting a node, rendering will not call OpenGL commands directly anymore (as currently is the case); it will instead push CocosGraphicsCommands to a queue. Commands In the queue will subsequently be read by the rendering backend, processed as needed and pushed to the actual rendering API (i.e. OpenGL) (see picture)



 
The rendering backend (running on his own thread) will in turn pop graphics commands from the queue, process them and actually execute them. Any locking or CPU expensive OpenGL commands will be then executed from the back-end thread, letting Cocos’ main thread free continue working on parsing the scene graph or doing other non rendering related tasks. This will help parallelism and will allow for using multi core CPU’s (see picture)



 
With Cocos2d-x 3.00 we also want to introduce the concept of automatic batching.  In fact we believe reducing the number of draw calls and render device state changes will improve drastically rendering speed.

In order to achieve very good batching, we would like to introduce also a new concept of “attributes” for Layers (formally CCLayer). There are going to (at least) 3 new Layer attributes:

 

  • Unordered

  • Static

  • Batch



Unordered Layer (formally CCLayer)



We want now focus on Unordered Layers, which are going to help achieving auto batching for improving rendering performance.

Rendering order in Cocos2d is dictated by the “order” nodes are arranged in the scene graph (see picture)



 
This is still going to be true still in V.3.0 unless the Layer is tagged as Unordered.

The Unordered attribute will instruct the Layer to disregard rendering order for all of his children (see picture)



 
The graphics commands will then be put in the CommandQueue and a special “unordered tag” will be place in the command queue as well for instructing the rendered to disregard the order and re arrange graphics commands so to render all the primitives using the same material in one draw call. Rendering all primitives (that use the same “material”) in one go will make rendering much faster, especially on mobile devices.



Static Layer

 

Layers tagged as static, will be treated as if all children will not going to be translated/rotated/zoomed (transformed) during the entire lifespan of the layer. This will allow Cocos performing expensive operations as matrices concatenation or computing culling information (i.e. quad-tree) only once (typically before the first rendering pass) improving drastically performance. Note that sprites in a static Layer can still be “animated” as far as they’re not transformed or scaled.



Batch Layer

 

A batch layers will behave very similarly to how a Batch Node (CCBatchNode) currently works in Cocos2d. All the children of a batch layer will HAVE to use the same “material” thus allowing the front end to combine all the draw calls for that layer in one single one. (Erroneously) Adding children that use a different material to a Batch Layer will trigger an Assert ().



Automatic Culling

 

To do



Rendering context (RenderBucket, RenderTarget, Camera, viewport)

 

To do



Rendering and materials system

 

To do



Customize rendering for nodes

To do

 

转载:https://docs.google.com/document/d/1nDX131S-k_XwKHkh7CjP4yC4pmywLk8Do3kMtyrRYwI/edit?pli=1

文章评论

程序员的一天:一寸光阴一寸金
程序员的一天:一寸光阴一寸金
Java程序员必看电影
Java程序员必看电影
十大编程算法助程序员走上高手之路
十大编程算法助程序员走上高手之路
老程序员的下场
老程序员的下场
科技史上最臭名昭著的13大罪犯
科技史上最臭名昭著的13大罪犯
总结2014中国互联网十大段子
总结2014中国互联网十大段子
看13位CEO、创始人和高管如何提高工作效率
看13位CEO、创始人和高管如何提高工作效率
程序员周末都喜欢做什么?
程序员周末都喜欢做什么?
旅行,写作,编程
旅行,写作,编程
60个开发者不容错过的免费资源库
60个开发者不容错过的免费资源库
程序员应该关注的一些事儿
程序员应该关注的一些事儿
我的丈夫是个程序员
我的丈夫是个程序员
不懂技术不要对懂技术的人说这很容易实现
不懂技术不要对懂技术的人说这很容易实现
写给自己也写给你 自己到底该何去何从
写给自己也写给你 自己到底该何去何从
“肮脏的”IT工作排行榜
“肮脏的”IT工作排行榜
那些争议最大的编程观点
那些争议最大的编程观点
当下全球最炙手可热的八位少年创业者
当下全球最炙手可热的八位少年创业者
什么才是优秀的用户界面设计
什么才是优秀的用户界面设计
程序员最害怕的5件事 你中招了吗?
程序员最害怕的5件事 你中招了吗?
做程序猿的老婆应该注意的一些事情
做程序猿的老婆应该注意的一些事情
程序猿的崛起——Growth Hacker
程序猿的崛起——Growth Hacker
老美怎么看待阿里赴美上市
老美怎么看待阿里赴美上市
每天工作4小时的程序员
每天工作4小时的程序员
一个程序员的时间管理
一个程序员的时间管理
程序员眼里IE浏览器是什么样的
程序员眼里IE浏览器是什么样的
 程序员的样子
程序员的样子
Web开发者需具备的8个好习惯
Web开发者需具备的8个好习惯
10个帮程序员减压放松的网站
10个帮程序员减压放松的网站
聊聊HTTPS和SSL/TLS协议
聊聊HTTPS和SSL/TLS协议
程序员都该阅读的书
程序员都该阅读的书
程序员的鄙视链
程序员的鄙视链
如何成为一名黑客
如何成为一名黑客
10个调试和排错的小建议
10个调试和排错的小建议
编程语言是女人
编程语言是女人
程序员和编码员之间的区别
程序员和编码员之间的区别
Java 与 .NET 的平台发展之争
Java 与 .NET 的平台发展之争
我是如何打败拖延症的
我是如何打败拖延症的
漫画:程序员的工作
漫画:程序员的工作
中美印日四国程序员比较
中美印日四国程序员比较
如何区分一个程序员是“老手“还是“新手“?
如何区分一个程序员是“老手“还是“新手“?
为啥Android手机总会越用越慢?
为啥Android手机总会越用越慢?
我跳槽是因为他们的显示器更大
我跳槽是因为他们的显示器更大
程序员必看的十大电影
程序员必看的十大电影
团队中“技术大拿”并非越多越好
团队中“技术大拿”并非越多越好
“懒”出效率是程序员的美德
“懒”出效率是程序员的美德
软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有