util: Explicitly call the unpack functions from inside bptc pack/unpack.
[mesa.git] / src / util / format / u_format_bptc.c
index 2d02e11f48b0ce10d15895657c52ac3a4f461d03..337097465710cce84edf8da9e37302a6376cd3c8 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "util/format/u_format.h"
 #include "util/format/u_format_bptc.h"
+#include "u_format_pack.h"
 #include "util/format_srgb.h"
 #include "util/u_math.h"
 
@@ -52,7 +53,7 @@ util_format_bptc_rgba_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
 }
 
 void
-util_format_bptc_rgba_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+util_format_bptc_rgba_unorm_unpack_rgba_float(void *dst_row, unsigned dst_stride,
                                               const uint8_t *src_row, unsigned src_stride,
                                               unsigned width, unsigned height)
 {
@@ -61,10 +62,10 @@ util_format_bptc_rgba_unorm_unpack_rgba_float(float *dst_row, unsigned dst_strid
    decompress_rgba_unorm(width, height,
                          src_row, src_stride,
                          temp_block, width * 4 * sizeof(uint8_t));
-   util_format_read_4f(PIPE_FORMAT_R8G8B8A8_UNORM,
-                       dst_row, dst_stride,
-                       temp_block, width * 4 * sizeof(uint8_t),
-                       0, 0, width, height);
+   util_format_r8g8b8a8_unorm_unpack_rgba_float(
+                      dst_row, dst_stride,
+                      temp_block, width * 4 * sizeof(uint8_t),
+                      width, height);
    free((void *) temp_block);
 }
 
@@ -75,10 +76,10 @@ util_format_bptc_rgba_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
 {
    uint8_t *temp_block;
    temp_block = malloc(width * height * 4 * sizeof(uint8_t));
-   util_format_read_4ub(PIPE_FORMAT_R32G32B32A32_FLOAT,
+   util_format_r32g32b32a32_float_unpack_rgba_8unorm(
                         temp_block, width * 4 * sizeof(uint8_t),
-                        src_row, src_stride,
-                        0, 0, width, height);
+                        (uint8_t *)src_row, src_stride,
+                        width, height);
    compress_rgba_unorm(width, height,
                        temp_block, width * 4 * sizeof(uint8_t),
                        dst_row, dst_stride);
@@ -86,7 +87,7 @@ util_format_bptc_rgba_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
 }
 
 void
-util_format_bptc_rgba_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_rgba_unorm_fetch_rgba(void *dst, const uint8_t *src,
                                              unsigned width, unsigned height)
 {
    uint8_t temp_block[4];
@@ -94,10 +95,10 @@ util_format_bptc_rgba_unorm_fetch_rgba_float(float *dst, const uint8_t *src,
    fetch_rgba_unorm_from_block(src + ((width * sizeof(uint8_t)) * (height / 4) + (width / 4)) * 16,
                                temp_block, (width % 4) + (height % 4) * 4);
 
-   util_format_read_4f(PIPE_FORMAT_R8G8B8A8_UNORM,
-                       dst, 4 * sizeof(float),
-                       temp_block, 4 * sizeof(uint8_t),
-                       0, 0, 1, 1);
+   util_format_read_4(PIPE_FORMAT_R8G8B8A8_UNORM,
+                      dst, 4 * sizeof(float),
+                      temp_block, 4 * sizeof(uint8_t),
+                      0, 0, 1, 1);
 }
 
 void
@@ -121,7 +122,7 @@ util_format_bptc_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride,
 }
 
 void
-util_format_bptc_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+util_format_bptc_srgba_unpack_rgba_float(void *dst_row, unsigned dst_stride,
                                          const uint8_t *src_row, unsigned src_stride,
                                          unsigned width, unsigned height)
 {
@@ -130,10 +131,10 @@ util_format_bptc_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride,
    decompress_rgba_unorm(width, height,
                          src_row, src_stride,
                          temp_block, width * 4 * sizeof(uint8_t));
-   util_format_read_4f(PIPE_FORMAT_R8G8B8A8_SRGB,
-                       dst_row, dst_stride,
-                       temp_block, width * 4 * sizeof(uint8_t),
-                       0, 0, width, height);
+   util_format_r8g8b8a8_srgb_unpack_rgba_float(dst_row, dst_stride,
+                                               temp_block, width * 4 * sizeof(uint8_t),
+                                               width, height);
+
    free((void *) temp_block);
 }
 
@@ -149,17 +150,14 @@ util_format_bptc_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride,
 }
 
 void
-util_format_bptc_srgba_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_srgba_fetch_rgba(void *dst, const uint8_t *src,
                                         unsigned width, unsigned height)
 {
    uint8_t temp_block[4];
 
    fetch_rgba_unorm_from_block(src + ((width * sizeof(uint8_t)) * (height / 4) + (width / 4)) * 16,
                                temp_block, (width % 4) + (height % 4) * 4);
-   util_format_read_4f(PIPE_FORMAT_R8G8B8A8_SRGB,
-                       dst, 4 * sizeof(float),
-                       temp_block, width * 4 * sizeof(uint8_t),
-                       0, 0, 1, 1);
+   util_format_r8g8b8a8_srgb_fetch_rgba(dst, temp_block, 0, 0);
 }
 
 void
@@ -173,10 +171,10 @@ util_format_bptc_rgb_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_str
                         src_row, src_stride,
                         temp_block, width * 4 * sizeof(float),
                         true);
-   util_format_read_4ub(PIPE_FORMAT_R32G32B32A32_FLOAT,
+   util_format_r32g32b32a32_float_unpack_rgba_8unorm(
                         dst_row, dst_stride,
-                        temp_block, width * 4 * sizeof(float),
-                        0, 0, width, height);
+                        (const uint8_t *)temp_block, width * 4 * sizeof(float),
+                        width, height);
    free((void *) temp_block);
 }
 
@@ -191,7 +189,7 @@ util_format_bptc_rgb_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_strid
 }
 
 void
-util_format_bptc_rgb_float_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+util_format_bptc_rgb_float_unpack_rgba_float(void *dst_row, unsigned dst_stride,
                                              const uint8_t *src_row, unsigned src_stride,
                                              unsigned width, unsigned height)
 {
@@ -213,7 +211,7 @@ util_format_bptc_rgb_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride
 }
 
 void
-util_format_bptc_rgb_float_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_rgb_float_fetch_rgba(void *dst, const uint8_t *src,
                                             unsigned width, unsigned height)
 {
    fetch_rgb_float_from_block(src + ((width * sizeof(uint8_t)) * (height / 4) + (width / 4)) * 16,
@@ -231,10 +229,10 @@ util_format_bptc_rgb_ufloat_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_st
                         src_row, src_stride,
                         temp_block, width * 4 * sizeof(float),
                         false);
-   util_format_read_4ub(PIPE_FORMAT_R32G32B32A32_FLOAT,
+   util_format_r32g32b32a32_float_unpack_rgba_8unorm(
                         dst_row, dst_stride,
-                        temp_block, width * 4 * sizeof(float),
-                        0, 0, width, height);
+                        (const uint8_t *)temp_block, width * 4 * sizeof(float),
+                        width, height);
    free((void *) temp_block);
 }
 
@@ -249,7 +247,7 @@ util_format_bptc_rgb_ufloat_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stri
 }
 
 void
-util_format_bptc_rgb_ufloat_unpack_rgba_float(float *dst_row, unsigned dst_stride,
+util_format_bptc_rgb_ufloat_unpack_rgba_float(void *dst_row, unsigned dst_stride,
                                               const uint8_t *src_row, unsigned src_stride,
                                               unsigned width, unsigned height)
 {
@@ -271,7 +269,7 @@ util_format_bptc_rgb_ufloat_pack_rgba_float(uint8_t *dst_row, unsigned dst_strid
 }
 
 void
-util_format_bptc_rgb_ufloat_fetch_rgba_float(float *dst, const uint8_t *src,
+util_format_bptc_rgb_ufloat_fetch_rgba(void *dst, const uint8_t *src,
                                              unsigned width, unsigned height)
 {
    fetch_rgb_float_from_block(src + ((width * sizeof(uint8_t)) * (height / 4) + (width / 4)) * 16,