#include "texcompress.h"
#include "texcompress_etc.h"
#include "texstore.h"
+#include "config.h"
#include "macros.h"
#include "format_unpack.h"
#include "util/format_srgb.h"
#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 */
assert(0);
if (punchthrough_alpha)
dst[3] = 255;
}
+ else
+ unreachable("unhandled block mode");
}
static void
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;
for (i = 0; i < w; i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
false /* punchthrough_alpha */);
- /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
- 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;
}
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
for (i = 0; i < w; i++) {
etc2_rgba8_fetch_texel(&block, i, j, dst);
- /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
- 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;
}
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;
for (i = 0; i < w; i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
true /* punchthrough_alpha */);
- /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
- 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;
}
/* 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);
}
GLboolean
-_mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_srgb8(UNUSED_TEXSTORE_PARAMS)
{
assert(0);
}
GLboolean
-_mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_rgba8_eac(UNUSED_TEXSTORE_PARAMS)
{
assert(0);
}
GLboolean
-_mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_srgb8_alpha8_eac(UNUSED_TEXSTORE_PARAMS)
{
assert(0);
}
GLboolean
-_mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_r11_eac(UNUSED_TEXSTORE_PARAMS)
{
assert(0);
}
GLboolean
-_mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_signed_r11_eac(UNUSED_TEXSTORE_PARAMS)
{
assert(0);
}
GLboolean
-_mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_rg11_eac(UNUSED_TEXSTORE_PARAMS)
{
assert(0);
}
GLboolean
-_mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_signed_rg11_eac(UNUSED_TEXSTORE_PARAMS)
{
assert(0);
}
GLboolean
-_mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_rgb8_punchthrough_alpha1(UNUSED_TEXSTORE_PARAMS)
{
assert(0);
}
GLboolean
-_mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
+_mesa_texstore_etc2_srgb8_punchthrough_alpha1(UNUSED_TEXSTORE_PARAMS)
{
assert(0);
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,
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_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_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);
}