pnggroup / libpng

LIBPNG: Portable Network Graphics support, official libpng repository
http://libpng.sf.net
Other
1.25k stars 611 forks source link

powerpc VSX acceleration could be tweaked for AltiVec/VMX #192

Open classilla opened 6 years ago

classilla commented 6 years ago

I'm testing a version in TenFourFox that tweaks the VSX code to run under AltiVec/VMX (there are some missing intrinsics and it's always BE, but otherwise it mostly "just worked"). Is there interest in this? If so, I can upstream it. See classilla/tenfourfox#448 for the changes; I kept the VMX stuff in separate files though it may be possible to merge them.

barkovv commented 6 years ago

I am not sure that you need separate file for VMX version. The only intrin in "filter_vsx_intrinsics.c" which is missing in VMX is vec_vsx_ld (which is wrapped with "vec_ld_unaligned"). As far as I understand the only thing you need to do is to define it to your VMX version. Ofcource you can introduce some switch similar to Intel's SSE logic (e.g PNG_POWERPC_VSX_OPT == 1 for VMX and PNG_POWERPC_VSX_OPT ==2 for VSX) .

classilla commented 6 years ago

No, that would probably work too (I just did this for simplicity). Everything else worked; I just changed the names since I wasn't sure initially if I need to make other adjustments (I didn't). For vec_ld_unaligned, I used this:

#define vec_ld_unaligned(v,s) { v=vec_perm(vec_ld(0,s),vec_ld(16,s),vec_lvsl(0,s)); }

It doesn't look like vec_st_unaligned is used anywhere.