Talking about x multi-thread rendering

feasibility:

The game loop mainly includes these parts:

1, hardware events, mainly refers to touch screen events, key events and mouse events;

2, game events, mainly refers to timer events and predefined events, such as schedule;

3, game logic, for fat script side, this refers to the script logic;

4. The generation of rendering data refers to the node's visit in the engine. Here, all the data to be sent to OpenGL are calculated and generated, including attribute data such as vertex texture coordinates, uniform data such as transformation matrix texture, and mixed mode rendering status;

5. Send all data to OpenGL through the OpenGL interface.

Talking about x multi-thread rendering

Among these steps, only the fifth step needs to involve OpenGL operations, and the first four steps are all for the fifth step, and the fifth step does not need or need feedback data to the first four steps. This is a typical producer-consumer model that uses multi-threaded processing with very low thread synchronization overhead.

necessity:

Dealing with game logic (including the first four steps) takes too much cpu, and sending data to OpenGL is also quite time consuming, especially when it comes to multiple rendering state transitions. Separating the two on a multi-core CPU improves parallelism and improves the game's frame rate.

Some programs:

After cocos2d-x3.0 there is a big change is not rendered in the visit inside, but generate rendering commands in the visit inside, and send the command to the render class cache, waiting for an opportunity to process these commands, that is, rendering.

This is a typical command mode. As long as the data processed by these commands is not the same as the main thread (the execution thread of the game logic) or the data of the main thread is mutually exclusive by locking, the thread safety can be guaranteed. Most of the data we can generate a copy in the visit (actually draw), and for a small number of objects, each containing a large number of vertex data, we can do mutual exclusion by locking, such as particle systems. Fewer thread exclusive operations will not cause too much thread communication overhead.

The main loop of the game is also the first four steps related to the execution of the game logic, and then the conditional variable is used to tell the rendering thread that the data is ready. We can also use the double-buffer system, which creates two render command caches. When the render thread uses a command cache for rendering, the main thread logic can send render commands to another cache.

If the main thread logic really needs OpenGL processing to get some data, we can also use some of the more inefficient compromise. The main thread sends the command to the rendering thread in a manner similar to the schedule, and then waits. The rendering thread maintains a queue of such commands. The queue is prioritized in each cycle, and the main thread is notified after the processing is completed. This practice is not easy to use.

As an example, the operation of creating a texture synchronously and generating a sprite, this part of generating the texture needs to be put into the rendering thread, this can use this scheme. In fact, the game logic does not need to care about this texture in the end, the main thread can not wait until the rendering thread to complete the texture and then continue to run, the rendering thread after processing the completion of the texture, through the schedule to inform the main thread, the main thread to update this Texture2d object texture ID can be, greatly improving efficiency.

All In One Business Computer

All In One Business Computer is the one of the important All In One PC series, can meet all enter and normal business application scenarios. Therefore, more and more clients choose and recommend this Business All In One Computer for business or education projects. The Best All In One Computer For Business is the similar Apple design, competitive and attractive, the hottest parameters is 19 or 21.5 inch intel i3 or i5 2th or 3th or 4th 4 gb ram 128GB ssd . There are many other all In One Computers For Business with lighter weight. Of course, you can see Colorful All In One Gaming PC, All In One Desktop Touch Screen and All In One Business Pc. Believe you can always find the right one at this store. To save time, You can also contact us by email or calling directly to get matched and valuable information fast.


Any other special configuration interest, also feel free to let us know, will try our best to back you up.

Except all in one Custom All In One PC, 14 inch Education Laptop and 15.6 inch business laptop also available here.


All In One Business Computer,Business All In One Computer,Best All In One Computer For Business,all In One Computers For Business,All In One Business Pc

Henan Shuyi Electronics Co., Ltd. , https://www.shuyioemelectronics.com