SFTtech / openage

Free (as in freedom) open source clone of the Age of Empires II engine 🚀
http://openage.dev
Other
12.63k stars 1.11k forks source link

Speed up converter texture packing with Cython #1371

Open heinezen opened 3 years ago

heinezen commented 3 years ago

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() and factor(), 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:

You can test your changes with the singlefile media converter.

Further Reading

fabiobarkoski commented 1 month ago

Looking in the binpack.pyx history, seems that the converter already received some speed up improvement

heinezen commented 1 month ago

@fabiobarkoski It has been converted to Cython but none of the points in the ssue have been solved completely afaik.

fabiobarkoski commented 1 month ago

Can I try to work on it? But I'll need some guidance :)

heinezen commented 1 month ago

You absolutely can :) Although it might be a bit harder than medium difficulty if you don't work with Cython much. Just saying :D