summaryrefslogtreecommitdiff
path: root/GLESv2
diff options
context:
space:
mode:
authorStanislav Vorobiov <s.vorobiov@samsung.com>2014-03-20 13:10:03 +0400
committerStanislav Vorobiov <s.vorobiov@samsung.com>2014-03-21 09:49:14 +0400
commit945d6ae49a40732654db578b9e46c95e9144b7fd (patch)
treed02f6fb6ad9ca8d79a60d62b22bc614a25c9c6a2 /GLESv2
parent57c951f4e2e0f4fe47015183e135afd6def137ae (diff)
downloademulator-yagl-945d6ae49a40732654db578b9e46c95e9144b7fd.tar.gz
emulator-yagl-945d6ae49a40732654db578b9e46c95e9144b7fd.tar.bz2
emulator-yagl-945d6ae49a40732654db578b9e46c95e9144b7fd.zip
YaGL: Fix ETC2 textures unpacking
ETC2 textures were unpacking incorrectly if width or height were not multiple of block size. This is now fixed Change-Id: I68f249b61e285af8142115c4f7e907f66483ec78 Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com>
Diffstat (limited to 'GLESv2')
-rw-r--r--GLESv2/yagl_texcompress_etc2.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/GLESv2/yagl_texcompress_etc2.c b/GLESv2/yagl_texcompress_etc2.c
index 2575fcd..02e9959 100644
--- a/GLESv2/yagl_texcompress_etc2.c
+++ b/GLESv2/yagl_texcompress_etc2.c
@@ -625,9 +625,9 @@ void yagl_texcompress_etc2_unpack_r11(uint8_t *dst_row,
for (x = 0; x < width; x+= bw) {
etc2_r11_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
@@ -659,10 +659,10 @@ void yagl_texcompress_etc2_unpack_signed_r11(uint8_t *dst_row,
for (x = 0; x < width; x+= bw) {
etc2_r11_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_signed_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
@@ -695,10 +695,10 @@ void yagl_texcompress_etc2_unpack_rg11(uint8_t *dst_row,
/* red component */
etc2_r11_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
@@ -706,10 +706,10 @@ void yagl_texcompress_etc2_unpack_rg11(uint8_t *dst_row,
/* green/blue component */
etc2_r11_parse_block(&block, src + 8);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_r11_fetch_texel(&block, i, j, dst + comp_size);
*(GLushort*)(dst + comp_size * 2) = 0;
dst += comps * comp_size;
@@ -743,10 +743,10 @@ void yagl_texcompress_etc2_unpack_signed_rg11(uint8_t *dst_row,
/* red component */
etc2_r11_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_signed_r11_fetch_texel(&block, i, j, dst);
dst += comps * comp_size;
}
@@ -754,10 +754,10 @@ void yagl_texcompress_etc2_unpack_signed_rg11(uint8_t *dst_row,
/* green/blue component */
etc2_r11_parse_block(&block, src + 8);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride +
x * comps * comp_size;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_signed_r11_fetch_texel(&block, i, j, dst + comp_size);
*(GLushort*)(dst + comp_size * 2) = 0;
dst += comps * comp_size;
@@ -788,9 +788,9 @@ void yagl_texcompress_etc2_unpack_rgb8(uint8_t *dst_row,
etc2_rgb8_parse_block(&block, src,
false /* punchthrough_alpha */);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
false /* punchthrough_alpha */);
dst[3] = 255;
@@ -824,9 +824,9 @@ void yagl_texcompress_etc2_unpack_srgb8(uint8_t *dst_row,
etc2_rgb8_parse_block(&block, src,
false /* punchthrough_alpha */);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
false /* punchthrough_alpha */);
/* Convert to GL_BGRA */
@@ -862,9 +862,9 @@ void yagl_texcompress_etc2_unpack_rgb8_punchthrough_alpha1(uint8_t *dst_row,
for (x = 0; x < width; x+= bw) {
etc2_rgb8_parse_block(&block, src,
true /* punchthrough_alpha */);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
true /* punchthrough_alpha */);
dst += comps;
@@ -896,9 +896,9 @@ void yagl_texcompress_etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row,
for (x = 0; x < width; x+= bw) {
etc2_rgb8_parse_block(&block, src,
true /* punchthrough_alpha */);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_rgb8_fetch_texel(&block, i, j, dst,
true /* punchthrough_alpha */);
/* Convert to GL_BGRA */
@@ -939,9 +939,9 @@ void yagl_texcompress_etc2_unpack_rgba8(uint8_t *dst_row,
for (x = 0; x < width; x+= bw) {
etc2_rgba8_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_rgba8_fetch_texel(&block, i, j, dst);
dst += comps;
}
@@ -975,9 +975,9 @@ void yagl_texcompress_etc2_unpack_srgb8_alpha8(uint8_t *dst_row,
for (x = 0; x < width; x+= bw) {
etc2_rgba8_parse_block(&block, src);
- for (j = 0; j < bh; j++) {
+ for (j = 0; (j < bh) && ((y + j) < height); j++) {
uint8_t *dst = dst_row + (y + j) * dst_stride + x * comps;
- for (i = 0; i < bw; i++) {
+ for (i = 0; (i < bw) && ((x + i) < width); i++) {
etc2_rgba8_fetch_texel(&block, i, j, dst);
/* Convert to GL_BGRA */