mesa: replace _NEW_EVAL with vbo_exec_update_eval_maps
[mesa.git] / src / mesa / main / texcompress_etc.c
index d4650109857171d6c114ca05fd3370d513b27227..32464f3ca9e41df60473fe452d3ef9aca76ea6a4 100644 (file)
@@ -41,6 +41,7 @@
 #include "texcompress.h"
 #include "texcompress_etc.h"
 #include "texstore.h"
+#include "config.h"
 #include "macros.h"
 #include "format_unpack.h"
 #include "util/format_srgb.h"
@@ -105,7 +106,7 @@ static const int etc2_modifier_tables_non_opaque[8][4] = {
 #undef UINT8_TYPE
 
 GLboolean
-_mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS)
+_mesa_texstore_etc1_rgb8(UNUSED_TEXSTORE_PARAMS)
 {
    /* GL_ETC1_RGB8_OES is only valid in glCompressedTexImage2D */
    assert(0);
@@ -547,6 +548,8 @@ etc2_rgb8_fetch_texel(const struct etc2_block *block,
       if (punchthrough_alpha)
          dst[3] = 255;
    }
+   else
+      unreachable("unhandled block mode");
 }
 
 static void
@@ -718,7 +721,8 @@ etc2_unpack_srgb8(uint8_t *dst_row,
                   const uint8_t *src_row,
                   unsigned src_stride,
                   unsigned width,
-                  unsigned height)
+                 unsigned height,
+                 bool bgra)
 {
    const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
    struct etc2_block block;
@@ -740,11 +744,14 @@ etc2_unpack_srgb8(uint8_t *dst_row,
             for (i = 0; i < w; i++) {
                etc2_rgb8_fetch_texel(&block, i, j, dst,
                                      false /* punchthrough_alpha */);
-               /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
-               tmp = dst[0];
-               dst[0] = dst[2];
-               dst[2] = tmp;
-               dst[3] = 255;
+
+              if (bgra) {
+                 /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
+                 tmp = dst[0];
+                 dst[0] = dst[2];
+                 dst[2] = tmp;
+                 dst[3] = 255;
+              }
 
                dst += comps;
             }
@@ -800,7 +807,8 @@ etc2_unpack_srgb8_alpha8(uint8_t *dst_row,
                          const uint8_t *src_row,
                          unsigned src_stride,
                          unsigned width,
-                         unsigned height)
+                        unsigned height,
+                        bool bgra)
 {
    /* If internalformat is COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, each 4 × 4 block
     * of RGBA8888 information is compressed to 128 bits. To decode a block, the
@@ -824,11 +832,13 @@ etc2_unpack_srgb8_alpha8(uint8_t *dst_row,
             for (i = 0; i < w; i++) {
                etc2_rgba8_fetch_texel(&block, i, j, dst);
 
-               /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
-               tmp = dst[0];
-               dst[0] = dst[2];
-               dst[2] = tmp;
-               dst[3] = dst[3];
+              if (bgra) {
+                 /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
+                 tmp = dst[0];
+                 dst[0] = dst[2];
+                 dst[2] = tmp;
+                 dst[3] = dst[3];
+              }
 
                dst += comps;
             }
@@ -1057,7 +1067,8 @@ etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row,
                                      const uint8_t *src_row,
                                      unsigned src_stride,
                                      unsigned width,
-                                     unsigned height)
+                                    unsigned height,
+                                    bool bgra)
 {
    const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
    struct etc2_block block;
@@ -1077,11 +1088,14 @@ etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row,
             for (i = 0; i < w; i++) {
                etc2_rgb8_fetch_texel(&block, i, j, dst,
                                      true /* punchthrough_alpha */);
-               /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
-               tmp = dst[0];
-               dst[0] = dst[2];
-               dst[2] = tmp;
-               dst[3] = dst[3];
+
+              if (bgra) {
+                 /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
+                 tmp = dst[0];
+                 dst[0] = dst[2];
+                 dst[2] = tmp;
+                 dst[3] = dst[3];
+              }
 
                dst += comps;
             }
