diff --git a/include/bx/inline/pixelformat.inl b/include/bx/inline/pixelformat.inl index 8a271d5..2dc17d3 100644 --- a/include/bx/inline/pixelformat.inl +++ b/include/bx/inline/pixelformat.inl @@ -31,6 +31,23 @@ namespace bx return max(-1.0f, float(_value) / _scale); } + // A8 + inline void packA8(void* _dst, const float* _src) + { + uint8_t* dst = (uint8_t*)_dst; + dst[0] = uint8_t(toUnorm(_src[3], 255.0f) ); + } + + inline void unpackA8(float* _dst, const void* _src) + { + const uint8_t* src = (const uint8_t*)_src; + const float aa = fromUnorm(src[0], 255.0f); + _dst[0] = aa; + _dst[1] = aa; + _dst[2] = aa; + _dst[3] = aa; + } + // R8 inline void packR8(void* _dst, const float* _src) { @@ -47,22 +64,6 @@ namespace bx _dst[3] = 1.0f; } - // A8 - inline void packA8(void* _dst, const float* _src) - { - uint8_t* dst = (uint8_t*)_dst; - dst[0] = uint8_t(toUnorm(_src[3], 255.0f)); - } - - inline void unpackA8(float* _dst, const void* _src) - { - const uint8_t* src = (const uint8_t*)_src; - _dst[0] = fromUnorm(src[0], 255.0f); - _dst[1] = 0.0f; - _dst[2] = 0.0f; - _dst[3] = _dst[0]; - } - // R8S inline void packR8S(void* _dst, const float* _src) { diff --git a/include/bx/pixelformat.h b/include/bx/pixelformat.h index c75b398..7cb8763 100644 --- a/include/bx/pixelformat.h +++ b/include/bx/pixelformat.h @@ -41,6 +41,10 @@ namespace bx /// float fromSnorm(int32_t _value, float _scale); + // A8 + void packA8(void* _dst, const float* _src); + void unpackA8(float* _dst, const void* _src); + // R8 void packR8(void* _dst, const float* _src); void unpackR8(float* _dst, const void* _src);