2 * Copyright (C) 2011 LunarG, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * \file texcompress_etc.c
26 * GL_OES_compressed_ETC1_RGB8_texture support.
27 * Supported ETC2 texture formats are:
28 * GL_COMPRESSED_RGB8_ETC2
29 * GL_COMPRESSED_SRGB8_ETC2
30 * GL_COMPRESSED_RGBA8_ETC2_EAC
31 * GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
32 * GL_COMPRESSED_R11_EAC
33 * GL_COMPRESSED_RG11_EAC
34 * GL_COMPRESSED_SIGNED_R11_EAC
35 * GL_COMPRESSED_SIGNED_RG11_EAC
36 * MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
37 * MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
41 #include "texcompress.h"
42 #include "texcompress_etc.h"
45 #include "format_unpack.h"
50 uint64_t pixel_indices
[2];
51 const int *modifier_tables
[2];
59 uint8_t base_colors
[3][3];
60 uint8_t paint_colors
[4][3];
61 uint8_t base_codeword
;
66 static const int etc2_distance_table
[8] = {
67 3, 6, 11, 16, 23, 32, 41, 64 };
69 static const int etc2_modifier_tables
[16][8] = {
70 { -3, -6, -9, -15, 2, 5, 8, 14},
71 { -3, -7, -10, -13, 2, 6, 9, 12},
72 { -2, -5, -8, -13, 1, 4, 7, 12},
73 { -2, -4, -6, -13, 1, 3, 5, 12},
74 { -3, -6, -8, -12, 2, 5, 7, 11},
75 { -3, -7, -9, -11, 2, 6, 8, 10},
76 { -4, -7, -8, -11, 3, 6, 7, 10},
77 { -3, -5, -8, -11, 2, 4, 7, 10},
78 { -2, -6, -8, -10, 1, 5, 7, 9},
79 { -2, -5, -8, -10, 1, 4, 7, 9},
80 { -2, -4, -8, -10, 1, 3, 7, 9},
81 { -2, -5, -7, -10, 1, 4, 6, 9},
82 { -3, -4, -7, -10, 2, 3, 6, 9},
83 { -1, -2, -3, -10, 0, 1, 2, 9},
84 { -4, -6, -8, -9, 3, 5, 7, 8},
85 { -3, -5, -7, -9, 2, 4, 6, 8},
88 static const int etc2_modifier_tables_non_opaque
[8][4] = {
99 /* define etc1_parse_block and etc. */
100 #define UINT8_TYPE GLubyte
102 #include "texcompress_etc_tmp.h"
107 _mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS
)
109 /* GL_ETC1_RGB8_OES is only valid in glCompressedTexImage2D */
117 * Decode texture data in format `MESA_FORMAT_ETC1_RGB8` to
118 * `MESA_FORMAT_ABGR8888`.
120 * The size of the source data must be a multiple of the ETC1 block size,
121 * which is 8, even if the texture image's dimensions are not aligned to 4.
122 * From the GL_OES_compressed_ETC1_RGB8_texture spec:
123 * The texture is described as a number of 4x4 pixel blocks. If the
124 * texture (or a particular mip-level) is smaller than 4 pixels in
125 * any dimension (such as a 2x2 or a 8x1 texture), the texture is
126 * found in the upper left part of the block(s), and the rest of the
127 * pixels are not used. For instance, a texture of size 4x2 will be
128 * placed in the upper half of a 4x4 block, and the lower half of the
129 * pixels in the block will not be accessed.
131 * \param src_width in pixels
132 * \param src_height in pixels
133 * \param dst_stride in bytes
136 _mesa_etc1_unpack_rgba8888(uint8_t *dst_row
,
138 const uint8_t *src_row
,
143 etc1_unpack_rgba8888(dst_row
, dst_stride
,
145 src_width
, src_height
);
149 etc2_base_color1_t_mode(const uint8_t *in
, GLuint index
)
151 uint8_t R1a
= 0, x
= 0;
152 /* base col 1 = extend_4to8bits( (R1a << 2) | R1b, G1, B1) */
155 R1a
= (in
[0] >> 3) & 0x3;
156 x
= ((R1a
<< 2) | (in
[0] & 0x3));
159 x
= ((in
[1] >> 4) & 0xf);
168 return ((x
<< 4) | (x
& 0xf));
172 etc2_base_color2_t_mode(const uint8_t *in
, GLuint index
)
175 /*extend 4to8bits(R2, G2, B2)*/
178 x
= ((in
[2] >> 4) & 0xf );
184 x
= ((in
[3] >> 4) & 0xf);
190 return ((x
<< 4) | (x
& 0xf));
194 etc2_base_color1_h_mode(const uint8_t *in
, GLuint index
)
197 /* base col 1 = extend 4to8bits(R1, (G1a << 1) | G1b, (B1a << 3) | B1b) */
200 x
= ((in
[0] >> 3) & 0xf);
203 x
= (((in
[0] & 0x7) << 1) | ((in
[1] >> 4) & 0x1));
207 (((in
[1] & 0x3) << 1) | ((in
[2] >> 7) & 0x1)));
213 return ((x
<< 4) | (x
& 0xf));
217 etc2_base_color2_h_mode(const uint8_t *in
, GLuint index
)
220 /* base col 2 = extend 4to8bits(R2, G2, B2) */
223 x
= ((in
[2] >> 3) & 0xf );
226 x
= (((in
[2] & 0x7) << 1) | ((in
[3] >> 7) & 0x1));
229 x
= ((in
[3] >> 3) & 0xf);
235 return ((x
<< 4) | (x
& 0xf));
239 etc2_base_color_o_planar(const uint8_t *in
, GLuint index
)
244 tmp
= ((in
[0] >> 1) & 0x3f); /* RO */
245 return ((tmp
<< 2) | (tmp
>> 4));
247 tmp
= (((in
[0] & 0x1) << 6) | /* GO1 */
248 ((in
[1] >> 1) & 0x3f)); /* GO2 */
249 return ((tmp
<< 1) | (tmp
>> 6));
251 tmp
= (((in
[1] & 0x1) << 5) | /* BO1 */
252 (in
[2] & 0x18) | /* BO2 */
253 (((in
[2] & 0x3) << 1) | ((in
[3] >> 7) & 0x1))); /* BO3 */
254 return ((tmp
<< 2) | (tmp
>> 4));
262 etc2_base_color_h_planar(const uint8_t *in
, GLuint index
)
267 tmp
= (((in
[3] & 0x7c) >> 1) | /* RH1 */
268 (in
[3] & 0x1)); /* RH2 */
269 return ((tmp
<< 2) | (tmp
>> 4));
271 tmp
= (in
[4] >> 1) & 0x7f; /* GH */
272 return ((tmp
<< 1) | (tmp
>> 6));
274 tmp
= (((in
[4] & 0x1) << 5) |
275 ((in
[5] >> 3) & 0x1f)); /* BH */
276 return ((tmp
<< 2) | (tmp
>> 4));
284 etc2_base_color_v_planar(const uint8_t *in
, GLuint index
)
289 tmp
= (((in
[5] & 0x7) << 0x3) |
290 ((in
[6] >> 5) & 0x7)); /* RV */
291 return ((tmp
<< 2) | (tmp
>> 4));
293 tmp
= (((in
[6] & 0x1f) << 2) |
294 ((in
[7] >> 6) & 0x3)); /* GV */
295 return ((tmp
<< 1) | (tmp
>> 6));
297 tmp
= in
[7] & 0x3f; /* BV */
298 return ((tmp
<< 2) | (tmp
>> 4));
306 etc2_get_pixel_index(const struct etc2_block
*block
, int x
, int y
)
308 int bit
= ((3 - y
) + (3 - x
) * 4) * 3;
309 int idx
= (block
->pixel_indices
[1] >> bit
) & 0x7;
314 etc2_clamp(int color
)
316 /* CLAMP(color, 0, 255) */
317 return (uint8_t) CLAMP(color
, 0, 255);
321 etc2_clamp2(int color
)
323 /* CLAMP(color, 0, 2047) */
324 return (GLushort
) CLAMP(color
, 0, 2047);
328 etc2_clamp3(int color
)
330 /* CLAMP(color, -1023, 1023) */
331 return (GLshort
) CLAMP(color
, -1023, 1023);
335 etc2_rgb8_parse_block(struct etc2_block
*block
,
337 GLboolean punchthrough_alpha
)
340 GLboolean diffbit
= false;
341 static const int lookup
[8] = { 0, 1, 2, 3, -4, -3, -2, -1 };
343 const int R_plus_dR
= (src
[0] >> 3) + lookup
[src
[0] & 0x7];
344 const int G_plus_dG
= (src
[1] >> 3) + lookup
[src
[1] & 0x7];
345 const int B_plus_dB
= (src
[2] >> 3) + lookup
[src
[2] & 0x7];
347 /* Reset the mode flags */
348 block
->is_ind_mode
= false;
349 block
->is_diff_mode
= false;
350 block
->is_t_mode
= false;
351 block
->is_h_mode
= false;
352 block
->is_planar_mode
= false;
354 if (punchthrough_alpha
)
355 block
->opaque
= src
[3] & 0x2;
357 diffbit
= src
[3] & 0x2;
359 if (!diffbit
&& !punchthrough_alpha
) {
360 /* individual mode */
361 block
->is_ind_mode
= true;
363 for (i
= 0; i
< 3; i
++) {
364 /* Texture decode algorithm is same for individual mode in etc1
367 block
->base_colors
[0][i
] = etc1_base_color_ind_hi(src
[i
]);
368 block
->base_colors
[1][i
] = etc1_base_color_ind_lo(src
[i
]);
371 else if (R_plus_dR
< 0 || R_plus_dR
> 31){
373 block
->is_t_mode
= true;
375 for(i
= 0; i
< 3; i
++) {
376 block
->base_colors
[0][i
] = etc2_base_color1_t_mode(src
, i
);
377 block
->base_colors
[1][i
] = etc2_base_color2_t_mode(src
, i
);
381 etc2_distance_table
[(((src
[3] >> 2) & 0x3) << 1) |
384 for (i
= 0; i
< 3; i
++) {
385 block
->paint_colors
[0][i
] = etc2_clamp(block
->base_colors
[0][i
]);
386 block
->paint_colors
[1][i
] = etc2_clamp(block
->base_colors
[1][i
] +
388 block
->paint_colors
[2][i
] = etc2_clamp(block
->base_colors
[1][i
]);
389 block
->paint_colors
[3][i
] = etc2_clamp(block
->base_colors
[1][i
] -
393 else if (G_plus_dG
< 0 || G_plus_dG
> 31){
394 int base_color_1_value
, base_color_2_value
;
397 block
->is_h_mode
= true;
399 for(i
= 0; i
< 3; i
++) {
400 block
->base_colors
[0][i
] = etc2_base_color1_h_mode(src
, i
);
401 block
->base_colors
[1][i
] = etc2_base_color2_h_mode(src
, i
);
404 base_color_1_value
= (block
->base_colors
[0][0] << 16) +
405 (block
->base_colors
[0][1] << 8) +
406 block
->base_colors
[0][2];
407 base_color_2_value
= (block
->base_colors
[1][0] << 16) +
408 (block
->base_colors
[1][1] << 8) +
409 block
->base_colors
[1][2];
412 etc2_distance_table
[(src
[3] & 0x4) |
413 ((src
[3] & 0x1) << 1) |
414 (base_color_1_value
>= base_color_2_value
)];
416 for (i
= 0; i
< 3; i
++) {
417 block
->paint_colors
[0][i
] = etc2_clamp(block
->base_colors
[0][i
] +
419 block
->paint_colors
[1][i
] = etc2_clamp(block
->base_colors
[0][i
] -
421 block
->paint_colors
[2][i
] = etc2_clamp(block
->base_colors
[1][i
] +
423 block
->paint_colors
[3][i
] = etc2_clamp(block
->base_colors
[1][i
] -
427 else if (B_plus_dB
< 0 || B_plus_dB
> 31) {
429 block
->is_planar_mode
= true;
431 /* opaque bit must be set in planar mode */
432 block
->opaque
= true;
434 for (i
= 0; i
< 3; i
++) {
435 block
->base_colors
[0][i
] = etc2_base_color_o_planar(src
, i
);
436 block
->base_colors
[1][i
] = etc2_base_color_h_planar(src
, i
);
437 block
->base_colors
[2][i
] = etc2_base_color_v_planar(src
, i
);
440 else if (diffbit
|| punchthrough_alpha
) {
441 /* differential mode */
442 block
->is_diff_mode
= true;
444 for (i
= 0; i
< 3; i
++) {
445 /* Texture decode algorithm is same for differential mode in etc1
448 block
->base_colors
[0][i
] = etc1_base_color_diff_hi(src
[i
]);
449 block
->base_colors
[1][i
] = etc1_base_color_diff_lo(src
[i
]);
453 if (block
->is_ind_mode
|| block
->is_diff_mode
) {
454 int table1_idx
= (src
[3] >> 5) & 0x7;
455 int table2_idx
= (src
[3] >> 2) & 0x7;
457 /* Use same modifier tables as for etc1 textures if opaque bit is set
458 * or if non punchthrough texture format
460 block
->modifier_tables
[0] = (block
->opaque
|| !punchthrough_alpha
) ?
461 etc1_modifier_tables
[table1_idx
] :
462 etc2_modifier_tables_non_opaque
[table1_idx
];
463 block
->modifier_tables
[1] = (block
->opaque
|| !punchthrough_alpha
) ?
464 etc1_modifier_tables
[table2_idx
] :
465 etc2_modifier_tables_non_opaque
[table2_idx
];
467 block
->flipped
= (src
[3] & 0x1);
470 block
->pixel_indices
[0] =
471 (src
[4] << 24) | (src
[5] << 16) | (src
[6] << 8) | src
[7];
475 etc2_rgb8_fetch_texel(const struct etc2_block
*block
,
476 int x
, int y
, uint8_t *dst
,
477 GLboolean punchthrough_alpha
)
479 const uint8_t *base_color
;
480 int modifier
, bit
, idx
, blk
;
482 /* get pixel index */
484 idx
= ((block
->pixel_indices
[0] >> (15 + bit
)) & 0x2) |
485 ((block
->pixel_indices
[0] >> (bit
)) & 0x1);
487 if (block
->is_ind_mode
|| block
->is_diff_mode
) {
488 /* check for punchthrough_alpha format */
489 if (punchthrough_alpha
) {
490 if (!block
->opaque
&& idx
== 2) {
491 dst
[0] = dst
[1] = dst
[2] = dst
[3] = 0;
498 /* Use pixel index and subblock to get the modifier */
499 blk
= (block
->flipped
) ? (y
>= 2) : (x
>= 2);
500 base_color
= block
->base_colors
[blk
];
501 modifier
= block
->modifier_tables
[blk
][idx
];
503 dst
[0] = etc2_clamp(base_color
[0] + modifier
);
504 dst
[1] = etc2_clamp(base_color
[1] + modifier
);
505 dst
[2] = etc2_clamp(base_color
[2] + modifier
);
507 else if (block
->is_t_mode
|| block
->is_h_mode
) {
508 /* check for punchthrough_alpha format */
509 if (punchthrough_alpha
) {
510 if (!block
->opaque
&& idx
== 2) {
511 dst
[0] = dst
[1] = dst
[2] = dst
[3] = 0;
518 /* Use pixel index to pick one of the paint colors */
519 dst
[0] = block
->paint_colors
[idx
][0];
520 dst
[1] = block
->paint_colors
[idx
][1];
521 dst
[2] = block
->paint_colors
[idx
][2];
523 else if (block
->is_planar_mode
) {
524 /* {R(x, y) = clamp255((x × (RH − RO) + y × (RV − RO) + 4 × RO + 2) >> 2)
525 * {G(x, y) = clamp255((x × (GH − GO) + y × (GV − GO) + 4 × GO + 2) >> 2)
526 * {B(x, y) = clamp255((x × (BH − BO) + y × (BV − BO) + 4 × BO + 2) >> 2)
528 int red
, green
, blue
;
529 red
= (x
* (block
->base_colors
[1][0] - block
->base_colors
[0][0]) +
530 y
* (block
->base_colors
[2][0] - block
->base_colors
[0][0]) +
531 4 * block
->base_colors
[0][0] + 2) >> 2;
533 green
= (x
* (block
->base_colors
[1][1] - block
->base_colors
[0][1]) +
534 y
* (block
->base_colors
[2][1] - block
->base_colors
[0][1]) +
535 4 * block
->base_colors
[0][1] + 2) >> 2;
537 blue
= (x
* (block
->base_colors
[1][2] - block
->base_colors
[0][2]) +
538 y
* (block
->base_colors
[2][2] - block
->base_colors
[0][2]) +
539 4 * block
->base_colors
[0][2] + 2) >> 2;
541 dst
[0] = etc2_clamp(red
);
542 dst
[1] = etc2_clamp(green
);
543 dst
[2] = etc2_clamp(blue
);
545 /* check for punchthrough_alpha format */
546 if (punchthrough_alpha
)
552 etc2_alpha8_fetch_texel(const struct etc2_block
*block
,
553 int x
, int y
, uint8_t *dst
)
555 int modifier
, alpha
, idx
;
556 /* get pixel index */
557 idx
= etc2_get_pixel_index(block
, x
, y
);
558 modifier
= etc2_modifier_tables
[block
->table_index
][idx
];
559 alpha
= block
->base_codeword
+ modifier
* block
->multiplier
;
560 dst
[3] = etc2_clamp(alpha
);
564 etc2_r11_fetch_texel(const struct etc2_block
*block
,
565 int x
, int y
, uint8_t *dst
)
569 /* Get pixel index */
570 idx
= etc2_get_pixel_index(block
, x
, y
);
571 modifier
= etc2_modifier_tables
[block
->table_index
][idx
];
573 if (block
->multiplier
!= 0)
574 /* clamp2(base codeword × 8 + 4 + modifier × multiplier × 8) */
575 color
= etc2_clamp2(((block
->base_codeword
<< 3) | 0x4) +
576 ((modifier
* block
->multiplier
) << 3));
578 color
= etc2_clamp2(((block
->base_codeword
<< 3) | 0x4) + modifier
);
580 /* Extend 11 bits color value to 16 bits. OpenGL ES 3.0 specification
581 * allows extending the color value to any number of bits. But, an
582 * implementation is not allowed to truncate the 11-bit value to less than
585 color
= (color
<< 5) | (color
>> 6);
586 ((GLushort
*)dst
)[0] = color
;
590 etc2_signed_r11_fetch_texel(const struct etc2_block
*block
,
591 int x
, int y
, uint8_t *dst
)
595 GLbyte base_codeword
= (GLbyte
) block
->base_codeword
;
597 if (base_codeword
== -128)
598 base_codeword
= -127;
600 /* Get pixel index */
601 idx
= etc2_get_pixel_index(block
, x
, y
);
602 modifier
= etc2_modifier_tables
[block
->table_index
][idx
];
604 if (block
->multiplier
!= 0)
605 /* clamp3(base codeword × 8 + modifier × multiplier × 8) */
606 color
= etc2_clamp3((base_codeword
<< 3) +
607 ((modifier
* block
->multiplier
) << 3));
609 color
= etc2_clamp3((base_codeword
<< 3) + modifier
);
611 /* Extend 11 bits color value to 16 bits. OpenGL ES 3.0 specification
612 * allows extending the color value to any number of bits. But, an
613 * implementation is not allowed to truncate the 11-bit value to less than
614 * 11 bits. A negative 11-bit value must first be made positive before bit
615 * replication, and then made negative again
618 color
= (color
<< 5) | (color
>> 5);
621 color
= (color
<< 5) | (color
>> 5);
624 ((GLshort
*)dst
)[0] = color
;
628 etc2_alpha8_parse_block(struct etc2_block
*block
, const uint8_t *src
)
630 block
->base_codeword
= src
[0];
631 block
->multiplier
= (src
[1] >> 4) & 0xf;
632 block
->table_index
= src
[1] & 0xf;
633 block
->pixel_indices
[1] = (((uint64_t)src
[2] << 40) |
634 ((uint64_t)src
[3] << 32) |
635 ((uint64_t)src
[4] << 24) |
636 ((uint64_t)src
[5] << 16) |
637 ((uint64_t)src
[6] << 8) |
642 etc2_r11_parse_block(struct etc2_block
*block
, const uint8_t *src
)
644 /* Parsing logic remains same as for etc2_alpha8_parse_block */
645 etc2_alpha8_parse_block(block
, src
);
649 etc2_rgba8_parse_block(struct etc2_block
*block
, const uint8_t *src
)
651 /* RGB component is parsed the same way as for MESA_FORMAT_ETC2_RGB8 */
652 etc2_rgb8_parse_block(block
, src
+ 8,
653 false /* punchthrough_alpha */);
654 /* Parse Alpha component */
655 etc2_alpha8_parse_block(block
, src
);
659 etc2_rgba8_fetch_texel(const struct etc2_block
*block
,
660 int x
, int y
, uint8_t *dst
)
662 etc2_rgb8_fetch_texel(block
, x
, y
, dst
,
663 false /* punchthrough_alpha */);
664 etc2_alpha8_fetch_texel(block
, x
, y
, dst
);
668 etc2_unpack_rgb8(uint8_t *dst_row
,
670 const uint8_t *src_row
,
675 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 4;
676 struct etc2_block block
;
679 for (y
= 0; y
< height
; y
+= bh
) {
680 const uint8_t *src
= src_row
;
682 for (x
= 0; x
< width
; x
+= bw
) {
683 etc2_rgb8_parse_block(&block
, src
,
684 false /* punchthrough_alpha */);
686 for (j
= 0; j
< bh
; j
++) {
687 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
688 for (i
= 0; i
< bw
; i
++) {
689 etc2_rgb8_fetch_texel(&block
, i
, j
, dst
,
690 false /* punchthrough_alpha */);
699 src_row
+= src_stride
;
704 etc2_unpack_srgb8(uint8_t *dst_row
,
706 const uint8_t *src_row
,
711 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 4;
712 struct etc2_block block
;
716 for (y
= 0; y
< height
; y
+= bh
) {
717 const uint8_t *src
= src_row
;
719 for (x
= 0; x
< width
; x
+= bw
) {
720 etc2_rgb8_parse_block(&block
, src
,
721 false /* punchthrough_alpha */);
723 for (j
= 0; j
< bh
; j
++) {
724 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
725 for (i
= 0; i
< bw
; i
++) {
726 etc2_rgb8_fetch_texel(&block
, i
, j
, dst
,
727 false /* punchthrough_alpha */);
728 /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
740 src_row
+= src_stride
;
745 etc2_unpack_rgba8(uint8_t *dst_row
,
747 const uint8_t *src_row
,
752 /* If internalformat is COMPRESSED_RGBA8_ETC2_EAC, each 4 × 4 block of
753 * RGBA8888 information is compressed to 128 bits. To decode a block, the
754 * two 64-bit integers int64bitAlpha and int64bitColor are calculated.
756 const unsigned bw
= 4, bh
= 4, bs
= 16, comps
= 4;
757 struct etc2_block block
;
760 for (y
= 0; y
< height
; y
+= bh
) {
761 const uint8_t *src
= src_row
;
763 for (x
= 0; x
< width
; x
+= bw
) {
764 etc2_rgba8_parse_block(&block
, src
);
766 for (j
= 0; j
< bh
; j
++) {
767 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
768 for (i
= 0; i
< bw
; i
++) {
769 etc2_rgba8_fetch_texel(&block
, i
, j
, dst
);
776 src_row
+= src_stride
;
781 etc2_unpack_srgb8_alpha8(uint8_t *dst_row
,
783 const uint8_t *src_row
,
788 /* If internalformat is COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, each 4 × 4 block
789 * of RGBA8888 information is compressed to 128 bits. To decode a block, the
790 * two 64-bit integers int64bitAlpha and int64bitColor are calculated.
792 const unsigned bw
= 4, bh
= 4, bs
= 16, comps
= 4;
793 struct etc2_block block
;
797 for (y
= 0; y
< height
; y
+= bh
) {
798 const uint8_t *src
= src_row
;
800 for (x
= 0; x
< width
; x
+= bw
) {
801 etc2_rgba8_parse_block(&block
, src
);
803 for (j
= 0; j
< bh
; j
++) {
804 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
805 for (i
= 0; i
< bw
; i
++) {
806 etc2_rgba8_fetch_texel(&block
, i
, j
, dst
);
808 /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
820 src_row
+= src_stride
;
825 etc2_unpack_r11(uint8_t *dst_row
,
827 const uint8_t *src_row
,
832 /* If internalformat is COMPRESSED_R11_EAC, each 4 × 4 block of
833 color information is compressed to 64 bits.
835 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 1, comp_size
= 2;
836 struct etc2_block block
;
839 for (y
= 0; y
< height
; y
+= bh
) {
840 const uint8_t *src
= src_row
;
842 for (x
= 0; x
< width
; x
+= bw
) {
843 etc2_r11_parse_block(&block
, src
);
845 for (j
= 0; j
< bh
; j
++) {
846 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
* comp_size
;
847 for (i
= 0; i
< bw
; i
++) {
848 etc2_r11_fetch_texel(&block
, i
, j
, dst
);
849 dst
+= comps
* comp_size
;
855 src_row
+= src_stride
;
860 etc2_unpack_rg11(uint8_t *dst_row
,
862 const uint8_t *src_row
,
867 /* If internalformat is COMPRESSED_RG11_EAC, each 4 × 4 block of
868 RG color information is compressed to 128 bits.
870 const unsigned bw
= 4, bh
= 4, bs
= 16, comps
= 2, comp_size
= 2;
871 struct etc2_block block
;
874 for (y
= 0; y
< height
; y
+= bh
) {
875 const uint8_t *src
= src_row
;
877 for (x
= 0; x
< width
; x
+= bw
) {
879 etc2_r11_parse_block(&block
, src
);
881 for (j
= 0; j
< bh
; j
++) {
882 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+
883 x
* comps
* comp_size
;
884 for (i
= 0; i
< bw
; i
++) {
885 etc2_r11_fetch_texel(&block
, i
, j
, dst
);
886 dst
+= comps
* comp_size
;
889 /* green component */
890 etc2_r11_parse_block(&block
, src
+ 8);
892 for (j
= 0; j
< bh
; j
++) {
893 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+
894 x
* comps
* comp_size
;
895 for (i
= 0; i
< bw
; i
++) {
896 etc2_r11_fetch_texel(&block
, i
, j
, dst
+ comp_size
);
897 dst
+= comps
* comp_size
;
903 src_row
+= src_stride
;
908 etc2_unpack_signed_r11(uint8_t *dst_row
,
910 const uint8_t *src_row
,
915 /* If internalformat is COMPRESSED_SIGNED_R11_EAC, each 4 × 4 block of
916 red color information is compressed to 64 bits.
918 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 1, comp_size
= 2;
919 struct etc2_block block
;
922 for (y
= 0; y
< height
; y
+= bh
) {
923 const uint8_t *src
= src_row
;
925 for (x
= 0; x
< width
; x
+= bw
) {
926 etc2_r11_parse_block(&block
, src
);
928 for (j
= 0; j
< bh
; j
++) {
929 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+
930 x
* comps
* comp_size
;
931 for (i
= 0; i
< bw
; i
++) {
932 etc2_signed_r11_fetch_texel(&block
, i
, j
, dst
);
933 dst
+= comps
* comp_size
;
939 src_row
+= src_stride
;
944 etc2_unpack_signed_rg11(uint8_t *dst_row
,
946 const uint8_t *src_row
,
951 /* If internalformat is COMPRESSED_SIGNED_RG11_EAC, each 4 × 4 block of
952 RG color information is compressed to 128 bits.
954 const unsigned bw
= 4, bh
= 4, bs
= 16, comps
= 2, comp_size
= 2;
955 struct etc2_block block
;
958 for (y
= 0; y
< height
; y
+= bh
) {
959 const uint8_t *src
= src_row
;
961 for (x
= 0; x
< width
; x
+= bw
) {
963 etc2_r11_parse_block(&block
, src
);
965 for (j
= 0; j
< bh
; j
++) {
966 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+
967 x
* comps
* comp_size
;
968 for (i
= 0; i
< bw
; i
++) {
969 etc2_signed_r11_fetch_texel(&block
, i
, j
, dst
);
970 dst
+= comps
* comp_size
;
973 /* green component */
974 etc2_r11_parse_block(&block
, src
+ 8);
976 for (j
= 0; j
< bh
; j
++) {
977 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+
978 x
* comps
* comp_size
;
979 for (i
= 0; i
< bw
; i
++) {
980 etc2_signed_r11_fetch_texel(&block
, i
, j
, dst
+ comp_size
);
981 dst
+= comps
* comp_size
;
987 src_row
+= src_stride
;
992 etc2_unpack_rgb8_punchthrough_alpha1(uint8_t *dst_row
,
994 const uint8_t *src_row
,
999 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 4;
1000 struct etc2_block block
;
1001 unsigned x
, y
, i
, j
;
1003 for (y
= 0; y
< height
; y
+= bh
) {
1004 const uint8_t *src
= src_row
;
1006 for (x
= 0; x
< width
; x
+= bw
) {
1007 etc2_rgb8_parse_block(&block
, src
,
1008 true /* punchthrough_alpha */);
1009 for (j
= 0; j
< bh
; j
++) {
1010 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
1011 for (i
= 0; i
< bw
; i
++) {
1012 etc2_rgb8_fetch_texel(&block
, i
, j
, dst
,
1013 true /* punchthrough_alpha */);
1021 src_row
+= src_stride
;
1026 etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row
,
1027 unsigned dst_stride
,
1028 const uint8_t *src_row
,
1029 unsigned src_stride
,
1033 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 4;
1034 struct etc2_block block
;
1035 unsigned x
, y
, i
, j
;
1038 for (y
= 0; y
< height
; y
+= bh
) {
1039 const uint8_t *src
= src_row
;
1041 for (x
= 0; x
< width
; x
+= bw
) {
1042 etc2_rgb8_parse_block(&block
, src
,
1043 true /* punchthrough_alpha */);
1044 for (j
= 0; j
< bh
; j
++) {
1045 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
1046 for (i
= 0; i
< bw
; i
++) {
1047 etc2_rgb8_fetch_texel(&block
, i
, j
, dst
,
1048 true /* punchthrough_alpha */);
1049 /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
1062 src_row
+= src_stride
;
1066 /* ETC2 texture formats are valid in glCompressedTexImage2D and
1067 * glCompressedTexSubImage2D functions */
1069 _mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS
)
1077 _mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS
)
1085 _mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS
)
1093 _mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS
)
1101 _mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS
)
1109 _mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS
)
1117 _mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS
)
1125 _mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS
)
1133 _mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS
)
1141 _mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS
)
1150 * Decode texture data in any one of following formats:
1151 * `MESA_FORMAT_ETC2_RGB8`
1152 * `MESA_FORMAT_ETC2_SRGB8`
1153 * `MESA_FORMAT_ETC2_RGBA8_EAC`
1154 * `MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC`
1155 * `MESA_FORMAT_ETC2_R11_EAC`
1156 * `MESA_FORMAT_ETC2_RG11_EAC`
1157 * `MESA_FORMAT_ETC2_SIGNED_R11_EAC`
1158 * `MESA_FORMAT_ETC2_SIGNED_RG11_EAC`
1159 * `MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1`
1160 * `MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1`
1162 * The size of the source data must be a multiple of the ETC2 block size
1163 * even if the texture image's dimensions are not aligned to 4.
1165 * \param src_width in pixels
1166 * \param src_height in pixels
1167 * \param dst_stride in bytes
1171 _mesa_unpack_etc2_format(uint8_t *dst_row
,
1172 unsigned dst_stride
,
1173 const uint8_t *src_row
,
1174 unsigned src_stride
,
1176 unsigned src_height
,
1179 if (format
== MESA_FORMAT_ETC2_RGB8
)
1180 etc2_unpack_rgb8(dst_row
, dst_stride
,
1181 src_row
, src_stride
,
1182 src_width
, src_height
);
1183 else if (format
== MESA_FORMAT_ETC2_SRGB8
)
1184 etc2_unpack_srgb8(dst_row
, dst_stride
,
1185 src_row
, src_stride
,
1186 src_width
, src_height
);
1187 else if (format
== MESA_FORMAT_ETC2_RGBA8_EAC
)
1188 etc2_unpack_rgba8(dst_row
, dst_stride
,
1189 src_row
, src_stride
,
1190 src_width
, src_height
);
1191 else if (format
== MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
)
1192 etc2_unpack_srgb8_alpha8(dst_row
, dst_stride
,
1193 src_row
, src_stride
,
1194 src_width
, src_height
);
1195 else if (format
== MESA_FORMAT_ETC2_R11_EAC
)
1196 etc2_unpack_r11(dst_row
, dst_stride
,
1197 src_row
, src_stride
,
1198 src_width
, src_height
);
1199 else if (format
== MESA_FORMAT_ETC2_RG11_EAC
)
1200 etc2_unpack_rg11(dst_row
, dst_stride
,
1201 src_row
, src_stride
,
1202 src_width
, src_height
);
1203 else if (format
== MESA_FORMAT_ETC2_SIGNED_R11_EAC
)
1204 etc2_unpack_signed_r11(dst_row
, dst_stride
,
1205 src_row
, src_stride
,
1206 src_width
, src_height
);
1207 else if (format
== MESA_FORMAT_ETC2_SIGNED_RG11_EAC
)
1208 etc2_unpack_signed_rg11(dst_row
, dst_stride
,
1209 src_row
, src_stride
,
1210 src_width
, src_height
);
1211 else if (format
== MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
)
1212 etc2_unpack_rgb8_punchthrough_alpha1(dst_row
, dst_stride
,
1213 src_row
, src_stride
,
1214 src_width
, src_height
);
1215 else if (format
== MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
)
1216 etc2_unpack_srgb8_punchthrough_alpha1(dst_row
, dst_stride
,
1217 src_row
, src_stride
,
1218 src_width
, src_height
);
1224 fetch_etc1_rgb8(const GLubyte
*map
,
1225 GLint rowStride
, GLint i
, GLint j
,
1228 struct etc1_block block
;
1232 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1234 etc1_parse_block(&block
, src
);
1235 etc1_fetch_texel(&block
, i
% 4, j
% 4, dst
);
1237 texel
[RCOMP
] = UBYTE_TO_FLOAT(dst
[0]);
1238 texel
[GCOMP
] = UBYTE_TO_FLOAT(dst
[1]);
1239 texel
[BCOMP
] = UBYTE_TO_FLOAT(dst
[2]);
1240 texel
[ACOMP
] = 1.0f
;
1245 fetch_etc2_rgb8(const GLubyte
*map
,
1246 GLint rowStride
, GLint i
, GLint j
, GLfloat
*texel
)
1248 struct etc2_block block
;
1252 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1254 etc2_rgb8_parse_block(&block
, src
,
1255 false /* punchthrough_alpha */);
1256 etc2_rgb8_fetch_texel(&block
, i
% 4, j
% 4, dst
,
1257 false /* punchthrough_alpha */);
1259 texel
[RCOMP
] = UBYTE_TO_FLOAT(dst
[0]);
1260 texel
[GCOMP
] = UBYTE_TO_FLOAT(dst
[1]);
1261 texel
[BCOMP
] = UBYTE_TO_FLOAT(dst
[2]);
1262 texel
[ACOMP
] = 1.0f
;
1266 fetch_etc2_srgb8(const GLubyte
*map
,
1267 GLint rowStride
, GLint i
, GLint j
, GLfloat
*texel
)
1269 struct etc2_block block
;
1273 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1275 etc2_rgb8_parse_block(&block
, src
,
1276 false /* punchthrough_alpha */);
1277 etc2_rgb8_fetch_texel(&block
, i
% 4, j
% 4, dst
,
1278 false /* punchthrough_alpha */);
1280 texel
[RCOMP
] = _mesa_nonlinear_to_linear(dst
[0]);
1281 texel
[GCOMP
] = _mesa_nonlinear_to_linear(dst
[1]);
1282 texel
[BCOMP
] = _mesa_nonlinear_to_linear(dst
[2]);
1283 texel
[ACOMP
] = 1.0f
;
1287 fetch_etc2_rgba8_eac(const GLubyte
*map
,
1288 GLint rowStride
, GLint i
, GLint j
, GLfloat
*texel
)
1290 struct etc2_block block
;
1294 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 16;
1296 etc2_rgba8_parse_block(&block
, src
);
1297 etc2_rgba8_fetch_texel(&block
, i
% 4, j
% 4, dst
);
1299 texel
[RCOMP
] = UBYTE_TO_FLOAT(dst
[0]);
1300 texel
[GCOMP
] = UBYTE_TO_FLOAT(dst
[1]);
1301 texel
[BCOMP
] = UBYTE_TO_FLOAT(dst
[2]);
1302 texel
[ACOMP
] = UBYTE_TO_FLOAT(dst
[3]);
1306 fetch_etc2_srgb8_alpha8_eac(const GLubyte
*map
,
1307 GLint rowStride
, GLint i
, GLint j
, GLfloat
*texel
)
1309 struct etc2_block block
;
1313 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 16;
1315 etc2_rgba8_parse_block(&block
, src
);
1316 etc2_rgba8_fetch_texel(&block
, i
% 4, j
% 4, dst
);
1318 texel
[RCOMP
] = _mesa_nonlinear_to_linear(dst
[0]);
1319 texel
[GCOMP
] = _mesa_nonlinear_to_linear(dst
[1]);
1320 texel
[BCOMP
] = _mesa_nonlinear_to_linear(dst
[2]);
1321 texel
[ACOMP
] = UBYTE_TO_FLOAT(dst
[3]);
1325 fetch_etc2_r11_eac(const GLubyte
*map
,
1326 GLint rowStride
, GLint i
, GLint j
, GLfloat
*texel
)
1328 struct etc2_block block
;
1332 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1334 etc2_r11_parse_block(&block
, src
);
1335 etc2_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)&dst
);
1337 texel
[RCOMP
] = USHORT_TO_FLOAT(dst
);
1338 texel
[GCOMP
] = 0.0f
;
1339 texel
[BCOMP
] = 0.0f
;
1340 texel
[ACOMP
] = 1.0f
;
1344 fetch_etc2_rg11_eac(const GLubyte
*map
,
1345 GLint rowStride
, GLint i
, GLint j
, GLfloat
*texel
)
1347 struct etc2_block block
;
1351 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 16;
1354 etc2_r11_parse_block(&block
, src
);
1355 etc2_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)dst
);
1357 /* green component */
1358 etc2_r11_parse_block(&block
, src
+ 8);
1359 etc2_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)(dst
+ 1));
1361 texel
[RCOMP
] = USHORT_TO_FLOAT(dst
[0]);
1362 texel
[GCOMP
] = USHORT_TO_FLOAT(dst
[1]);
1363 texel
[BCOMP
] = 0.0f
;
1364 texel
[ACOMP
] = 1.0f
;
1368 fetch_etc2_signed_r11_eac(const GLubyte
*map
,
1369 GLint rowStride
, GLint i
, GLint j
, GLfloat
*texel
)
1371 struct etc2_block block
;
1375 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1377 etc2_r11_parse_block(&block
, src
);
1378 etc2_signed_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)&dst
);
1380 texel
[RCOMP
] = SHORT_TO_FLOAT(dst
);
1381 texel
[GCOMP
] = 0.0f
;
1382 texel
[BCOMP
] = 0.0f
;
1383 texel
[ACOMP
] = 1.0f
;
1387 fetch_etc2_signed_rg11_eac(const GLubyte
*map
,
1388 GLint rowStride
, GLint i
, GLint j
, GLfloat
*texel
)
1390 struct etc2_block block
;
1394 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 16;
1397 etc2_r11_parse_block(&block
, src
);
1398 etc2_signed_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)dst
);
1400 /* green component */
1401 etc2_r11_parse_block(&block
, src
+ 8);
1402 etc2_signed_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)(dst
+ 1));
1404 texel
[RCOMP
] = SHORT_TO_FLOAT(dst
[0]);
1405 texel
[GCOMP
] = SHORT_TO_FLOAT(dst
[1]);
1406 texel
[BCOMP
] = 0.0f
;
1407 texel
[ACOMP
] = 1.0f
;
1411 fetch_etc2_rgb8_punchthrough_alpha1(const GLubyte
*map
,
1412 GLint rowStride
, GLint i
, GLint j
,
1415 struct etc2_block block
;
1419 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1421 etc2_rgb8_parse_block(&block
, src
,
1422 true /* punchthrough alpha */);
1423 etc2_rgb8_fetch_texel(&block
, i
% 4, j
% 4, dst
,
1424 true /* punchthrough alpha */);
1425 texel
[RCOMP
] = UBYTE_TO_FLOAT(dst
[0]);
1426 texel
[GCOMP
] = UBYTE_TO_FLOAT(dst
[1]);
1427 texel
[BCOMP
] = UBYTE_TO_FLOAT(dst
[2]);
1428 texel
[ACOMP
] = UBYTE_TO_FLOAT(dst
[3]);
1432 fetch_etc2_srgb8_punchthrough_alpha1(const GLubyte
*map
,
1434 GLint i
, GLint j
, GLfloat
*texel
)
1436 struct etc2_block block
;
1440 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1442 etc2_rgb8_parse_block(&block
, src
,
1443 true /* punchthrough alpha */);
1444 etc2_rgb8_fetch_texel(&block
, i
% 4, j
% 4, dst
,
1445 true /* punchthrough alpha */);
1446 texel
[RCOMP
] = _mesa_nonlinear_to_linear(dst
[0]);
1447 texel
[GCOMP
] = _mesa_nonlinear_to_linear(dst
[1]);
1448 texel
[BCOMP
] = _mesa_nonlinear_to_linear(dst
[2]);
1449 texel
[ACOMP
] = UBYTE_TO_FLOAT(dst
[3]);
1453 compressed_fetch_func
1454 _mesa_get_etc_fetch_func(mesa_format format
)
1457 case MESA_FORMAT_ETC1_RGB8
:
1458 return fetch_etc1_rgb8
;
1459 case MESA_FORMAT_ETC2_RGB8
:
1460 return fetch_etc2_rgb8
;
1461 case MESA_FORMAT_ETC2_SRGB8
:
1462 return fetch_etc2_srgb8
;
1463 case MESA_FORMAT_ETC2_RGBA8_EAC
:
1464 return fetch_etc2_rgba8_eac
;
1465 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
1466 return fetch_etc2_srgb8_alpha8_eac
;
1467 case MESA_FORMAT_ETC2_R11_EAC
:
1468 return fetch_etc2_r11_eac
;
1469 case MESA_FORMAT_ETC2_RG11_EAC
:
1470 return fetch_etc2_rg11_eac
;
1471 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
1472 return fetch_etc2_signed_r11_eac
;
1473 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
1474 return fetch_etc2_signed_rg11_eac
;
1475 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
1476 return fetch_etc2_rgb8_punchthrough_alpha1
;
1477 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
1478 return fetch_etc2_srgb8_punchthrough_alpha1
;