Skip to content

WIP: Add a format for float16 RGBA images

Adam Jackson requested to merge ajax/pixman:fp16 into master

Starting from the float32 support, add some accesssors to expand and compact the image to and from float16. All the internal math is in terms of the float32 wide pipeline. You probably don't want to do much with such an image other than blit it around. But that's fine, the point is just to have the ability to store such a format in a pixman_image to allow upper layers to use pixman for all image formats.

The conversion code here is stolen from Mesa, and makes no attempt to be fast. It's also quite ugly to have a copy of it in both pixman/ and test/; suggestions welcome.

If you wanted to do better and you're on x86, the f16c extension (of approximately 2011 vintage) lets you convert to/from vectors of float16 and float32. You'd still be operating in float32 internally, but the load and store would hopefully be much faster.

If you wanted to do better and your compiler supports _Float16 as a native data type you could just, like, use that. At the moment that means gcc and either arm64 or arm32 + -mfp16-format=ieee. This might be slightly risky (in a performance sense) if any of the primitive operations are implemented as library calls, but one hopes your compiler wouldn't implement _Float16 if it needed to do that very often.

Edited by Adam Jackson

Merge request reports