Module: Mesa
Branch: main
Commit: 2b7dfd8de1a4db10aaf18046b97a52240336fe8d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b7dfd8de1a4db10aaf18046b97a52240336fe8d

Author: Erik Faye-Lund <[email protected]>
Date:   Wed Aug 10 11:16:28 2022 +0200

mesa: add _mesa_unpack_bptc-function

Acked-by: Marek Olšák <[email protected]>
Acked-by: Soroush Kashani <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18012>

---

 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 <stdbool.h>
 #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

Reply via email to