What are draw calls(绘制命令) and what are batches(批)

Resolution

It is important to know what are draw calls and what are batches. A draw call is a call to the graphics API to draw objects (e.g draw a triangle), while a batch is a group of draw calls to be drawn together. Batching objects to be drawn together, minimizes the state changes needed to draw each object inside the batch. This is turn leads to improved performance by reducing the CPU cost of rendering the objects.

Unity groups in batches the objects to be drawn in two ways: Dynamic Batching and Static Batching. Only objects that share properties like textures or materials can be batched together.

Static batching is the recommended(推荐的) batching technique(技巧) for objects that do not move and it render batched objects very fast. It has a trade off(trade off 权衡) regarding memory, as the meshes need to be combined into a single larger mesh, which is made of the union(并集) of all the smaller individual(个体) meshes in the scene that are marked as static and meet the criteria(标准) to be batched together. To do static batching, you need your objects to be static, thus mark them as static in the inspector.

Dynamic batching on the other hand, tries to optimize the way non-static objects are rendered, by this transforming their vertices on the CPU, grouping many similar vertices together, and drawing them all in one go. It's limited to small meshes, as batching larger meshes dynamically is more expensive than not batching them.

To learn more about how to batch objects or what are draw calls please see the official documentation here.

posted on 2019-09-09 09:37  Sweet小马  阅读(230)  评论(0编辑  收藏  举报

导航