[Mesa-dev] mesa: fix packing/unpacking for MESA_FORMAT_A4R4G4B4_UNORM

Submitted by Brian Paul on March 4, 2014, 4:10 p.m.

Details

Message ID 1393949455-5504-1-git-send-email-brianp@vmware.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Brian Paul March 4, 2014, 4:10 p.m.
Spotted by Chia-I Wu.
---
 src/mesa/main/format_pack.c      |    2 +-
 src/mesa/main/format_unpack.c    |    8 ++++----
 src/mesa/swrast/s_texfetch_tmp.h |    8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c
index 2772ff2..ee505ec 100644
--- a/src/mesa/main/format_pack.c
+++ b/src/mesa/main/format_pack.c
@@ -567,7 +567,7 @@  static void
 pack_ubyte_ARGB4444_REV(const GLubyte src[4], void *dst)
 {
    GLushort *d = ((GLushort *) dst);
-   *d = PACK_COLOR_4444(src[GCOMP], src[BCOMP], src[ACOMP], src[RCOMP]);
+   *d = PACK_COLOR_4444(src[BCOMP], src[GCOMP], src[RCOMP], src[ACOMP]);
 }
 
 static void
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 276ba55..d8bf57d 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -267,10 +267,10 @@  unpack_ARGB4444_REV(const void *src, GLfloat dst[][4], GLuint n)
    const GLushort *s = ((const GLushort *) src);
    GLuint i;
    for (i = 0; i < n; i++) {
-      dst[i][RCOMP] = ((s[i]      ) & 0xf) * (1.0F / 15.0F);
-      dst[i][GCOMP] = ((s[i] >> 12) & 0xf) * (1.0F / 15.0F);
-      dst[i][BCOMP] = ((s[i] >>  8) & 0xf) * (1.0F / 15.0F);
-      dst[i][ACOMP] = ((s[i] >>  4) & 0xf) * (1.0F / 15.0F);
+      dst[i][RCOMP] = ((s[i] >>  4) & 0xf) * (1.0F / 15.0F);
+      dst[i][GCOMP] = ((s[i] >>  8) & 0xf) * (1.0F / 15.0F);
+      dst[i][BCOMP] = ((s[i] >> 12) & 0xf) * (1.0F / 15.0F);
+      dst[i][ACOMP] = ((s[i]      ) & 0xf) * (1.0F / 15.0F);
    }
 }
 
