projects
/
mesa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mesa: add ASTC 2D LDR decoder
[mesa.git]
/
src
/
mesa
/
main
/
texcompress_etc.c
diff --git
a/src/mesa/main/texcompress_etc.c
b/src/mesa/main/texcompress_etc.c
index 75bb9f7ffa85bcabf72aa5c4b3ebac9e67339551..b39ab33d36fc6607d29a6c35ac2c9b499e261172 100644
(file)
--- a/
src/mesa/main/texcompress_etc.c
+++ b/
src/mesa/main/texcompress_etc.c
@@
-41,8
+41,10
@@
#include "texcompress.h"
#include "texcompress_etc.h"
#include "texstore.h"
#include "texcompress.h"
#include "texcompress_etc.h"
#include "texstore.h"
+#include "config.h"
#include "macros.h"
#include "format_unpack.h"
#include "macros.h"
#include "format_unpack.h"
+#include "util/format_srgb.h"
struct etc2_block {
struct etc2_block {
@@
-104,10
+106,10
@@
static const int etc2_modifier_tables_non_opaque[8][4] = {
#undef UINT8_TYPE
GLboolean
#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 */
{
/* GL_ETC1_RGB8_OES is only valid in glCompressedTexImage2D */
-
ASSERT
(0);
+
assert
(0);
return GL_FALSE;
}
return GL_FALSE;
}
@@
-429,8
+431,7
@@
etc2_rgb8_parse_block(struct etc2_block *block,
block->is_planar_mode = true;
/* opaque bit must be set in planar mode */
block->is_planar_mode = true;
/* opaque bit must be set in planar mode */
- if (!block->opaque)
- block->opaque = true;
+ block->opaque = true;
for (i = 0; i < 3; i++) {
block->base_colors[0][i] = etc2_base_color_o_planar(src, i);
for (i = 0; i < 3; i++) {
block->base_colors[0][i] = etc2_base_color_o_planar(src, i);
@@
-458,10
+459,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
*/
/* 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];
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];
etc1_modifier_tables[table2_idx] :
etc2_modifier_tables_non_opaque[table2_idx];
@@
-679,14
+680,25
@@
etc2_unpack_rgb8(uint8_t *dst_row,
for (y = 0; y < height; y += bh) {
const uint8_t *src = src_row;
for (y = 0; y < height; y += bh) {
const uint8_t *src = src_row;
+ /*
+ * Destination texture may not be a multiple of four texels in
+ * height. Compute a safe height to avoid writing outside the texture.
+ */
+ const unsigned h = MIN2(bh, height - y);
for (x = 0; x < width; x+= bw) {
for (x = 0; x < width; x+= bw) {
+ /*
+ * 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 */);
etc2_rgb8_parse_block(&block, src,
false /* punchthrough_alpha */);
- for (j = 0; j <
b
h; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
false /* punchthrough_alpha */);
dst[3] = 255;
etc2_rgb8_fetch_texel(&block, i, j, dst,
false /* punchthrough_alpha */);
dst[3] = 255;
@@
-707,7
+719,8
@@
etc2_unpack_srgb8(uint8_t *dst_row,
const uint8_t *src_row,
unsigned src_stride,
unsigned width,
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;
{
const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
struct etc2_block block;
@@
-716,21
+729,27
@@
etc2_unpack_srgb8(uint8_t *dst_row,
for (y = 0; y < height; y += bh) {
const uint8_t *src = src_row;
for (y = 0; y < height; y += bh) {
const uint8_t *src = src_row;
+ const unsigned h = MIN2(bh, height - y);
for (x = 0; x < width; x+= bw) {
for (x = 0; x < width; x+= bw) {
+ const unsigned w = MIN2(bw, width - x);
etc2_rgb8_parse_block(&block, src,
false /* punchthrough_alpha */);
etc2_rgb8_parse_block(&block, src,
false /* punchthrough_alpha */);
- for (j = 0; j < bh; j++) {
+
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
false /* punchthrough_alpha */);
etc2_rgb8_fetch_texel(&block, i, j, dst,
false /* punchthrough_alpha */);
- /* Convert to MESA_FORMAT_SARGB8 */
- 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;
}
dst += comps;
}
@@
-760,13
+779,15
@@
etc2_unpack_rgba8(uint8_t *dst_row,
for (y = 0; y < height; y += bh) {
const uint8_t *src = src_row;
for (y = 0; y < height; y += bh) {
const uint8_t *src = src_row;
+ const unsigned h = MIN2(bh, height - y);
for (x = 0; x < width; x+= bw) {
for (x = 0; x < width; x+= bw) {
+ const unsigned w = MIN2(bw, width - x);
etc2_rgba8_parse_block(&block, src);
etc2_rgba8_parse_block(&block, src);
- for (j = 0; j <
b
h; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgba8_fetch_texel(&block, i, j, dst);
dst += comps;
}
etc2_rgba8_fetch_texel(&block, i, j, dst);
dst += comps;
}
@@
-784,7
+805,8
@@
etc2_unpack_srgb8_alpha8(uint8_t *dst_row,
const uint8_t *src_row,
unsigned src_stride,
unsigned width,
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
{
/* 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
@@
-796,21
+818,25
@@
etc2_unpack_srgb8_alpha8(uint8_t *dst_row,
uint8_t tmp;
for (y = 0; y < height; y += bh) {
uint8_t tmp;
for (y = 0; y < height; y += bh) {
+ const unsigned h = MIN2(bh, height - y);
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
+ const unsigned w = MIN2(bw, width - x);
etc2_rgba8_parse_block(&block, src);
etc2_rgba8_parse_block(&block, src);
- for (j = 0; j <
b
h; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgba8_fetch_texel(&block, i, j, dst);
etc2_rgba8_fetch_texel(&block, i, j, dst);
- /* Convert to MESA_FORMAT_SARGB8 */
- 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;
}
dst += comps;
}
@@
-838,14
+864,16
@@
etc2_unpack_r11(uint8_t *dst_row,
unsigned x, y, i, j;
for (y = 0; y < height; y += bh) {
unsigned x, y, i, j;
for (y = 0; y < height; y += bh) {
+ const unsigned h = MIN2(bh, height - y);
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
+ const unsigned w = MIN2(bw, width - x);
etc2_r11_parse_block(&block, src);
etc2_r11_parse_block(&block, src);
- for (j = 0; j <
b
h; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps * comp_size;
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps * comp_size;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
etc2_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
@@
-873,16
+901,18
@@
etc2_unpack_rg11(uint8_t *dst_row,
unsigned x, y, i, j;
for (y = 0; y < height; y += bh) {
unsigned x, y, i, j;
for (y = 0; y < height; y += bh) {
+ const unsigned h = MIN2(bh, height - y);
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
+ const unsigned w = MIN2(bw, width - x);
/* red component */
etc2_r11_parse_block(&block, src);
/* red component */
etc2_r11_parse_block(&block, src);
- for (j = 0; j <
b
h; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
etc2_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
@@
-890,10
+920,10
@@
etc2_unpack_rg11(uint8_t *dst_row,
/* green component */
etc2_r11_parse_block(&block, src + 8);
/* green component */
etc2_r11_parse_block(&block, src + 8);
- for (j = 0; j <
b
h; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_r11_fetch_texel(&block, i, j, dst + comp_size);
dst += comps * comp_size;
}
etc2_r11_fetch_texel(&block, i, j, dst + comp_size);
dst += comps * comp_size;
}
@@
-921,15
+951,17
@@
etc2_unpack_signed_r11(uint8_t *dst_row,
unsigned x, y, i, j;
for (y = 0; y < height; y += bh) {
unsigned x, y, i, j;
for (y = 0; y < height; y += bh) {
+ const unsigned h = MIN2(bh, height - y);
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
+ const unsigned w = MIN2(bw, width - x);
etc2_r11_parse_block(&block, src);
etc2_r11_parse_block(&block, src);
- for (j = 0; j <
b
h; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_signed_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
etc2_signed_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
@@
-957,16
+989,18
@@
etc2_unpack_signed_rg11(uint8_t *dst_row,
unsigned x, y, i, j;
for (y = 0; y < height; y += bh) {
unsigned x, y, i, j;
for (y = 0; y < height; y += bh) {
+ const unsigned h = MIN2(bh, height - y);
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
+ const unsigned w = MIN2(bw, width - x);
/* red component */
etc2_r11_parse_block(&block, src);
/* red component */
etc2_r11_parse_block(&block, src);
- for (j = 0; j <
b
h; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_signed_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
etc2_signed_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
@@
-974,10
+1008,10
@@
etc2_unpack_signed_rg11(uint8_t *dst_row,
/* green component */
etc2_r11_parse_block(&block, src + 8);
/* green component */
etc2_r11_parse_block(&block, src + 8);
- for (j = 0; j <
b
h; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_signed_r11_fetch_texel(&block, i, j, dst + comp_size);
dst += comps * comp_size;
}
etc2_signed_r11_fetch_texel(&block, i, j, dst + comp_size);
dst += comps * comp_size;
}
@@
-1002,14
+1036,16
@@
etc2_unpack_rgb8_punchthrough_alpha1(uint8_t *dst_row,
unsigned x, y, i, j;
for (y = 0; y < height; y += bh) {
unsigned x, y, i, j;
for (y = 0; y < height; y += bh) {
+ const unsigned h = MIN2(bh, height - y);
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
+ const unsigned w = MIN2(bw, width - x);
etc2_rgb8_parse_block(&block, src,
true /* punchthrough_alpha */);
etc2_rgb8_parse_block(&block, src,
true /* punchthrough_alpha */);
- for (j = 0; j <
b
h; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
true /* punchthrough_alpha */);
dst += comps;
etc2_rgb8_fetch_texel(&block, i, j, dst,
true /* punchthrough_alpha */);
dst += comps;
@@
-1029,7
+1065,8
@@
etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row,
const uint8_t *src_row,
unsigned src_stride,
unsigned width,
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;
{
const unsigned bw = 4, bh = 4, bs = 8, comps = 4;
struct etc2_block block;
@@
-1037,21
+1074,26
@@
etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row,
uint8_t tmp;
for (y = 0; y < height; y += bh) {
uint8_t tmp;
for (y = 0; y < height; y += bh) {
+ const unsigned h = MIN2(bh, height - y);
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
const uint8_t *src = src_row;
for (x = 0; x < width; x+= bw) {
+ const unsigned w = MIN2(bw, width - x);
etc2_rgb8_parse_block(&block, src,
true /* punchthrough_alpha */);
etc2_rgb8_parse_block(&block, src,
true /* punchthrough_alpha */);
- for (j = 0; j <
b
h; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i <
b
w; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
true /* punchthrough_alpha */);
etc2_rgb8_fetch_texel(&block, i, j, dst,
true /* punchthrough_alpha */);
- /* Convert to MESA_FORMAT_SARGB8 */
- 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;
}
dst += comps;
}
@@
-1067,81
+1109,81
@@
etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row,
/* ETC2 texture formats are valid in glCompressedTexImage2D and
* glCompressedTexSubImage2D functions */
GLboolean
/* 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);
+
assert
(0);
return GL_FALSE;
}
GLboolean
return GL_FALSE;
}
GLboolean
-_mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_srgb8(
UNUSED_
TEXSTORE_PARAMS)
{
{
-
ASSERT
(0);
+
assert
(0);
return GL_FALSE;
}
GLboolean
return GL_FALSE;
}
GLboolean
-_mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_rgba8_eac(
UNUSED_
TEXSTORE_PARAMS)
{
{
-
ASSERT
(0);
+
assert
(0);
return GL_FALSE;
}
GLboolean
return GL_FALSE;
}
GLboolean
-_mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_srgb8_alpha8_eac(
UNUSED_
TEXSTORE_PARAMS)
{
{
-
ASSERT
(0);
+
assert
(0);
return GL_FALSE;
}
GLboolean
return GL_FALSE;
}
GLboolean
-_mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_r11_eac(
UNUSED_
TEXSTORE_PARAMS)
{
{
-
ASSERT
(0);
+
assert
(0);
return GL_FALSE;
}
GLboolean
return GL_FALSE;
}
GLboolean
-_mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_signed_r11_eac(
UNUSED_
TEXSTORE_PARAMS)
{
{
-
ASSERT
(0);
+
assert
(0);
return GL_FALSE;
}
GLboolean
return GL_FALSE;
}
GLboolean
-_mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_rg11_eac(
UNUSED_
TEXSTORE_PARAMS)
{
{
-
ASSERT
(0);
+
assert
(0);
return GL_FALSE;
}
GLboolean
return GL_FALSE;
}
GLboolean
-_mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_signed_rg11_eac(
UNUSED_
TEXSTORE_PARAMS)
{
{
-
ASSERT
(0);
+
assert
(0);
return GL_FALSE;
}
GLboolean
return GL_FALSE;
}
GLboolean
-_mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_rgb8_punchthrough_alpha1(
UNUSED_
TEXSTORE_PARAMS)
{
{
-
ASSERT
(0);
+
assert
(0);
return GL_FALSE;
}
GLboolean
return GL_FALSE;
}
GLboolean
-_mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_srgb8_punchthrough_alpha1(
UNUSED_
TEXSTORE_PARAMS)
{
{
-
ASSERT
(0);
+
assert
(0);
return GL_FALSE;
}
return GL_FALSE;
}
@@
-1175,7
+1217,8
@@
_mesa_unpack_etc2_format(uint8_t *dst_row,
unsigned src_stride,
unsigned src_width,
unsigned src_height,
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,
{
if (format == MESA_FORMAT_ETC2_RGB8)
etc2_unpack_rgb8(dst_row, dst_stride,
@@
-1184,7
+1227,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,
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,
else if (format == MESA_FORMAT_ETC2_RGBA8_EAC)
etc2_unpack_rgba8(dst_row, dst_stride,
src_row, src_stride,
@@
-1192,7
+1235,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,
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,
else if (format == MESA_FORMAT_ETC2_R11_EAC)
etc2_unpack_r11(dst_row, dst_stride,
src_row, src_stride,
@@
-1216,7
+1259,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,
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
);
}
}
@@
-1278,9
+1321,9
@@
fetch_etc2_srgb8(const GLubyte *map,
etc2_rgb8_fetch_texel(&block, i % 4, j % 4, dst,
false /* punchthrough_alpha */);
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;
}
texel[ACOMP] = 1.0f;
}
@@
-1316,9
+1359,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);
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]);
}
texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
}
@@
-1444,9
+1487,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 */);
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]);
}
texel[ACOMP] = UBYTE_TO_FLOAT(dst[3]);
}