Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up converter texture packing with Cython #1671

Conversation

fabiobarkoski
Copy link
Contributor

@fabiobarkoski fabiobarkoski commented Aug 7, 2024

Improve texture converter performance with Cython

resolve: #1371

Copy link
Member

@heinezen heinezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey looks good for now. I think you got the basics of Cython right. What would be your next steps?

openage/convert/service/export/png/binpack.pyx Outdated Show resolved Hide resolved
openage/convert/service/export/png/binpack.pyx Outdated Show resolved Hide resolved
openage/convert/service/export/png/binpack.pyx Outdated Show resolved Hide resolved
openage/convert/service/export/png/binpack.pyx Outdated Show resolved Hide resolved
@fabiobarkoski
Copy link
Contributor Author

I think you got the basics of Cython right

Is there anything that I could improve?

What would be your next steps?

I'll try to make the additional optimizations

@heinezen heinezen linked an issue Sep 29, 2024 that may be closed by this pull request
3 tasks
@heinezen
Copy link
Member

@fabiobarkoski I think from a perspective of cythonization of the members and variables, the code is already pretty optimized. We now can only gain more speed with design changes to the code.

I think that this idea from the issue might be worth a try:

Currently pack() gets passed a list of frame objects, but technically only width, height and index of a frame are needed.

The idea here being is that pack doesn't get a list of TextureImage (i.e. members named block in the code) but a list that only contains a tuple of (width, height) and then only operates on that. This would also require that we use the block index in self.mapping instead of hashing the block itself.

@fabiobarkoski fabiobarkoski force-pushed the feature/speed-up-converter-texture-packing branch 2 times, most recently from 6fefdb4 to e227a43 Compare November 25, 2024 20:08
@fabiobarkoski fabiobarkoski marked this pull request as ready for review November 25, 2024 20:17
@fabiobarkoski fabiobarkoski changed the title [WIP] Speed up converter texture packing with Cython Speed up converter texture packing with Cython Nov 25, 2024
@heinezen
Copy link
Member

I'll start the review now.

Copy link
Member

@heinezen heinezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already pretty good, I just had a few ideas for the code and extra C++ types.

openage/convert/service/export/png/binpack.pyx Outdated Show resolved Hide resolved
openage/convert/processor/export/texture_merge.pyx Outdated Show resolved Hide resolved
openage/convert/processor/export/texture_merge.pyx Outdated Show resolved Hide resolved
openage/convert/processor/export/texture_merge.pyx Outdated Show resolved Hide resolved
openage/convert/service/export/png/binpack.pyx Outdated Show resolved Hide resolved
@fabiobarkoski fabiobarkoski force-pushed the feature/speed-up-converter-texture-packing branch 2 times, most recently from 060817f to ea3ccac Compare December 4, 2024 12:10
Copy link
Member

@heinezen heinezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, the imports are the last thing that needs changing.

openage/convert/processor/export/texture_merge.pyx Outdated Show resolved Hide resolved
openage/convert/processor/export/texture_merge.pxd Outdated Show resolved Hide resolved
@fabiobarkoski fabiobarkoski force-pushed the feature/speed-up-converter-texture-packing branch 2 times, most recently from 51925f1 to b5aef1b Compare December 8, 2024 00:49
@heinezen heinezen force-pushed the feature/speed-up-converter-texture-packing branch from b5aef1b to ceefb23 Compare December 8, 2024 12:10
Copy link
Member

@heinezen heinezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a tiny change myself after testing locally. Well done!

cythonized more the texture packing, also changed the
list passed to factor(), before was a list of frame objects, now
a list of only width, height and index of the frames.
@heinezen heinezen force-pushed the feature/speed-up-converter-texture-packing branch from ceefb23 to e04eafa Compare December 8, 2024 12:10
@heinezen heinezen merged commit 0f20032 into SFTtech:master Dec 8, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Speed up converter texture packing with Cython
2 participants