diff --git a/src/mesa/swrast/s_texfetch_tmp.h b/src/mesa/swrast/s_texfetch_tmp.h
index 806f0fd..1db3adc 100644
--- a/src/mesa/swrast/s_texfetch_tmp.h
+++ b/src/mesa/swrast/s_texfetch_tmp.h
@@ -611,10 +611,10 @@  static void FETCH(f_argb4444_rev)( const struct swrast_texture_image *texImage,
                                    GLint i, GLint j, GLint k, GLfloat *texel )
 {
    const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
-   texel[RCOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
-   texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
-   texel[BCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
-   texel[ACOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
+   texel[RCOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
+   texel[GCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
+   texel[BCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
+   texel[ACOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
 }
 
 

Comments

Am 04.03.2014 17:10, schrieb Brian Paul:
> Spotted by Chia-I Wu.
> ---
>  src/mesa/main/format_pack.c      |    2 +-
>  src/mesa/main/format_unpack.c    |    8 ++++----
>  src/mesa/swrast/s_texfetch_tmp.h |    8 ++++----
>  3 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c
> index 2772ff2..ee505ec 100644
> --- a/src/mesa/main/format_pack.c
> +++ b/src/mesa/main/format_pack.c
> @@ -567,7 +567,7 @@ static void
>  pack_ubyte_ARGB4444_REV(const GLubyte src[4], void *dst)
>  {
>     GLushort *d = ((GLushort *) dst);
> -   *d = PACK_COLOR_4444(src[GCOMP], src[BCOMP], src[ACOMP], src[RCOMP]);
> +   *d = PACK_COLOR_4444(src[BCOMP], src[GCOMP], src[RCOMP], src[ACOMP]);
>  }
>  
>  static void
> diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
> index 276ba55..d8bf57d 100644
> --- a/src/mesa/main/format_unpack.c
> +++ b/src/mesa/main/format_unpack.c
> @@ -267,10 +267,10 @@ unpack_ARGB4444_REV(const void *src, GLfloat dst[][4], GLuint n)
>     const GLushort *s = ((const GLushort *) src);
>     GLuint i;
>     for (i = 0; i < n; i++) {
> -      dst[i][RCOMP] = ((s[i]      ) & 0xf) * (1.0F / 15.0F);
> -      dst[i][GCOMP] = ((s[i] >> 12) & 0xf) * (1.0F / 15.0F);
> -      dst[i][BCOMP] = ((s[i] >>  8) & 0xf) * (1.0F / 15.0F);
> -      dst[i][ACOMP] = ((s[i] >>  4) & 0xf) * (1.0F / 15.0F);
> +      dst[i][RCOMP] = ((s[i] >>  4) & 0xf) * (1.0F / 15.0F);
> +      dst[i][GCOMP] = ((s[i] >>  8) & 0xf) * (1.0F / 15.0F);
> +      dst[i][BCOMP] = ((s[i] >> 12) & 0xf) * (1.0F / 15.0F);
> +      dst[i][ACOMP] = ((s[i]      ) & 0xf) * (1.0F / 15.0F);
>     }
>  }
>  
> diff --git a/src/mesa/swrast/s_texfetch_tmp.h b/src/mesa/swrast/s_texfetch_tmp.h
> index 806f0fd..1db3adc 100644
> --- a/src/mesa/swrast/s_texfetch_tmp.h
> +++ b/src/mesa/swrast/s_texfetch_tmp.h
> @@ -611,10 +611,10 @@ static void FETCH(f_argb4444_rev)( const struct swrast_texture_image *texImage,
>                                     GLint i, GLint j, GLint k, GLfloat *texel )
>  {
>     const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
> -   texel[RCOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
> -   texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
> -   texel[BCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
> -   texel[ACOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
> +   texel[RCOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
> +   texel[GCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
> +   texel[BCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
> +   texel[ACOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
>  }
>  
>  
> 

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
On Wed, Mar 5, 2014 at 12:10 AM, Brian Paul <brianp@vmware.com> wrote:
> Spotted by Chia-I Wu.
unpack_ubyte_ARGB4444_REV() needs the same care too.  With that fixed,
this patch is

Reviewed-by: Chia-I Wu <olv@lunarg.com>


> ---
>  src/mesa/main/format_pack.c      |    2 +-
>  src/mesa/main/format_unpack.c    |    8 ++++----
>  src/mesa/swrast/s_texfetch_tmp.h |    8 ++++----
>  3 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c
> index 2772ff2..ee505ec 100644
> --- a/src/mesa/main/format_pack.c
> +++ b/src/mesa/main/format_pack.c
> @@ -567,7 +567,7 @@ static void
>  pack_ubyte_ARGB4444_REV(const GLubyte src[4], void *dst)
>  {
>     GLushort *d = ((GLushort *) dst);
> -   *d = PACK_COLOR_4444(src[GCOMP], src[BCOMP], src[ACOMP], src[RCOMP]);
> +   *d = PACK_COLOR_4444(src[BCOMP], src[GCOMP], src[RCOMP], src[ACOMP]);
>  }
>
>  static void
> diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
> index 276ba55..d8bf57d 100644
> --- a/src/mesa/main/format_unpack.c
> +++ b/src/mesa/main/format_unpack.c
> @@ -267,10 +267,10 @@ unpack_ARGB4444_REV(const void *src, GLfloat dst[][4], GLuint n)
>     const GLushort *s = ((const GLushort *) src);
>     GLuint i;
>     for (i = 0; i < n; i++) {
> -      dst[i][RCOMP] = ((s[i]      ) & 0xf) * (1.0F / 15.0F);
> -      dst[i][GCOMP] = ((s[i] >> 12) & 0xf) * (1.0F / 15.0F);
> -      dst[i][BCOMP] = ((s[i] >>  8) & 0xf) * (1.0F / 15.0F);
> -      dst[i][ACOMP] = ((s[i] >>  4) & 0xf) * (1.0F / 15.0F);
> +      dst[i][RCOMP] = ((s[i] >>  4) & 0xf) * (1.0F / 15.0F);
> +      dst[i][GCOMP] = ((s[i] >>  8) & 0xf) * (1.0F / 15.0F);
> +      dst[i][BCOMP] = ((s[i] >> 12) & 0xf) * (1.0F / 15.0F);
> +      dst[i][ACOMP] = ((s[i]      ) & 0xf) * (1.0F / 15.0F);
>     }
>  }
>
> diff --git a/src/mesa/swrast/s_texfetch_tmp.h b/src/mesa/swrast/s_texfetch_tmp.h
> index 806f0fd..1db3adc 100644
> --- a/src/mesa/swrast/s_texfetch_tmp.h
> +++ b/src/mesa/swrast/s_texfetch_tmp.h
> @@ -611,10 +611,10 @@ static void FETCH(f_argb4444_rev)( const struct swrast_texture_image *texImage,
>                                     GLint i, GLint j, GLint k, GLfloat *texel )
>  {
>     const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
> -   texel[RCOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
> -   texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
> -   texel[BCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
> -   texel[ACOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
> +   texel[RCOMP] = ((s >>  4) & 0xf) * (1.0F / 15.0F);
> +   texel[GCOMP] = ((s >>  8) & 0xf) * (1.0F / 15.0F);
> +   texel[BCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
> +   texel[ACOMP] = ((s      ) & 0xf) * (1.0F / 15.0F);
>  }
>
>
> --
> 1.7.10.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
On 03/04/2014 08:17 PM, Chia-I Wu wrote:
> On Wed, Mar 5, 2014 at 12:10 AM, Brian Paul <brianp@vmware.com> wrote:
>> Spotted by Chia-I Wu.
> unpack_ubyte_ARGB4444_REV() needs the same care too.  With that fixed,
> this patch is
>
> Reviewed-by: Chia-I Wu <olv@lunarg.com>

I missed that function in the original patch.  Follow-up patch posted...

Thanks.

-Brian
On 03/05/2014 09:02 AM, Brian Paul wrote:
> On 03/04/2014 08:17 PM, Chia-I Wu wrote:
>> On Wed, Mar 5, 2014 at 12:10 AM, Brian Paul <brianp@vmware.com> wrote:
>>> Spotted by Chia-I Wu.
>> unpack_ubyte_ARGB4444_REV() needs the same care too.  With that fixed,
>> this patch is
>>
>> Reviewed-by: Chia-I Wu <olv@lunarg.com>
>
> I missed that function in the original patch.  Follow-up patch posted...

I guess I didn't push the original patch yet so I'll squash the two 
patches before pushing.

-Brian