X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Ftexcompress_etc.c;h=d4650109857171d6c114ca05fd3370d513b27227;hb=edd50828618ed2efe799013c2723d67c407d86b4;hp=75019820577924742ba271e1ceb942f195987586;hpb=cb4ad1368551b64756c7b6e2007588e34739b188;p=mesa.git diff --git a/src/mesa/main/texcompress_etc.c b/src/mesa/main/texcompress_etc.c index 75019820577..d4650109857 100644 --- a/src/mesa/main/texcompress_etc.c +++ b/src/mesa/main/texcompress_etc.c @@ -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]; @@ -685,15 +686,15 @@ etc2_unpack_rgb8(uint8_t *dst_row, const unsigned h = MIN2(bh, height - y); for (x = 0; x < width; x+= bw) { - etc2_rgb8_parse_block(&block, src, - false /* punchthrough_alpha */); - /* * Destination texture may not be a multiple of four texels in * width. Compute a safe width to avoid writing outside the texture. */ const unsigned w = MIN2(bw, width - x); + etc2_rgb8_parse_block(&block, src, + false /* punchthrough_alpha */); + for (j = 0; j < h; j++) { uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps; for (i = 0; i < w; i++) { @@ -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]); }