From 2b7dfd8de1a4db10aaf18046b97a52240336fe8d Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 10 Aug 2022 11:16:28 +0200 Subject: [PATCH] mesa: add _mesa_unpack_bptc-function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Acked-by: Marek Olšák Acked-by: Soroush Kashani Part-of: --- src/mesa/main/texcompress_bptc.c | 34 ++++++++++++++++++++++++++++++++ src/mesa/main/texcompress_bptc.h | 9 +++++++++ 2 files changed, 43 insertions(+) diff --git a/src/mesa/main/texcompress_bptc.c b/src/mesa/main/texcompress_bptc.c index 70dc37d8897..d3269bf1a3b 100644 --- a/src/mesa/main/texcompress_bptc.c +++ b/src/mesa/main/texcompress_bptc.c @@ -26,6 +26,8 @@ * GL_ARB_texture_compression_bptc support. */ +#define BPTC_BLOCK_DECODE + #include #include "texcompress.h" #include "texcompress_bptc.h" @@ -241,3 +243,35 @@ _mesa_texstore_bptc_rgb_unsigned_float(TEXSTORE_PARAMS) srcAddr, srcPacking, false /* unsigned */); } + +void +_mesa_unpack_bptc(uint8_t *dst_row, + unsigned dst_stride, + const uint8_t *src_row, + unsigned src_stride, + unsigned src_width, + unsigned src_height, + mesa_format format) +{ + switch (format) { + case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT: + decompress_rgb_float(src_width, src_height, + src_row, src_stride, + (float *)dst_row, dst_stride, + true); + break; + + case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT: + decompress_rgb_float(src_width, src_height, + src_row, src_stride, + (float *)dst_row, dst_stride, + false); + break; + + default: + decompress_rgba_unorm(src_width, src_height, + src_row, src_stride, + dst_row, dst_stride); + break; + } +} diff --git a/src/mesa/main/texcompress_bptc.h b/src/mesa/main/texcompress_bptc.h index 814548e2bcc..f02b891d2f1 100644 --- a/src/mesa/main/texcompress_bptc.h +++ b/src/mesa/main/texcompress_bptc.h @@ -41,4 +41,13 @@ _mesa_texstore_bptc_rgb_unsigned_float(TEXSTORE_PARAMS); compressed_fetch_func _mesa_get_bptc_fetch_func(mesa_format format); +void +_mesa_unpack_bptc(uint8_t *dst_row, + unsigned dst_stride, + const uint8_t *src_row, + unsigned src_stride, + unsigned src_width, + unsigned src_height, + mesa_format format); + #endif