@@ -1097,7 +1111,7 @@ etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row,
 /* ETC2 texture formats are valid in glCompressedTexImage2D and
  * glCompressedTexSubImage2D functions */
 GLboolean
-_mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_rgb8(UNUSED_TEXSTORE_PARAMS)
 {
    assert(0);
 
@@ -1105,7 +1119,7 @@ _mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS)
 }
 
 GLboolean
-_mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_srgb8(UNUSED_TEXSTORE_PARAMS)
 {
    assert(0);
 
@@ -1113,7 +1127,7 @@ _mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS)
 }
 
 GLboolean
-_mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_rgba8_eac(UNUSED_TEXSTORE_PARAMS)
 {
    assert(0);
 
@@ -1121,7 +1135,7 @@ _mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS)
 }
 
 GLboolean
-_mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_srgb8_alpha8_eac(UNUSED_TEXSTORE_PARAMS)
 {
    assert(0);
 
@@ -1129,7 +1143,7 @@ _mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS)
 }
 
 GLboolean
-_mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_r11_eac(UNUSED_TEXSTORE_PARAMS)
 {
    assert(0);
 
@@ -1137,7 +1151,7 @@ _mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS)
 }
 
 GLboolean
-_mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_signed_r11_eac(UNUSED_TEXSTORE_PARAMS)
 {
    assert(0);
 
@@ -1145,7 +1159,7 @@ _mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS)
 }
 
 GLboolean
-_mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_rg11_eac(UNUSED_TEXSTORE_PARAMS)
 {
    assert(0);
 
@@ -1153,7 +1167,7 @@ _mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS)
 }
 
 GLboolean
-_mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_signed_rg11_eac(UNUSED_TEXSTORE_PARAMS)
 {
    assert(0);
 
@@ -1161,7 +1175,7 @@ _mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS)
 }
 
 GLboolean
-_mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_rgb8_punchthrough_alpha1(UNUSED_TEXSTORE_PARAMS)
 {
    assert(0);
 
@@ -1169,7 +1183,7 @@ _mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
 }
 
 GLboolean
-_mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_srgb8_punchthrough_alpha1(UNUSED_TEXSTORE_PARAMS)
 {
    assert(0);
 
@@ -1205,7 +1219,8 @@ _mesa_unpack_etc2_format(uint8_t *dst_row,
                          unsigned src_stride,
                          unsigned src_width,
                          unsigned src_height,
-                         mesa_format format)
+                        mesa_format format,
+                        bool bgra)
 {
    if (format == MESA_FORMAT_ETC2_RGB8)
       etc2_unpack_rgb8(dst_row, dst_stride,
@@ -1214,7 +1229,7 @@ _mesa_unpack_etc2_format(uint8_t *dst_row,
    else if (format == MESA_FORMAT_ETC2_SRGB8)
       etc2_unpack_srgb8(dst_row, dst_stride,
                         src_row, src_stride,
-                        src_width, src_height);
+                       src_width, src_height, bgra);
    else if (format == MESA_FORMAT_ETC2_RGBA8_EAC)
       etc2_unpack_rgba8(dst_row, dst_stride,
                         src_row, src_stride,
@@ -1222,7 +1237,7 @@ _mesa_unpack_etc2_format(uint8_t *dst_row,
    else if (format == MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC)
       etc2_unpack_srgb8_alpha8(dst_row, dst_stride,
                                src_row, src_stride,
-                               src_width, src_height);
+                              src_width, src_height, bgra);
    else if (format == MESA_FORMAT_ETC2_R11_EAC)
       etc2_unpack_r11(dst_row, dst_stride,
                       src_row, src_stride,
@@ -1246,7 +1261,7 @@ _mesa_unpack_etc2_format(uint8_t *dst_row,
    else if (format == MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1)
       etc2_unpack_srgb8_punchthrough_alpha1(dst_row, dst_stride,
                                             src_row, src_stride,
-                                            src_width, src_height);
+                                           src_width, src_height, bgra);
 }