cocos / cocos-engine

Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
https://www.cocos.com/en/creator
Other
8.88k stars 2.06k forks source link

Optimize dynamic atlas packing strategy #11196

Open jareguo opened 2 years ago

jareguo commented 2 years ago

Use Case

all games

Problem Description

https://forum.cocos.org/t/topic/135586 Many users complained about the poor space utilization of the dynamic atlas packing.

Proposed Solution

A solution from 乐府 https://forum.cocos.org/t/topic/98157

  1. 参考乐府帖子 4.1,允许回收纹理时合图空间也跟着释放
  2. 采用分帧合图,逐步降低 drawcall,不要求一次性合完,每一帧合并一张纹理
  3. 参考帖子 4.3 对 待合并的纹理采用排序策略,优先合并小图、尺寸规整的图、低频改动的图(如 UI 背景),最大化合图收益
  4. 优化空间分配算法,允许图片旋转,确保空间充分利用。由于采用分帧合图,性能上应该不会比之前差很多。

  5. Refer to the post 4.1 of 乐府, allow the texture to be recycled and the space to be released
  6. Use frame-by-frame merging to gradually reduce the drawcall, not requiring a one-time merge, and merging one texture per frame
  7. Refer to the post 4.3 to adopt a ranking strategy for the textures to be merged, prioritizing the merging of small, regular-sized, and low-frequency altered images (such as UI backgrounds) to maximize the merging benefit
  8. optimize the space allocation algorithm and allow image rotation to ensure full utilization of space. Due to the use of frame-split merging, the performance should not be much worse than before.

How it works

No response

Alternatives Considered

nothing

Additional Information

No response

LinYunMo commented 1 year ago

https://forum.cocos.org/t/topic/143973 关于释放的反馈