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 "mfeatures.h"
42 #include "texcompress.h"
43 #include "texcompress_etc.h"
46 #include "format_unpack.h"
51 uint64_t pixel_indices
[2];
52 const int *modifier_tables
[2];
60 uint8_t base_colors
[3][3];
61 uint8_t paint_colors
[4][3];
62 uint8_t base_codeword
;
67 static const int etc2_distance_table
[8] = {
68 3, 6, 11, 16, 23, 32, 41, 64 };
70 static const int etc2_modifier_tables
[16][8] = {
71 { -3, -6, -9, -15, 2, 5, 8, 14},
72 { -3, -7, -10, -13, 2, 6, 9, 12},
73 { -2, -5, -8, -13, 1, 4, 7, 12},
74 { -2, -4, -6, -13, 1, 3, 5, 12},
75 { -3, -6, -8, -12, 2, 5, 7, 11},
76 { -3, -7, -9, -11, 2, 6, 8, 10},
77 { -4, -7, -8, -11, 3, 6, 7, 10},
78 { -3, -5, -8, -11, 2, 4, 7, 10},
79 { -2, -6, -8, -10, 1, 5, 7, 9},
80 { -2, -5, -8, -10, 1, 4, 7, 9},
81 { -2, -4, -8, -10, 1, 3, 7, 9},
82 { -2, -5, -7, -10, 1, 4, 6, 9},
83 { -3, -4, -7, -10, 2, 3, 6, 9},
84 { -1, -2, -3, -10, 0, 1, 2, 9},
85 { -4, -6, -8, -9, 3, 5, 7, 8},
86 { -3, -5, -7, -9, 2, 4, 6, 8},
89 static const int etc2_modifier_tables_non_opaque
[8][4] = {
100 /* define etc1_parse_block and etc. */
101 #define UINT8_TYPE GLubyte
103 #include "texcompress_etc_tmp.h"
108 _mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS
)
110 /* GL_ETC1_RGB8_OES is only valid in glCompressedTexImage2D */
118 * Decode texture data in format `MESA_FORMAT_ETC1_RGB8` to
119 * `MESA_FORMAT_ABGR8888`.
121 * The size of the source data must be a multiple of the ETC1 block size,
122 * which is 8, even if the texture image's dimensions are not aligned to 4.
123 * From the GL_OES_compressed_ETC1_RGB8_texture spec:
124 * The texture is described as a number of 4x4 pixel blocks. If the
125 * texture (or a particular mip-level) is smaller than 4 pixels in
126 * any dimension (such as a 2x2 or a 8x1 texture), the texture is
127 * found in the upper left part of the block(s), and the rest of the
128 * pixels are not used. For instance, a texture of size 4x2 will be
129 * placed in the upper half of a 4x4 block, and the lower half of the
130 * pixels in the block will not be accessed.
132 * \param src_width in pixels
133 * \param src_height in pixels
134 * \param dst_stride in bytes
137 _mesa_etc1_unpack_rgba8888(uint8_t *dst_row
,
139 const uint8_t *src_row
,
144 etc1_unpack_rgba8888(dst_row
, dst_stride
,
146 src_width
, src_height
);
150 etc2_base_color1_t_mode(const uint8_t *in
, GLuint index
)
152 uint8_t R1a
= 0, x
= 0;
153 /* base col 1 = extend_4to8bits( (R1a << 2) | R1b, G1, B1) */
156 R1a
= (in
[0] >> 3) & 0x3;
157 x
= ((R1a
<< 2) | (in
[0] & 0x3));
160 x
= ((in
[1] >> 4) & 0xf);
169 return ((x
<< 4) | (x
& 0xf));
173 etc2_base_color2_t_mode(const uint8_t *in
, GLuint index
)
176 /*extend 4to8bits(R2, G2, B2)*/
179 x
= ((in
[2] >> 4) & 0xf );
185 x
= ((in
[3] >> 4) & 0xf);
191 return ((x
<< 4) | (x
& 0xf));
195 etc2_base_color1_h_mode(const uint8_t *in
, GLuint index
)
198 /* base col 1 = extend 4to8bits(R1, (G1a << 1) | G1b, (B1a << 3) | B1b) */
201 x
= ((in
[0] >> 3) & 0xf);
204 x
= (((in
[0] & 0x7) << 1) | ((in
[1] >> 4) & 0x1));
208 (((in
[1] & 0x3) << 1) | ((in
[2] >> 7) & 0x1)));
214 return ((x
<< 4) | (x
& 0xf));
218 etc2_base_color2_h_mode(const uint8_t *in
, GLuint index
)
221 /* base col 2 = extend 4to8bits(R2, G2, B2) */
224 x
= ((in
[2] >> 3) & 0xf );
227 x
= (((in
[2] & 0x7) << 1) | ((in
[3] >> 7) & 0x1));
230 x
= ((in
[3] >> 3) & 0xf);
236 return ((x
<< 4) | (x
& 0xf));
240 etc2_base_color_o_planar(const uint8_t *in
, GLuint index
)
245 tmp
= ((in
[0] >> 1) & 0x3f); /* RO */
246 return ((tmp
<< 2) | (tmp
>> 4));
248 tmp
= (((in
[0] & 0x1) << 6) | /* GO1 */
249 ((in
[1] >> 1) & 0x3f)); /* GO2 */
250 return ((tmp
<< 1) | (tmp
>> 6));
252 tmp
= (((in
[1] & 0x1) << 5) | /* BO1 */
253 (in
[2] & 0x18) | /* BO2 */
254 (((in
[2] & 0x3) << 1) | ((in
[3] >> 7) & 0x1))); /* BO3 */
255 return ((tmp
<< 2) | (tmp
>> 4));
263 etc2_base_color_h_planar(const uint8_t *in
, GLuint index
)
268 tmp
= (((in
[3] & 0x7c) >> 1) | /* RH1 */
269 (in
[3] & 0x1)); /* RH2 */
270 return ((tmp
<< 2) | (tmp
>> 4));
272 tmp
= (in
[4] >> 1) & 0x7f; /* GH */
273 return ((tmp
<< 1) | (tmp
>> 6));
275 tmp
= (((in
[4] & 0x1) << 5) |
276 ((in
[5] >> 3) & 0x1f)); /* BH */
277 return ((tmp
<< 2) | (tmp
>> 4));
285 etc2_base_color_v_planar(const uint8_t *in
, GLuint index
)
290 tmp
= (((in
[5] & 0x7) << 0x3) |
291 ((in
[6] >> 5) & 0x7)); /* RV */
292 return ((tmp
<< 2) | (tmp
>> 4));
294 tmp
= (((in
[6] & 0x1f) << 2) |
295 ((in
[7] >> 6) & 0x3)); /* GV */
296 return ((tmp
<< 1) | (tmp
>> 6));
298 tmp
= in
[7] & 0x3f; /* BV */
299 return ((tmp
<< 2) | (tmp
>> 4));
307 etc2_get_pixel_index(const struct etc2_block
*block
, int x
, int y
)
309 int bit
= ((3 - y
) + (3 - x
) * 4) * 3;
310 int idx
= (block
->pixel_indices
[1] >> bit
) & 0x7;
315 etc2_clamp(int color
)
317 /* CLAMP(color, 0, 255) */
318 return (uint8_t) CLAMP(color
, 0, 255);
322 etc2_clamp2(int color
)
324 /* CLAMP(color, 0, 2047) */
325 return (GLushort
) CLAMP(color
, 0, 2047);
329 etc2_clamp3(int color
)
331 /* CLAMP(color, -1023, 1023) */
332 return (GLshort
) CLAMP(color
, -1023, 1023);
336 etc2_rgb8_parse_block(struct etc2_block
*block
,
338 GLboolean punchthrough_alpha
)
341 GLboolean diffbit
= false;
342 static const int lookup
[8] = { 0, 1, 2, 3, -4, -3, -2, -1 };
344 const int R_plus_dR
= (src
[0] >> 3) + lookup
[src
[0] & 0x7];
345 const int G_plus_dG
= (src
[1] >> 3) + lookup
[src
[1] & 0x7];
346 const int B_plus_dB
= (src
[2] >> 3) + lookup
[src
[2] & 0x7];
348 /* Reset the mode flags */
349 block
->is_ind_mode
= false;
350 block
->is_diff_mode
= false;
351 block
->is_t_mode
= false;
352 block
->is_h_mode
= false;
353 block
->is_planar_mode
= false;
355 if (punchthrough_alpha
)
356 block
->opaque
= src
[3] & 0x2;
358 diffbit
= src
[3] & 0x2;
360 if (!diffbit
&& !punchthrough_alpha
) {
361 /* individual mode */
362 block
->is_ind_mode
= true;
364 for (i
= 0; i
< 3; i
++) {
365 /* Texture decode algorithm is same for individual mode in etc1
368 block
->base_colors
[0][i
] = etc1_base_color_ind_hi(src
[i
]);
369 block
->base_colors
[1][i
] = etc1_base_color_ind_lo(src
[i
]);
372 else if (R_plus_dR
< 0 || R_plus_dR
> 31){
374 block
->is_t_mode
= true;
376 for(i
= 0; i
< 3; i
++) {
377 block
->base_colors
[0][i
] = etc2_base_color1_t_mode(src
, i
);
378 block
->base_colors
[1][i
] = etc2_base_color2_t_mode(src
, i
);
382 etc2_distance_table
[(((src
[3] >> 2) & 0x3) << 1) |
385 for (i
= 0; i
< 3; i
++) {
386 block
->paint_colors
[0][i
] = etc2_clamp(block
->base_colors
[0][i
]);
387 block
->paint_colors
[1][i
] = etc2_clamp(block
->base_colors
[1][i
] +
389 block
->paint_colors
[2][i
] = etc2_clamp(block
->base_colors
[1][i
]);
390 block
->paint_colors
[3][i
] = etc2_clamp(block
->base_colors
[1][i
] -
394 else if (G_plus_dG
< 0 || G_plus_dG
> 31){
395 int base_color_1_value
, base_color_2_value
;
398 block
->is_h_mode
= true;
400 for(i
= 0; i
< 3; i
++) {
401 block
->base_colors
[0][i
] = etc2_base_color1_h_mode(src
, i
);
402 block
->base_colors
[1][i
] = etc2_base_color2_h_mode(src
, i
);
405 base_color_1_value
= (block
->base_colors
[0][0] << 16) +
406 (block
->base_colors
[0][1] << 8) +
407 block
->base_colors
[0][2];
408 base_color_2_value
= (block
->base_colors
[1][0] << 16) +
409 (block
->base_colors
[1][1] << 8) +
410 block
->base_colors
[1][2];
413 etc2_distance_table
[(src
[3] & 0x4) |
414 ((src
[3] & 0x1) << 1) |
415 (base_color_1_value
>= base_color_2_value
)];
417 for (i
= 0; i
< 3; i
++) {
418 block
->paint_colors
[0][i
] = etc2_clamp(block
->base_colors
[0][i
] +
420 block
->paint_colors
[1][i
] = etc2_clamp(block
->base_colors
[0][i
] -
422 block
->paint_colors
[2][i
] = etc2_clamp(block
->base_colors
[1][i
] +
424 block
->paint_colors
[3][i
] = etc2_clamp(block
->base_colors
[1][i
] -
428 else if (B_plus_dB
< 0 || B_plus_dB
> 31) {
430 block
->is_planar_mode
= true;
432 /* opaque bit must be set in planar mode */
434 block
->opaque
= true;
436 for (i
= 0; i
< 3; i
++) {
437 block
->base_colors
[0][i
] = etc2_base_color_o_planar(src
, i
);
438 block
->base_colors
[1][i
] = etc2_base_color_h_planar(src
, i
);
439 block
->base_colors
[2][i
] = etc2_base_color_v_planar(src
, i
);
442 else if (diffbit
|| punchthrough_alpha
) {
443 /* differential mode */
444 block
->is_diff_mode
= true;
446 for (i
= 0; i
< 3; i
++) {
447 /* Texture decode algorithm is same for differential mode in etc1
450 block
->base_colors
[0][i
] = etc1_base_color_diff_hi(src
[i
]);
451 block
->base_colors
[1][i
] = etc1_base_color_diff_lo(src
[i
]);
455 if (block
->is_ind_mode
|| block
->is_diff_mode
) {
456 int table1_idx
= (src
[3] >> 5) & 0x7;
457 int table2_idx
= (src
[3] >> 2) & 0x7;
459 /* Use same modifier tables as for etc1 textures if opaque bit is set
460 * or if non punchthrough texture format
462 block
->modifier_tables
[0] = (block
->opaque
|| !punchthrough_alpha
) ?
463 etc1_modifier_tables
[table1_idx
] :
464 etc2_modifier_tables_non_opaque
[table1_idx
];
465 block
->modifier_tables
[1] = (block
->opaque
|| !punchthrough_alpha
) ?
466 etc1_modifier_tables
[table2_idx
] :
467 etc2_modifier_tables_non_opaque
[table2_idx
];
469 block
->flipped
= (src
[3] & 0x1);
472 block
->pixel_indices
[0] =
473 (src
[4] << 24) | (src
[5] << 16) | (src
[6] << 8) | src
[7];
477 etc2_rgb8_fetch_texel(const struct etc2_block
*block
,
478 int x
, int y
, uint8_t *dst
,
479 GLboolean punchthrough_alpha
)
481 const uint8_t *base_color
;
482 int modifier
, bit
, idx
, blk
;
484 /* get pixel index */
486 idx
= ((block
->pixel_indices
[0] >> (15 + bit
)) & 0x2) |
487 ((block
->pixel_indices
[0] >> (bit
)) & 0x1);
489 if (block
->is_ind_mode
|| block
->is_diff_mode
) {
490 /* check for punchthrough_alpha format */
491 if (punchthrough_alpha
) {
492 if (!block
->opaque
&& idx
== 2) {
493 dst
[0] = dst
[1] = dst
[2] = dst
[3] = 0;
500 /* Use pixel index and subblock to get the modifier */
501 blk
= (block
->flipped
) ? (y
>= 2) : (x
>= 2);
502 base_color
= block
->base_colors
[blk
];
503 modifier
= block
->modifier_tables
[blk
][idx
];
505 dst
[0] = etc2_clamp(base_color
[0] + modifier
);
506 dst
[1] = etc2_clamp(base_color
[1] + modifier
);
507 dst
[2] = etc2_clamp(base_color
[2] + modifier
);
509 else if (block
->is_t_mode
|| block
->is_h_mode
) {
510 /* check for punchthrough_alpha format */
511 if (punchthrough_alpha
) {
512 if (!block
->opaque
&& idx
== 2) {
513 dst
[0] = dst
[1] = dst
[2] = dst
[3] = 0;
520 /* Use pixel index to pick one of the paint colors */
521 dst
[0] = block
->paint_colors
[idx
][0];
522 dst
[1] = block
->paint_colors
[idx
][1];
523 dst
[2] = block
->paint_colors
[idx
][2];
525 else if (block
->is_planar_mode
) {
526 /* {R(x, y) = clamp255((x × (RH − RO) + y × (RV − RO) + 4 × RO + 2) >> 2)
527 * {G(x, y) = clamp255((x × (GH − GO) + y × (GV − GO) + 4 × GO + 2) >> 2)
528 * {B(x, y) = clamp255((x × (BH − BO) + y × (BV − BO) + 4 × BO + 2) >> 2)
530 int red
, green
, blue
;
531 red
= (x
* (block
->base_colors
[1][0] - block
->base_colors
[0][0]) +
532 y
* (block
->base_colors
[2][0] - block
->base_colors
[0][0]) +
533 4 * block
->base_colors
[0][0] + 2) >> 2;
535 green
= (x
* (block
->base_colors
[1][1] - block
->base_colors
[0][1]) +
536 y
* (block
->base_colors
[2][1] - block
->base_colors
[0][1]) +
537 4 * block
->base_colors
[0][1] + 2) >> 2;
539 blue
= (x
* (block
->base_colors
[1][2] - block
->base_colors
[0][2]) +
540 y
* (block
->base_colors
[2][2] - block
->base_colors
[0][2]) +
541 4 * block
->base_colors
[0][2] + 2) >> 2;
543 dst
[0] = etc2_clamp(red
);
544 dst
[1] = etc2_clamp(green
);
545 dst
[2] = etc2_clamp(blue
);
547 /* check for punchthrough_alpha format */
548 if (punchthrough_alpha
)
554 etc2_alpha8_fetch_texel(const struct etc2_block
*block
,
555 int x
, int y
, uint8_t *dst
)
557 int modifier
, alpha
, idx
;
558 /* get pixel index */
559 idx
= etc2_get_pixel_index(block
, x
, y
);
560 modifier
= etc2_modifier_tables
[block
->table_index
][idx
];
561 alpha
= block
->base_codeword
+ modifier
* block
->multiplier
;
562 dst
[3] = etc2_clamp(alpha
);
566 etc2_r11_fetch_texel(const struct etc2_block
*block
,
567 int x
, int y
, uint8_t *dst
)
571 /* Get pixel index */
572 idx
= etc2_get_pixel_index(block
, x
, y
);
573 modifier
= etc2_modifier_tables
[block
->table_index
][idx
];
575 if (block
->multiplier
!= 0)
576 /* clamp2(base codeword × 8 + 4 + modifier × multiplier × 8) */
577 color
= etc2_clamp2(((block
->base_codeword
<< 3) | 0x4) +
578 ((modifier
* block
->multiplier
) << 3));
580 color
= etc2_clamp2(((block
->base_codeword
<< 3) | 0x4) + modifier
);
582 /* Extend 11 bits color value to 16 bits. OpenGL ES 3.0 specification
583 * allows extending the color value to any number of bits. But, an
584 * implementation is not allowed to truncate the 11-bit value to less than
587 color
= (color
<< 5) | (color
>> 6);
588 ((GLushort
*)dst
)[0] = color
;
592 etc2_signed_r11_fetch_texel(const struct etc2_block
*block
,
593 int x
, int y
, uint8_t *dst
)
597 GLbyte base_codeword
= (GLbyte
) block
->base_codeword
;
599 if (base_codeword
== -128)
600 base_codeword
= -127;
602 /* Get pixel index */
603 idx
= etc2_get_pixel_index(block
, x
, y
);
604 modifier
= etc2_modifier_tables
[block
->table_index
][idx
];
606 if (block
->multiplier
!= 0)
607 /* clamp3(base codeword × 8 + modifier × multiplier × 8) */
608 color
= etc2_clamp3((base_codeword
<< 3) +
609 ((modifier
* block
->multiplier
) << 3));
611 color
= etc2_clamp3((base_codeword
<< 3) + modifier
);
613 /* Extend 11 bits color value to 16 bits. OpenGL ES 3.0 specification
614 * allows extending the color value to any number of bits. But, an
615 * implementation is not allowed to truncate the 11-bit value to less than
616 * 11 bits. A negative 11-bit value must first be made positive before bit
617 * replication, and then made negative again
620 color
= (color
<< 5) | (color
>> 5);
623 color
= (color
<< 5) | (color
>> 5);
626 ((GLshort
*)dst
)[0] = color
;
630 etc2_alpha8_parse_block(struct etc2_block
*block
, const uint8_t *src
)
632 block
->base_codeword
= src
[0];
633 block
->multiplier
= (src
[1] >> 4) & 0xf;
634 block
->table_index
= src
[1] & 0xf;
635 block
->pixel_indices
[1] = (((uint64_t)src
[2] << 40) |
636 ((uint64_t)src
[3] << 32) |
637 ((uint64_t)src
[4] << 24) |
638 ((uint64_t)src
[5] << 16) |
639 ((uint64_t)src
[6] << 8) |
644 etc2_r11_parse_block(struct etc2_block
*block
, const uint8_t *src
)
646 /* Parsing logic remains same as for etc2_alpha8_parse_block */
647 etc2_alpha8_parse_block(block
, src
);
651 etc2_rgba8_parse_block(struct etc2_block
*block
, const uint8_t *src
)
653 /* RGB component is parsed the same way as for MESA_FORMAT_ETC2_RGB8 */
654 etc2_rgb8_parse_block(block
, src
+ 8,
655 false /* punchthrough_alpha */);
656 /* Parse Alpha component */
657 etc2_alpha8_parse_block(block
, src
);
661 etc2_rgba8_fetch_texel(const struct etc2_block
*block
,
662 int x
, int y
, uint8_t *dst
)
664 etc2_rgb8_fetch_texel(block
, x
, y
, dst
,
665 false /* punchthrough_alpha */);
666 etc2_alpha8_fetch_texel(block
, x
, y
, dst
);
670 etc2_unpack_rgb8(uint8_t *dst_row
,
672 const uint8_t *src_row
,
677 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 4;
678 struct etc2_block block
;
681 for (y
= 0; y
< height
; y
+= bh
) {
682 const uint8_t *src
= src_row
;
684 for (x
= 0; x
< width
; x
+= bw
) {
685 etc2_rgb8_parse_block(&block
, src
,
686 false /* punchthrough_alpha */);
688 for (j
= 0; j
< bh
; j
++) {
689 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
690 for (i
= 0; i
< bw
; i
++) {
691 etc2_rgb8_fetch_texel(&block
, i
, j
, dst
,
692 false /* punchthrough_alpha */);
701 src_row
+= src_stride
;
706 etc2_unpack_srgb8(uint8_t *dst_row
,
708 const uint8_t *src_row
,
713 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 4;
714 struct etc2_block block
;
718 for (y
= 0; y
< height
; y
+= bh
) {
719 const uint8_t *src
= src_row
;
721 for (x
= 0; x
< width
; x
+= bw
) {
722 etc2_rgb8_parse_block(&block
, src
,
723 false /* punchthrough_alpha */);
725 for (j
= 0; j
< bh
; j
++) {
726 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
727 for (i
= 0; i
< bw
; i
++) {
728 etc2_rgb8_fetch_texel(&block
, i
, j
, dst
,
729 false /* punchthrough_alpha */);
730 /* Convert to MESA_FORMAT_SARGB8 */
742 src_row
+= src_stride
;
747 etc2_unpack_rgba8(uint8_t *dst_row
,
749 const uint8_t *src_row
,
754 /* If internalformat is COMPRESSED_RGBA8_ETC2_EAC, each 4 × 4 block of
755 * RGBA8888 information is compressed to 128 bits. To decode a block, the
756 * two 64-bit integers int64bitAlpha and int64bitColor are calculated.
758 const unsigned bw
= 4, bh
= 4, bs
= 16, comps
= 4;
759 struct etc2_block block
;
762 for (y
= 0; y
< height
; y
+= bh
) {
763 const uint8_t *src
= src_row
;
765 for (x
= 0; x
< width
; x
+= bw
) {
766 etc2_rgba8_parse_block(&block
, src
);
768 for (j
= 0; j
< bh
; j
++) {
769 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
770 for (i
= 0; i
< bw
; i
++) {
771 etc2_rgba8_fetch_texel(&block
, i
, j
, dst
);
778 src_row
+= src_stride
;
783 etc2_unpack_srgb8_alpha8(uint8_t *dst_row
,
785 const uint8_t *src_row
,
790 /* If internalformat is COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, each 4 × 4 block
791 * of RGBA8888 information is compressed to 128 bits. To decode a block, the
792 * two 64-bit integers int64bitAlpha and int64bitColor are calculated.
794 const unsigned bw
= 4, bh
= 4, bs
= 16, comps
= 4;
795 struct etc2_block block
;
799 for (y
= 0; y
< height
; y
+= bh
) {
800 const uint8_t *src
= src_row
;
802 for (x
= 0; x
< width
; x
+= bw
) {
803 etc2_rgba8_parse_block(&block
, src
);
805 for (j
= 0; j
< bh
; j
++) {
806 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
807 for (i
= 0; i
< bw
; i
++) {
808 etc2_rgba8_fetch_texel(&block
, i
, j
, dst
);
810 /* Convert to MESA_FORMAT_SARGB8 */
822 src_row
+= src_stride
;
827 etc2_unpack_r11(uint8_t *dst_row
,
829 const uint8_t *src_row
,
834 /* If internalformat is COMPRESSED_R11_EAC, each 4 × 4 block of
835 color information is compressed to 64 bits.
837 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 1, comp_size
= 2;
838 struct etc2_block block
;
841 for (y
= 0; y
< height
; y
+= bh
) {
842 const uint8_t *src
= src_row
;
844 for (x
= 0; x
< width
; x
+= bw
) {
845 etc2_r11_parse_block(&block
, src
);
847 for (j
= 0; j
< bh
; j
++) {
848 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
* comp_size
;
849 for (i
= 0; i
< bw
; i
++) {
850 etc2_r11_fetch_texel(&block
, i
, j
, dst
);
851 dst
+= comps
* comp_size
;
857 src_row
+= src_stride
;
862 etc2_unpack_rg11(uint8_t *dst_row
,
864 const uint8_t *src_row
,
869 /* If internalformat is COMPRESSED_RG11_EAC, each 4 × 4 block of
870 RG color information is compressed to 128 bits.
872 const unsigned bw
= 4, bh
= 4, bs
= 16, comps
= 2, comp_size
= 2;
873 struct etc2_block block
;
876 for (y
= 0; y
< height
; y
+= bh
) {
877 const uint8_t *src
= src_row
;
879 for (x
= 0; x
< width
; x
+= bw
) {
881 etc2_r11_parse_block(&block
, src
);
883 for (j
= 0; j
< bh
; j
++) {
884 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+
885 x
* comps
* comp_size
;
886 for (i
= 0; i
< bw
; i
++) {
887 etc2_r11_fetch_texel(&block
, i
, j
, dst
);
888 dst
+= comps
* comp_size
;
891 /* green component */
892 etc2_r11_parse_block(&block
, src
+ 8);
894 for (j
= 0; j
< bh
; j
++) {
895 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+
896 x
* comps
* comp_size
;
897 for (i
= 0; i
< bw
; i
++) {
898 etc2_r11_fetch_texel(&block
, i
, j
, dst
+ comp_size
);
899 dst
+= comps
* comp_size
;
905 src_row
+= src_stride
;
910 etc2_unpack_signed_r11(uint8_t *dst_row
,
912 const uint8_t *src_row
,
917 /* If internalformat is COMPRESSED_SIGNED_R11_EAC, each 4 × 4 block of
918 red color information is compressed to 64 bits.
920 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 1, comp_size
= 2;
921 struct etc2_block block
;
924 for (y
= 0; y
< height
; y
+= bh
) {
925 const uint8_t *src
= src_row
;
927 for (x
= 0; x
< width
; x
+= bw
) {
928 etc2_r11_parse_block(&block
, src
);
930 for (j
= 0; j
< bh
; j
++) {
931 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+
932 x
* comps
* comp_size
;
933 for (i
= 0; i
< bw
; i
++) {
934 etc2_signed_r11_fetch_texel(&block
, i
, j
, dst
);
935 dst
+= comps
* comp_size
;
941 src_row
+= src_stride
;
946 etc2_unpack_signed_rg11(uint8_t *dst_row
,
948 const uint8_t *src_row
,
953 /* If internalformat is COMPRESSED_SIGNED_RG11_EAC, each 4 × 4 block of
954 RG color information is compressed to 128 bits.
956 const unsigned bw
= 4, bh
= 4, bs
= 16, comps
= 2, comp_size
= 2;
957 struct etc2_block block
;
960 for (y
= 0; y
< height
; y
+= bh
) {
961 const uint8_t *src
= src_row
;
963 for (x
= 0; x
< width
; x
+= bw
) {
965 etc2_r11_parse_block(&block
, src
);
967 for (j
= 0; j
< bh
; j
++) {
968 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+
969 x
* comps
* comp_size
;
970 for (i
= 0; i
< bw
; i
++) {
971 etc2_signed_r11_fetch_texel(&block
, i
, j
, dst
);
972 dst
+= comps
* comp_size
;
975 /* green component */
976 etc2_r11_parse_block(&block
, src
+ 8);
978 for (j
= 0; j
< bh
; j
++) {
979 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+
980 x
* comps
* comp_size
;
981 for (i
= 0; i
< bw
; i
++) {
982 etc2_signed_r11_fetch_texel(&block
, i
, j
, dst
+ comp_size
);
983 dst
+= comps
* comp_size
;
989 src_row
+= src_stride
;
994 etc2_unpack_rgb8_punchthrough_alpha1(uint8_t *dst_row
,
996 const uint8_t *src_row
,
1001 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 4;
1002 struct etc2_block block
;
1003 unsigned x
, y
, i
, j
;
1005 for (y
= 0; y
< height
; y
+= bh
) {
1006 const uint8_t *src
= src_row
;
1008 for (x
= 0; x
< width
; x
+= bw
) {
1009 etc2_rgb8_parse_block(&block
, src
,
1010 true /* punchthrough_alpha */);
1011 for (j
= 0; j
< bh
; j
++) {
1012 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
1013 for (i
= 0; i
< bw
; i
++) {
1014 etc2_rgb8_fetch_texel(&block
, i
, j
, dst
,
1015 true /* punchthrough_alpha */);
1023 src_row
+= src_stride
;
1028 etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row
,
1029 unsigned dst_stride
,
1030 const uint8_t *src_row
,
1031 unsigned src_stride
,
1035 const unsigned bw
= 4, bh
= 4, bs
= 8, comps
= 4;
1036 struct etc2_block block
;
1037 unsigned x
, y
, i
, j
;
1040 for (y
= 0; y
< height
; y
+= bh
) {
1041 const uint8_t *src
= src_row
;
1043 for (x
= 0; x
< width
; x
+= bw
) {
1044 etc2_rgb8_parse_block(&block
, src
,
1045 true /* punchthrough_alpha */);
1046 for (j
= 0; j
< bh
; j
++) {
1047 uint8_t *dst
= dst_row
+ (y
+ j
) * dst_stride
+ x
* comps
;
1048 for (i
= 0; i
< bw
; i
++) {
1049 etc2_rgb8_fetch_texel(&block
, i
, j
, dst
,
1050 true /* punchthrough_alpha */);
1051 /* Convert to MESA_FORMAT_SARGB8 */
1064 src_row
+= src_stride
;
1068 /* ETC2 texture formats are valid in glCompressedTexImage2D and
1069 * glCompressedTexSubImage2D functions */
1071 _mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS
)
1079 _mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS
)
1087 _mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS
)
1095 _mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS
)
1103 _mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS
)
1111 _mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS
)
1119 _mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS
)
1127 _mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS
)
1135 _mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS
)
1143 _mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS
)
1152 * Decode texture data in any one of following formats:
1153 * `MESA_FORMAT_ETC2_RGB8`
1154 * `MESA_FORMAT_ETC2_SRGB8`
1155 * `MESA_FORMAT_ETC2_RGBA8_EAC`
1156 * `MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC`
1157 * `MESA_FORMAT_ETC2_R11_EAC`
1158 * `MESA_FORMAT_ETC2_RG11_EAC`
1159 * `MESA_FORMAT_ETC2_SIGNED_R11_EAC`
1160 * `MESA_FORMAT_ETC2_SIGNED_RG11_EAC`
1161 * `MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1`
1162 * `MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1`
1164 * The size of the source data must be a multiple of the ETC2 block size
1165 * even if the texture image's dimensions are not aligned to 4.
1167 * \param src_width in pixels
1168 * \param src_height in pixels
1169 * \param dst_stride in bytes
1173 _mesa_unpack_etc2_format(uint8_t *dst_row
,
1174 unsigned dst_stride
,
1175 const uint8_t *src_row
,
1176 unsigned src_stride
,
1178 unsigned src_height
,
1181 if (format
== MESA_FORMAT_ETC2_RGB8
)
1182 etc2_unpack_rgb8(dst_row
, dst_stride
,
1183 src_row
, src_stride
,
1184 src_width
, src_height
);
1185 else if (format
== MESA_FORMAT_ETC2_SRGB8
)
1186 etc2_unpack_srgb8(dst_row
, dst_stride
,
1187 src_row
, src_stride
,
1188 src_width
, src_height
);
1189 else if (format
== MESA_FORMAT_ETC2_RGBA8_EAC
)
1190 etc2_unpack_rgba8(dst_row
, dst_stride
,
1191 src_row
, src_stride
,
1192 src_width
, src_height
);
1193 else if (format
== MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
)
1194 etc2_unpack_srgb8_alpha8(dst_row
, dst_stride
,
1195 src_row
, src_stride
,
1196 src_width
, src_height
);
1197 else if (format
== MESA_FORMAT_ETC2_R11_EAC
)
1198 etc2_unpack_r11(dst_row
, dst_stride
,
1199 src_row
, src_stride
,
1200 src_width
, src_height
);
1201 else if (format
== MESA_FORMAT_ETC2_RG11_EAC
)
1202 etc2_unpack_rg11(dst_row
, dst_stride
,
1203 src_row
, src_stride
,
1204 src_width
, src_height
);
1205 else if (format
== MESA_FORMAT_ETC2_SIGNED_R11_EAC
)
1206 etc2_unpack_signed_r11(dst_row
, dst_stride
,
1207 src_row
, src_stride
,
1208 src_width
, src_height
);
1209 else if (format
== MESA_FORMAT_ETC2_SIGNED_RG11_EAC
)
1210 etc2_unpack_signed_rg11(dst_row
, dst_stride
,
1211 src_row
, src_stride
,
1212 src_width
, src_height
);
1213 else if (format
== MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
)
1214 etc2_unpack_rgb8_punchthrough_alpha1(dst_row
, dst_stride
,
1215 src_row
, src_stride
,
1216 src_width
, src_height
);
1217 else if (format
== MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
)
1218 etc2_unpack_srgb8_punchthrough_alpha1(dst_row
, dst_stride
,
1219 src_row
, src_stride
,
1220 src_width
, src_height
);
1226 fetch_etc1_rgb8(const GLubyte
*map
, const GLuint imageOffsets
[],
1227 GLint rowStride
, GLint i
, GLint j
, GLint k
,
1230 struct etc1_block block
;
1234 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1236 etc1_parse_block(&block
, src
);
1237 etc1_fetch_texel(&block
, i
% 4, j
% 4, dst
);
1239 texel
[RCOMP
] = UBYTE_TO_FLOAT(dst
[0]);
1240 texel
[GCOMP
] = UBYTE_TO_FLOAT(dst
[1]);
1241 texel
[BCOMP
] = UBYTE_TO_FLOAT(dst
[2]);
1242 texel
[ACOMP
] = 1.0f
;
1247 fetch_etc2_rgb8(const GLubyte
*map
, const GLuint imageOffsets
[],
1248 GLint rowStride
, GLint i
, GLint j
, GLint k
,
1251 struct etc2_block block
;
1255 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1257 etc2_rgb8_parse_block(&block
, src
,
1258 false /* punchthrough_alpha */);
1259 etc2_rgb8_fetch_texel(&block
, i
% 4, j
% 4, dst
,
1260 false /* punchthrough_alpha */);
1262 texel
[RCOMP
] = UBYTE_TO_FLOAT(dst
[0]);
1263 texel
[GCOMP
] = UBYTE_TO_FLOAT(dst
[1]);
1264 texel
[BCOMP
] = UBYTE_TO_FLOAT(dst
[2]);
1265 texel
[ACOMP
] = 1.0f
;
1269 fetch_etc2_srgb8(const GLubyte
*map
, const GLuint imageOffsets
[],
1270 GLint rowStride
, GLint i
, GLint j
, GLint k
,
1273 struct etc2_block block
;
1277 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1279 etc2_rgb8_parse_block(&block
, src
,
1280 false /* punchthrough_alpha */);
1281 etc2_rgb8_fetch_texel(&block
, i
% 4, j
% 4, dst
,
1282 false /* punchthrough_alpha */);
1284 texel
[RCOMP
] = _mesa_nonlinear_to_linear(dst
[0]);
1285 texel
[GCOMP
] = _mesa_nonlinear_to_linear(dst
[1]);
1286 texel
[BCOMP
] = _mesa_nonlinear_to_linear(dst
[2]);
1287 texel
[ACOMP
] = 1.0f
;
1291 fetch_etc2_rgba8_eac(const GLubyte
*map
, const GLuint imageOffsets
[],
1292 GLint rowStride
, GLint i
, GLint j
, GLint k
,
1295 struct etc2_block block
;
1299 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 16;
1301 etc2_rgba8_parse_block(&block
, src
);
1302 etc2_rgba8_fetch_texel(&block
, i
% 4, j
% 4, dst
);
1304 texel
[RCOMP
] = UBYTE_TO_FLOAT(dst
[0]);
1305 texel
[GCOMP
] = UBYTE_TO_FLOAT(dst
[1]);
1306 texel
[BCOMP
] = UBYTE_TO_FLOAT(dst
[2]);
1307 texel
[ACOMP
] = UBYTE_TO_FLOAT(dst
[3]);
1311 fetch_etc2_srgb8_alpha8_eac(const GLubyte
*map
, const GLuint imageOffsets
[],
1312 GLint rowStride
, GLint i
, GLint j
, GLint k
,
1315 struct etc2_block block
;
1319 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 16;
1321 etc2_rgba8_parse_block(&block
, src
);
1322 etc2_rgba8_fetch_texel(&block
, i
% 4, j
% 4, dst
);
1324 texel
[RCOMP
] = _mesa_nonlinear_to_linear(dst
[0]);
1325 texel
[GCOMP
] = _mesa_nonlinear_to_linear(dst
[1]);
1326 texel
[BCOMP
] = _mesa_nonlinear_to_linear(dst
[2]);
1327 texel
[ACOMP
] = UBYTE_TO_FLOAT(dst
[3]);
1331 fetch_etc2_r11_eac(const GLubyte
*map
, const GLuint imageOffsets
[],
1332 GLint rowStride
, GLint i
, GLint j
, GLint k
,
1335 struct etc2_block block
;
1339 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1341 etc2_r11_parse_block(&block
, src
);
1342 etc2_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)&dst
);
1344 texel
[RCOMP
] = USHORT_TO_FLOAT(dst
);
1345 texel
[GCOMP
] = 0.0f
;
1346 texel
[BCOMP
] = 0.0f
;
1347 texel
[ACOMP
] = 1.0f
;
1351 fetch_etc2_rg11_eac(const GLubyte
*map
, const GLuint imageOffsets
[],
1352 GLint rowStride
, GLint i
, GLint j
, GLint k
,
1355 struct etc2_block block
;
1359 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 16;
1362 etc2_r11_parse_block(&block
, src
);
1363 etc2_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)dst
);
1365 /* green component */
1366 etc2_r11_parse_block(&block
, src
+ 8);
1367 etc2_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)(dst
+ 1));
1369 texel
[RCOMP
] = USHORT_TO_FLOAT(dst
[0]);
1370 texel
[GCOMP
] = USHORT_TO_FLOAT(dst
[1]);
1371 texel
[BCOMP
] = 0.0f
;
1372 texel
[ACOMP
] = 1.0f
;
1376 fetch_etc2_signed_r11_eac(const GLubyte
*map
, const GLuint imageOffsets
[],
1377 GLint rowStride
, GLint i
, GLint j
, GLint k
,
1380 struct etc2_block block
;
1384 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1386 etc2_r11_parse_block(&block
, src
);
1387 etc2_signed_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)&dst
);
1389 texel
[RCOMP
] = SHORT_TO_FLOAT(dst
);
1390 texel
[GCOMP
] = 0.0f
;
1391 texel
[BCOMP
] = 0.0f
;
1392 texel
[ACOMP
] = 1.0f
;
1396 fetch_etc2_signed_rg11_eac(const GLubyte
*map
, const GLuint imageOffsets
[],
1397 GLint rowStride
, GLint i
, GLint j
, GLint k
,
1400 struct etc2_block block
;
1404 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 16;
1407 etc2_r11_parse_block(&block
, src
);
1408 etc2_signed_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)dst
);
1410 /* green component */
1411 etc2_r11_parse_block(&block
, src
+ 8);
1412 etc2_signed_r11_fetch_texel(&block
, i
% 4, j
% 4, (uint8_t *)(dst
+ 1));
1414 texel
[RCOMP
] = SHORT_TO_FLOAT(dst
[0]);
1415 texel
[GCOMP
] = SHORT_TO_FLOAT(dst
[1]);
1416 texel
[BCOMP
] = 0.0f
;
1417 texel
[ACOMP
] = 1.0f
;
1421 fetch_etc2_rgb8_punchthrough_alpha1(const GLubyte
*map
,
1422 const GLuint imageOffsets
[],
1423 GLint rowStride
, GLint i
, GLint j
, GLint k
,
1426 struct etc2_block block
;
1430 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1432 etc2_rgb8_parse_block(&block
, src
,
1433 true /* punchthrough alpha */);
1434 etc2_rgb8_fetch_texel(&block
, i
% 4, j
% 4, dst
,
1435 true /* punchthrough alpha */);
1436 texel
[RCOMP
] = UBYTE_TO_FLOAT(dst
[0]);
1437 texel
[GCOMP
] = UBYTE_TO_FLOAT(dst
[1]);
1438 texel
[BCOMP
] = UBYTE_TO_FLOAT(dst
[2]);
1439 texel
[ACOMP
] = UBYTE_TO_FLOAT(dst
[3]);
1443 fetch_etc2_srgb8_punchthrough_alpha1(const GLubyte
*map
,
1444 const GLuint imageOffsets
[],
1446 GLint i
, GLint j
, GLint k
,
1449 struct etc2_block block
;
1453 src
= map
+ (((rowStride
+ 3) / 4) * (j
/ 4) + (i
/ 4)) * 8;
1455 etc2_rgb8_parse_block(&block
, src
,
1456 true /* punchthrough alpha */);
1457 etc2_rgb8_fetch_texel(&block
, i
% 4, j
% 4, dst
,
1458 true /* punchthrough alpha */);
1459 texel
[RCOMP
] = _mesa_nonlinear_to_linear(dst
[0]);
1460 texel
[GCOMP
] = _mesa_nonlinear_to_linear(dst
[1]);
1461 texel
[BCOMP
] = _mesa_nonlinear_to_linear(dst
[2]);
1462 texel
[ACOMP
] = UBYTE_TO_FLOAT(dst
[3]);
1466 compressed_fetch_func
1467 _mesa_get_etc_fetch_func(gl_format format
)
1470 case MESA_FORMAT_ETC1_RGB8
:
1471 return fetch_etc1_rgb8
;
1472 case MESA_FORMAT_ETC2_RGB8
:
1473 return fetch_etc2_rgb8
;
1474 case MESA_FORMAT_ETC2_SRGB8
:
1475 return fetch_etc2_srgb8
;
1476 case MESA_FORMAT_ETC2_RGBA8_EAC
:
1477 return fetch_etc2_rgba8_eac
;
1478 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
1479 return fetch_etc2_srgb8_alpha8_eac
;
1480 case MESA_FORMAT_ETC2_R11_EAC
:
1481 return fetch_etc2_r11_eac
;
1482 case MESA_FORMAT_ETC2_RG11_EAC
:
1483 return fetch_etc2_rg11_eac
;
1484 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
1485 return fetch_etc2_signed_r11_eac
;
1486 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
1487 return fetch_etc2_signed_rg11_eac
;
1488 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
1489 return fetch_etc2_rgb8_punchthrough_alpha1
;
1490 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
1491 return fetch_etc2_srgb8_punchthrough_alpha1
;