[Mesa-dev] [PATCH 1/2] mesa: Fix a decoding bug in ETC2 signed-{r11, rg11} formats
Matt Turner
mattst88 at gmail.com
Sat Nov 17 16:40:19 PST 2012
On Thu, Nov 15, 2012 at 12:17 PM, Anuj Phogat <anuj.phogat at gmail.com> wrote:
> This patch fixes two issues in decoding signed formats:
> 1. Handle a corner case when base code word value is -128. As per
> OpenGL ES 3.0 specification -128 is not an allowed value and should
> be truncated to -127.
> 2. Converting a decoded 16 bit signed data to 16 bit unsigned data by
> adding 2 ^ 15 gives us an output which matches the decompressed image
> (.ppm) generated by ericsson's etcpack tool. ericsson is also doing this
> conversion in their tool because .ppm image files don't support signed
> data. gles 3.0 specification doesn't suggest this conversion. That is
> the reason etc2 signed format tests currently fails on gles3 branch.
> We need to keep the decoded data in signed format. This fix makes both
> signed format tests in gles3 conformance pass.
>
> Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
> ---
> src/mesa/main/texcompress_etc.c | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/main/texcompress_etc.c b/src/mesa/main/texcompress_etc.c
> index 44bdb84..b98ff02 100644
> --- a/src/mesa/main/texcompress_etc.c
> +++ b/src/mesa/main/texcompress_etc.c
> @@ -613,6 +613,10 @@ etc2_signed_r11_fetch_texel(const struct etc2_block *block,
> GLint modifier, idx;
> GLshort color;
> GLbyte base_codeword = (GLbyte) block->base_codeword;
> +
> + if (base_codeword == -128)
> + base_codeword = -127;
> +
> /* Get pixel index */
> idx = etc2_get_pixel_index(block, x, y);
> modifier = etc2_modifier_tables[block->table_index][idx];
> @@ -637,9 +641,7 @@ etc2_signed_r11_fetch_texel(const struct etc2_block *block,
> color = (color << 5) | (color >> 5);
> color = -color;
> }
> - /* Add 2^15 to get a 16-bit unsigned value */
> - color = color + (1 << 15);
> - ((GLushort *)dst)[0] = color;
> + ((GLshort *)dst)[0] = color;
> }
>
> static void
> --
> 1.7.7.6
Both patches are Tested-by: Matt Turner <mattst88 at gmail.com>
They fix eac_compression_signed_r11 and eac_compression_signed_rg11
from the gles3conform suite.
I think they should be squashed into previous commits on the gles3
branch. We can still rewrite history while it's on gles3, so why not.
:)
More information about the mesa-dev
mailing list