Speed up converter texture packing with Cython #1371
Labels
area: assets
Involved with assets (images, sounds, ...)
good first issue
Suitable for newcomers
improvement
Enhancement of an existing component
lang: cython
Implemented using Cython code
Required skills: Cython
Difficulty: Medium
Animation frames from AoE2 graphics files are packed into a texture atlas by the openage converter. We use bin packing to find the optimal arrangement (= smallest atlas dimensions) of the frames in the atlas. Bin packing becomes computationally intensive if a lot of frames are packed (looking at you Definitive Edition), so we want to optimize the algorithm as much as possible.
The goal of this issue is to speed up the bin packing implemented here using Cython. The most important methods to cythonize are
pack()
andfactor()
, since they are responsible for the packing logic. Ideally, these functions should contain as little Python overhead as possible.Additional optimization might be possible such as:
pack()
gets passed a list of frame objects, but technically only width, height and index of a frame are needed.factor()
texture_merge.pyx
, the function initiating the binpacking, could also use optimization for merging the individual frames into the atlas using the packer settings.You can test your changes with the singlefile media converter.
Further Reading
The text was updated successfully, but these errors were encountered: