[Mesa-dev] [PATCH 6/6] mesa/formats: 8-bit channel integer formats addition
Brian Paul
brianp at vmware.com
Tue Sep 1 10:32:19 PDT 2015
For 5&6, I didn't check every tiny detail, but looks good to me.
Reviewed-by: Brian Paul <brianp at vmware.com>
On 08/25/2015 07:14 PM, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> Add enough 8-bit channel formats to handle all the
> different things CTS throws at us.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
> src/mesa/main/formats.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> src/mesa/main/formats.csv | 4 ++++
> src/mesa/main/formats.h | 5 +++++
> src/mesa/main/glformats.c | 8 ++++++++
> src/mesa/swrast/s_texfetch.c | 4 ++++
> 5 files changed, 64 insertions(+)
>
> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
> index e73a549..e151f30 100644
> --- a/src/mesa/main/formats.c
> +++ b/src/mesa/main/formats.c
> @@ -883,6 +883,10 @@ _mesa_uncompressed_format_to_type_and_comps(mesa_format format,
> case MESA_FORMAT_R8G8B8X8_UNORM:
> case MESA_FORMAT_B8G8R8X8_UNORM:
> case MESA_FORMAT_X8R8G8B8_UNORM:
> + case MESA_FORMAT_A8B8G8R8_UINT:
> + case MESA_FORMAT_R8G8B8A8_UINT:
> + case MESA_FORMAT_B8G8R8A8_UINT:
> + case MESA_FORMAT_A8R8G8B8_UINT:
> *datatype = GL_UNSIGNED_BYTE;
> *comps = 4;
> return;
> @@ -1992,6 +1996,45 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
> case MESA_FORMAT_R5G5B5A1_UINT:
> return format == GL_RGBA_INTEGER && type == GL_UNSIGNED_SHORT_1_5_5_5_REV;
>
> + case MESA_FORMAT_A8B8G8R8_UINT:
> + if (format == GL_RGBA_INTEGER && type == GL_UNSIGNED_INT_8_8_8_8 && !swapBytes)
> + return GL_TRUE;
> +
> + if (format == GL_RGBA_INTEGER && type == GL_UNSIGNED_INT_8_8_8_8_REV && swapBytes)
> + return GL_TRUE;
> + return GL_FALSE;
> +
> + case MESA_FORMAT_A8R8G8B8_UINT:
> + if (format == GL_BGRA_INTEGER && type == GL_UNSIGNED_INT_8_8_8_8 &&
> + !swapBytes)
> + return GL_TRUE;
> +
> + if (format == GL_BGRA_INTEGER && type == GL_UNSIGNED_INT_8_8_8_8_REV &&
> + swapBytes)
> + return GL_TRUE;
> +
> + return GL_FALSE;
> +
> + case MESA_FORMAT_R8G8B8A8_UINT:
> + if (format == GL_RGBA_INTEGER && type == GL_UNSIGNED_INT_8_8_8_8_REV &&
> + !swapBytes)
> + return GL_TRUE;
> +
> + if (format == GL_RGBA_INTEGER && type == GL_UNSIGNED_INT_8_8_8_8 && swapBytes)
> + return GL_TRUE;
> +
> + return GL_FALSE;
> +
> + case MESA_FORMAT_B8G8R8A8_UINT:
> + if (format == GL_BGRA_INTEGER && type == GL_UNSIGNED_INT_8_8_8_8_REV &&
> + !swapBytes)
> + return GL_TRUE;
> +
> + if (format == GL_BGRA_INTEGER && type == GL_UNSIGNED_INT_8_8_8_8 && swapBytes)
> + return GL_TRUE;
> +
> + return GL_FALSE;
> +
> case MESA_FORMAT_R9G9B9E5_FLOAT:
> return format == GL_RGB && type == GL_UNSIGNED_INT_5_9_9_9_REV &&
> !swapBytes;
> diff --git a/src/mesa/main/formats.csv b/src/mesa/main/formats.csv
> index d30b0a9..3e70655 100644
> --- a/src/mesa/main/formats.csv
> +++ b/src/mesa/main/formats.csv
> @@ -186,6 +186,10 @@ MESA_FORMAT_RGBX_FLOAT32 , array , 1, 1, f32 , f32 , f32 , x32
> MESA_FORMAT_Z_FLOAT32 , array , 1, 1, f32 , , , , x___, zs
>
> # Packed signed/unsigned non-normalized integer formats
> +MESA_FORMAT_A8B8G8R8_UINT , packed, 1, 1, u8 , u8 , u8 , u8 , wzyx, rgb
> +MESA_FORMAT_A8R8G8B8_UINT , packed, 1, 1, u8 , u8 , u8 , u8 , yzwx, rgb
> +MESA_FORMAT_R8G8B8A8_UINT , packed, 1, 1, u8 , u8 , u8 , u8 , xyzw, rgb
> +MESA_FORMAT_B8G8R8A8_UINT , packed, 1, 1, u8 , u8 , u8 , u8 , zyxw, rgb
> MESA_FORMAT_B10G10R10A2_UINT , packed, 1, 1, u10 , u10 , u10 , u2 , zyxw, rgb
> MESA_FORMAT_R10G10B10A2_UINT , packed, 1, 1, u10 , u10 , u10 , u2 , xyzw, rgb
> MESA_FORMAT_A2B10G10R10_UINT , packed, 1, 1, u2 , u10 , u10 , u10 , wzyx, rgb
> diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
> index dff5980..17cb091 100644
> --- a/src/mesa/main/formats.h
> +++ b/src/mesa/main/formats.h
> @@ -470,6 +470,11 @@ typedef enum
> MESA_FORMAT_Z_FLOAT32,
>
> /* Packed signed/unsigned non-normalized integer formats */
> +
> + MESA_FORMAT_A8B8G8R8_UINT, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
> + MESA_FORMAT_A8R8G8B8_UINT, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
> + MESA_FORMAT_R8G8B8A8_UINT, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
> + MESA_FORMAT_B8G8R8A8_UINT, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
> MESA_FORMAT_B10G10R10A2_UINT, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */
> MESA_FORMAT_R10G10B10A2_UINT, /* AABB BBBB BBBB GGGG GGGG GGRR RRRR RRRR */
> MESA_FORMAT_A2B10G10R10_UINT, /* RRRR RRRR RRGG GGGG GGGG BBBB BBBB BBAA */
> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
> index 672532f..cef831c 100644
> --- a/src/mesa/main/glformats.c
> +++ b/src/mesa/main/glformats.c
> @@ -2818,6 +2818,10 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type)
> return MESA_FORMAT_A8R8G8B8_UNORM;
> else if (format == GL_ABGR_EXT)
> return MESA_FORMAT_R8G8B8A8_UNORM;
> + else if (format == GL_RGBA_INTEGER)
> + return MESA_FORMAT_A8B8G8R8_UINT;
> + else if (format == GL_BGRA_INTEGER)
> + return MESA_FORMAT_A8R8G8B8_UINT;
> break;
> case GL_UNSIGNED_INT_8_8_8_8_REV:
> if (format == GL_RGBA)
> @@ -2826,6 +2830,10 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type)
> return MESA_FORMAT_B8G8R8A8_UNORM;
> else if (format == GL_ABGR_EXT)
> return MESA_FORMAT_A8B8G8R8_UNORM;
> + else if (format == GL_RGBA_INTEGER)
> + return MESA_FORMAT_R8G8B8A8_UINT;
> + else if (format == GL_BGRA_INTEGER)
> + return MESA_FORMAT_B8G8R8A8_UINT;
> break;
> case GL_UNSIGNED_SHORT_8_8_MESA:
> if (format == GL_YCBCR_MESA)
> diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c
> index 0bf19f9..99fff08 100644
> --- a/src/mesa/swrast/s_texfetch.c
> +++ b/src/mesa/swrast/s_texfetch.c
> @@ -282,6 +282,10 @@ texfetch_funcs[] =
> },
>
> /* Packed signed/unsigned non-normalized integer formats */
> + FETCH_NULL(A8B8G8R8_UINT),
> + FETCH_NULL(A8R8G8B8_UINT),
> + FETCH_NULL(R8G8B8A8_UINT),
> + FETCH_NULL(B8G8R8A8_UINT),
> FETCH_NULL(B10G10R10A2_UINT),
> FETCH_NULL(R10G10B10A2_UINT),
> FETCH_NULL(A2B10G10R10_UINT),
>
More information about the mesa-dev
mailing list