Architectural Design of The cocos2d-x-3.0 cocos2d (v.3.0) rendering pipeline Roadmap)

Source: Internet
Author: User

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 labels on most modern tablets and mobile phones.

So we want to RE design Cocos Renderer, for making it more faster Ming, 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 wowould 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 CILS) 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 CES the number of draw CALS (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, lemo-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 won the number of draw CILS and render device state changes will improve drastically rendering speed.

In order to achieve very good batching, We wocould 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

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 locking Ming 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 CILS 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

Architectural Design of The cocos2d-x-3.0 cocos2d (v.3.0) rendering pipeline Roadmap)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.