pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
766 stars 120 forks source link

SIMD for image.tobytes() #2956

Open Starbuck5 opened 5 days ago

Starbuck5 commented 5 days ago

image.tobytes() has some great opportunities for SIMD acceleration.

It currently has an old SIMD backend that never builds because it is from before we learned how to do dynamic dispatch.

I think there are things in SSE3 that would be helpful here (better shuffle instructions), so maybe this one could use a SSE3 (or higher SSE) backend and an AVX2 backend, instead of our typical SSE2/AVX2 combination.

image.tobytes() being faster would help people using it to stream their surfaces into textures, so it could help a few people out noticeably.

ankith26 commented 4 days ago

This is worth investigating, and this is actually a duplicate of #1154