*/
#include <stdbool.h>
-#include "mfeatures.h"
#include "texcompress.h"
#include "texcompress_etc.h"
#include "texstore.h"
break;
}
return ((x << 4) | (x & 0xf));
- }
+}
static uint8_t
etc2_base_color2_h_mode(const uint8_t *in, GLuint index)
break;
}
return ((x << 4) | (x & 0xf));
- }
+}
static uint8_t
etc2_base_color_o_planar(const uint8_t *in, GLuint index)
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);
*/
block->base_colors[0][i] = etc1_base_color_diff_hi(src[i]);
block->base_colors[1][i] = etc1_base_color_diff_lo(src[i]);
- }
+ }
}
if (block->is_ind_mode || block->is_diff_mode) {
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) {
+ /*
+ * Destination texture may not be a multiple of four texels in
+ * width. Compute a safe width to avoid writing outside the texture.
+ */
+ const unsigned w = MIN2(bw, width - x);
+
etc2_rgb8_parse_block(&block, src,
false /* punchthrough_alpha */);
- for (j = 0; j < bh; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
false /* punchthrough_alpha */);
dst[3] = 255;
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) {
+ const unsigned w = MIN2(bw, width - x);
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;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
false /* punchthrough_alpha */);
- /* Convert to MESA_FORMAT_SARGB8 */
+ /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
tmp = dst[0];
dst[0] = dst[2];
dst[2] = tmp;
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
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) {
+ const unsigned w = MIN2(bw, width - x);
etc2_rgba8_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgba8_fetch_texel(&block, i, j, dst);
dst += comps;
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
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 unsigned w = MIN2(bw, width - x);
etc2_rgba8_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgba8_fetch_texel(&block, i, j, dst);
- /* Convert to MESA_FORMAT_SARGB8 */
+ /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
tmp = dst[0];
dst[0] = dst[2];
dst[2] = tmp;
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
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 unsigned w = MIN2(bw, width - x);
etc2_r11_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
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 unsigned w = MIN2(bw, width - x);
/* red component */
etc2_r11_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
/* green component */
etc2_r11_parse_block(&block, src + 8);
- for (j = 0; j < bh; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_r11_fetch_texel(&block, i, j, dst + comp_size);
dst += comps * comp_size;
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
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 unsigned w = MIN2(bw, width - x);
etc2_r11_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_signed_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
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 unsigned w = MIN2(bw, width - x);
/* red component */
etc2_r11_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_signed_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
/* green component */
etc2_r11_parse_block(&block, src + 8);
- for (j = 0; j < bh; j++) {
+ for (j = 0; j < h; j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_signed_r11_fetch_texel(&block, i, j, dst + comp_size);
dst += comps * comp_size;
}
}
src += bs;
- }
+ }
src_row += src_stride;
- }
+ }
}
static void
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 unsigned w = MIN2(bw, width - x);
etc2_rgb8_parse_block(&block, src,
true /* 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;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
true /* punchthrough_alpha */);
dst += comps;
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 unsigned w = MIN2(bw, width - x);
etc2_rgb8_parse_block(&block, src,
true /* 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;
- for (i = 0; i < bw; i++) {
+ for (i = 0; i < w; i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
true /* punchthrough_alpha */);
- /* Convert to MESA_FORMAT_SARGB8 */
+ /* Convert to MESA_FORMAT_B8G8R8A8_SRGB */
tmp = dst[0];
dst[0] = dst[2];
dst[2] = tmp;
unsigned src_stride,
unsigned src_width,
unsigned src_height,
- gl_format format)
+ mesa_format format)
{
if (format == MESA_FORMAT_ETC2_RGB8)
etc2_unpack_rgb8(dst_row, dst_stride,
static void
-fetch_etc1_rgb8(const GLubyte *map, const GLuint imageOffsets[],
- GLint rowStride, GLint i, GLint j, GLint k,
+fetch_etc1_rgb8(const GLubyte *map,
+ GLint rowStride, GLint i, GLint j,
GLfloat *texel)
{
struct etc1_block block;
static void
-fetch_etc2_rgb8(const GLubyte *map, const GLuint imageOffsets[],
- GLint rowStride, GLint i, GLint j, GLint k,
- GLfloat *texel)
+fetch_etc2_rgb8(const GLubyte *map,
+ GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
struct etc2_block block;
uint8_t dst[3];
}
static void
-fetch_etc2_srgb8(const GLubyte *map, const GLuint imageOffsets[],
- GLint rowStride, GLint i, GLint j, GLint k,
- GLfloat *texel)
+fetch_etc2_srgb8(const GLubyte *map,
+ GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
struct etc2_block block;
uint8_t dst[3];
}
static void
-fetch_etc2_rgba8_eac(const GLubyte *map, const GLuint imageOffsets[],
- GLint rowStride, GLint i, GLint j, GLint k,
- GLfloat *texel)
+fetch_etc2_rgba8_eac(const GLubyte *map,
+ GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
struct etc2_block block;
uint8_t dst[4];
}
static void
-fetch_etc2_srgb8_alpha8_eac(const GLubyte *map, const GLuint imageOffsets[],
- GLint rowStride, GLint i, GLint j, GLint k,
- GLfloat *texel)
+fetch_etc2_srgb8_alpha8_eac(const GLubyte *map,
+ GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
struct etc2_block block;
uint8_t dst[4];
}
static void
-fetch_etc2_r11_eac(const GLubyte *map, const GLuint imageOffsets[],
- GLint rowStride, GLint i, GLint j, GLint k,
- GLfloat *texel)
+fetch_etc2_r11_eac(const GLubyte *map,
+ GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
struct etc2_block block;
GLushort dst;
}
static void
-fetch_etc2_rg11_eac(const GLubyte *map, const GLuint imageOffsets[],
- GLint rowStride, GLint i, GLint j, GLint k,
- GLfloat *texel)
+fetch_etc2_rg11_eac(const GLubyte *map,
+ GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
struct etc2_block block;
GLushort dst[2];
}
static void
-fetch_etc2_signed_r11_eac(const GLubyte *map, const GLuint imageOffsets[],
- GLint rowStride, GLint i, GLint j, GLint k,
- GLfloat *texel)
+fetch_etc2_signed_r11_eac(const GLubyte *map,
+ GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
struct etc2_block block;
GLushort dst;
}
static void
-fetch_etc2_signed_rg11_eac(const GLubyte *map, const GLuint imageOffsets[],
- GLint rowStride, GLint i, GLint j, GLint k,
- GLfloat *texel)
+fetch_etc2_signed_rg11_eac(const GLubyte *map,
+ GLint rowStride, GLint i, GLint j, GLfloat *texel)
{
struct etc2_block block;
GLushort dst[2];
static void
fetch_etc2_rgb8_punchthrough_alpha1(const GLubyte *map,
- const GLuint imageOffsets[],
- GLint rowStride, GLint i, GLint j, GLint k,
+ GLint rowStride, GLint i, GLint j,
GLfloat *texel)
{
struct etc2_block block;
static void
fetch_etc2_srgb8_punchthrough_alpha1(const GLubyte *map,
- const GLuint imageOffsets[],
GLint rowStride,
- GLint i, GLint j, GLint k,
- GLfloat *texel)
+ GLint i, GLint j, GLfloat *texel)
{
struct etc2_block block;
uint8_t dst[4];
compressed_fetch_func
-_mesa_get_etc_fetch_func(gl_format format)
+_mesa_get_etc_fetch_func(mesa_format format)
{
switch (format) {
case MESA_FORMAT_ETC1_RGB8: