mesa: remove duplicated code around framebuffer_renderbuffer()
[mesa.git] / src / mesa / main / texcompress_etc.c
index ae973b001d6f12e039663a2ef1d66dbdd079d88c..d4650109857171d6c114ca05fd3370d513b27227 100644 (file)
@@ -43,6 +43,7 @@
 #include "texstore.h"
 #include "macros.h"
 #include "format_unpack.h"
+#include "util/format_srgb.h"
 
 
 struct etc2_block {
@@ -107,7 +108,7 @@ GLboolean
 _mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS)
 {
    /* GL_ETC1_RGB8_OES is only valid in glCompressedTexImage2D */
-   ASSERT(0);
+   assert(0);
 
    return GL_FALSE;
 }
@@ -457,10 +458,10 @@ etc2_rgb8_parse_block(struct etc2_block *block,
       /* Use same modifier tables as for etc1 textures if opaque bit is set
        * or if non punchthrough texture format
        */
-      block->modifier_tables[0] = (block->opaque || !punchthrough_alpha) ?
+      block->modifier_tables[0] = (!punchthrough_alpha || block->opaque) ?
                                   etc1_modifier_tables[table1_idx] :
                                   etc2_modifier_tables_non_opaque[table1_idx];
-      block->modifier_tables[1] = (block->opaque || !punchthrough_alpha) ?
+      block->modifier_tables[1] = (!punchthrough_alpha || block->opaque) ?
                                   etc1_modifier_tables[table2_idx] :
                                   etc2_modifier_tables_non_opaque[table2_idx];
 
@@ -1098,7 +1099,7 @@ etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row,
 GLboolean
 _mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS)
 {
-   ASSERT(0);
+   assert(0);
 
    return GL_FALSE;
 }
@@ -1106,7 +1107,7 @@ _mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS)
 {
-   ASSERT(0);
+   assert(0);
 
    return GL_FALSE;
 }
@@ -1114,7 +1115,7 @@ _mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS)
 {
-   ASSERT(0);
+   assert(0);
 
    return GL_FALSE;
 }
@@ -1122,7 +1123,7 @@ _mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS)
 {
-   ASSERT(0);
+   assert(0);
 
    return GL_FALSE;
 }
@@ -1130,7 +1131,7 @@ _mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS)
 {
-   ASSERT(0);
+   assert(0);
 
    return GL_FALSE;
 }
@@ -1138,7 +1139,7 @@ _mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS)
 {
-   ASSERT(0);
+   assert(0);
 
    return GL_FALSE;
 }
@@ -1146,7 +1147,7 @@ _mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS)
 {
-   ASSERT(0);
+   assert(0);
 
    return GL_FALSE;
 }
@@ -1154,7 +1155,7 @@ _mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS)
 {
-   ASSERT(0);
+   assert(0);
 
    return GL_FALSE;
 }
@@ -1162,7 +1163,7 @@ _mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
 {
-   ASSERT(0);
+   assert(0);
 
    return GL_FALSE;
 }
@@ -1170,7 +1171,7 @@ _mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
 GLboolean
 _mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
 {
-   ASSERT(0);
+   assert(0);
 
    return GL_FALSE;
 }
@@ -1307,9 +1308,9 @@ fetch_etc2_srgb8(const GLubyte *map,
    etc2_rgb8_fetch_texel(&block, i % 4, j % 4, dst,
                          false /* punchthrough_alpha */);
 
-   texel[RCOMP] = _mesa_nonlinear_to_linear(dst[0]);
-   texel[GCOMP] = _mesa_nonlinear_to_linear(dst[1]);
-   texel[BCOMP] = _mesa_nonlinear_to_linear(dst[2]);
+   texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(dst[0]);
+   texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(dst[1]);
+   texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(dst[2]);
    texel[ACOMP] = 1.0f;
 }
 
@@ -1345,9 +1346,9 @@ fetch_etc2_srgb8_alpha8_eac(const GLubyte *map,
    etc2_rgba8_parse_block(&block, src);
    etc2_rgba8_fetch_texel(&block, i % 4, j % 4, dst);
 
-   texel[RCOMP] = _mesa_nonlinear_to_linear(dst[0]);
-   texel[GCOMP] = _mesa_nonlinear_to_linear(dst[1]);
-   texel[BCOMP] = _mesa_nonlinear_to_linear(dst[2]);
+   texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(dst[0]);
+   texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(dst[1]);
+   texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(dst[2]);
    texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
 }
 
@@ -1473,9 +1474,9 @@ fetch_etc2_srgb8_punchthrough_alpha1(const GLubyte *map,
                          true /* punchthrough alpha */);
    etc2_rgb8_fetch_texel(&block, i % 4, j % 4, dst,
                          true /* punchthrough alpha */);
-   texel[RCOMP] = _mesa_nonlinear_to_linear(dst[0]);
-   texel[GCOMP] = _mesa_nonlinear_to_linear(dst[1]);
-   texel[BCOMP] = _mesa_nonlinear_to_linear(dst[2]);
+   texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(dst[0]);
+   texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(dst[1]);
+   texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(dst[2]);
    texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
 }