[Mesa-dev] [PATCH 06/23] glformats: add _mesa_es3_error_check_format_and_type

Ian Romanick idr at freedesktop.org
Mon Jan 7 10:32:56 PST 2013


On 01/04/2013 06:41 PM, Jordan Justen wrote:
> From: Matt Turner <mattst88 at gmail.com>
>
> This function checks for ES3 compatible
> format/type/internalFormat/dimension combinations.
>
> [jordan.l.justen at intel.com: additional tweaks for gles3-gtf]
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
>   src/mesa/main/glformats.c |  439 +++++++++++++++++++++++++++++++++++++++++++++
>   src/mesa/main/glformats.h |    5 +
>   2 files changed, 444 insertions(+)
>
> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
> index d2126bb..957afe7 100644
> --- a/src/mesa/main/glformats.c
> +++ b/src/mesa/main/glformats.c
> @@ -1653,3 +1653,442 @@ _mesa_es_error_check_format_and_type(GLenum format, GLenum type,
>
>      return type_valid ? GL_NO_ERROR : GL_INVALID_OPERATION;
>   }
> +
> +
> +/**
> + * Do error checking of format/type combinations for OpenGL ES 3
> + * glTex[Sub]Image.
> + * \return error code, or GL_NO_ERROR.
> + */
> +GLenum
> +_mesa_es3_error_check_format_and_type(GLenum format, GLenum type,
> +                                      GLenum internalFormat,
> +                                      unsigned dimensions)
> +{
> +   GLboolean type_valid = GL_TRUE;
> +
> +   switch (format) {
> +   case GL_RGBA:
> +      switch (type) {
> +      case GL_UNSIGNED_BYTE:
> +         switch (internalFormat) {
> +         case GL_RGBA:
> +         case GL_RGBA8:
> +         case GL_RGB5_A1:
> +         case GL_RGBA4:
> +         case GL_SRGB8_ALPHA8_EXT:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      case GL_BYTE:
> +         if (internalFormat != GL_RGBA8_SNORM)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_SHORT_4_4_4_4:
> +         switch (internalFormat) {
> +         case GL_RGBA:
> +         case GL_RGBA4:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      case GL_UNSIGNED_SHORT_5_5_5_1:
> +         switch (internalFormat) {
> +         case GL_RGBA:
> +         case GL_RGB5_A1:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      case GL_UNSIGNED_INT_2_10_10_10_REV:
> +         switch (internalFormat) {
> +         case GL_RGBA: /* XXX: Spec does *not* say this, but the test expects it */

Does the test check for GL_EXT_texture_type_2_10_10_10_REV?  This is 
from that extension, and I believe Mesa supports that.

> +         case GL_RGB10_A2:
> +         case GL_RGB5_A1:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      case GL_HALF_FLOAT:
> +         if (internalFormat != GL_RGBA16F)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_FLOAT:
> +         switch (internalFormat) {
> +         case GL_RGBA16F:
> +         case GL_RGBA32F:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      default:
> +         return GL_INVALID_OPERATION;
> +      }
> +      break;
> +
> +   case GL_RGBA_INTEGER:
> +      switch (type) {
> +      case GL_UNSIGNED_BYTE:
> +         if (internalFormat != GL_RGBA8UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_BYTE:
> +         if (internalFormat != GL_RGBA8I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_SHORT:
> +         if (internalFormat != GL_RGBA16UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_SHORT:
> +         if (internalFormat != GL_RGBA16I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_INT:
> +         if (internalFormat != GL_RGBA32UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_INT:
> +         if (internalFormat != GL_RGBA32I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_INT_2_10_10_10_REV:
> +         if (internalFormat != GL_RGB10_A2UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      default:
> +         return GL_INVALID_OPERATION;
> +      }
> +      break;
> +
> +   case GL_RGB:
> +      switch (type) {
> +      case GL_UNSIGNED_BYTE:
> +         switch (internalFormat) {
> +         case GL_RGB:
> +         case GL_RGB8:
> +         case GL_RGB565:
> +         case GL_SRGB8:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      case GL_BYTE:
> +         if (internalFormat != GL_RGB8_SNORM)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_SHORT_5_6_5:
> +         switch (internalFormat) {
> +         case GL_RGB:
> +         case GL_RGB565:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      case GL_UNSIGNED_INT_10F_11F_11F_REV:
> +         if (internalFormat != GL_R11F_G11F_B10F)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_INT_5_9_9_9_REV:
> +         if (internalFormat != GL_RGB9_E5)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_HALF_FLOAT:
> +         switch (internalFormat) {
> +         case GL_RGB16F:
> +         case GL_R11F_G11F_B10F:
> +         case GL_RGB9_E5:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      case GL_FLOAT:
> +         switch (internalFormat) {
> +         case GL_RGB16F:
> +         case GL_RGB32F:
> +         case GL_R11F_G11F_B10F:
> +         case GL_RGB9_E5:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      case GL_UNSIGNED_INT_2_10_10_10_REV:
> +         switch (internalFormat) {
> +         case GL_RGB:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      default:
> +         return GL_INVALID_OPERATION;
> +      }
> +      break;
> +
> +   case GL_RGB_INTEGER:
> +      switch (type) {
> +      case GL_UNSIGNED_BYTE:
> +         if (internalFormat != GL_RGB8UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_BYTE:
> +         if (internalFormat != GL_RGB8I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_SHORT:
> +         if (internalFormat != GL_RGB16UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_SHORT:
> +         if (internalFormat != GL_RGB16I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_INT:
> +         if (internalFormat != GL_RGB32UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_INT:
> +         if (internalFormat != GL_RGB32I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      default:
> +         return GL_INVALID_OPERATION;
> +      }
> +      break;
> +
> +   case GL_RG:
> +      switch (type) {
> +      case GL_UNSIGNED_BYTE:
> +         if (internalFormat != GL_RG8)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_BYTE:
> +         if (internalFormat != GL_RG8_SNORM)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_HALF_FLOAT:
> +         if (internalFormat != GL_RG16F)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_FLOAT:
> +         switch (internalFormat) {
> +         case GL_RG16F:
> +         case GL_RG32F:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      default:
> +         return GL_INVALID_OPERATION;
> +      }
> +      break;
> +
> +   case GL_RG_INTEGER:
> +      switch (type) {
> +      case GL_UNSIGNED_BYTE:
> +         if (internalFormat != GL_RG8UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_BYTE:
> +         if (internalFormat != GL_RG8I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_SHORT:
> +         if (internalFormat != GL_RG16UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_SHORT:
> +         if (internalFormat != GL_RG16I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_INT:
> +         if (internalFormat != GL_RG32UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_INT:
> +         if (internalFormat != GL_RG32I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      default:
> +         return GL_INVALID_OPERATION;
> +      }
> +      break;
> +
> +   case GL_RED:
> +      switch (type) {
> +      case GL_UNSIGNED_BYTE:
> +         if (internalFormat != GL_R8)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_BYTE:
> +         if (internalFormat != GL_R8_SNORM)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_HALF_FLOAT:
> +         if (internalFormat != GL_R16F)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_FLOAT:
> +         switch (internalFormat) {
> +         case GL_R16F:
> +         case GL_R32F:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      default:
> +         return GL_INVALID_OPERATION;
> +      }
> +      break;
> +
> +   case GL_RED_INTEGER:
> +      switch (type) {
> +      case GL_UNSIGNED_BYTE:
> +         if (internalFormat != GL_R8UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_BYTE:
> +         if (internalFormat != GL_R8I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_SHORT:
> +         if (internalFormat != GL_R16UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_SHORT:
> +         if (internalFormat != GL_R16I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_INT:
> +         if (internalFormat != GL_R32UI)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_INT:
> +         if (internalFormat != GL_R32I)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      default:
> +         return GL_INVALID_OPERATION;
> +      }
> +      break;
> +
> +   case GL_DEPTH_COMPONENT:
> +      if (dimensions != 2) {
> +         return GL_INVALID_OPERATION;
> +      }
> +      switch (type) {
> +      case GL_UNSIGNED_SHORT:
> +         if (internalFormat != GL_DEPTH_COMPONENT16)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_UNSIGNED_INT:
> +         switch (internalFormat) {
> +         case GL_DEPTH_COMPONENT16:
> +         case GL_DEPTH_COMPONENT24:
> +            break;
> +         default:
> +            return GL_INVALID_OPERATION;
> +         }
> +         break;
> +
> +      case GL_FLOAT:
> +         if (internalFormat != GL_DEPTH_COMPONENT32F)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      default:
> +         return GL_INVALID_OPERATION;
> +      }
> +      break;
> +
> +   case GL_DEPTH_STENCIL:
> +      if (dimensions != 2) {
> +         return GL_INVALID_OPERATION;
> +      }
> +      switch (type) {
> +      case GL_UNSIGNED_INT_24_8:
> +         if (internalFormat != GL_DEPTH24_STENCIL8)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
> +         if (internalFormat != GL_DEPTH32F_STENCIL8)
> +            return GL_INVALID_OPERATION;
> +         break;
> +
> +      default:
> +         return GL_INVALID_OPERATION;
> +      }
> +      break;
> +
> +   case GL_ALPHA:
> +   case GL_LUMINANCE:
> +   case GL_LUMINANCE_ALPHA:
> +      if (type != GL_UNSIGNED_BYTE || format != internalFormat)
> +         return GL_INVALID_OPERATION;
> +      break;
> +   }
> +
> +   return type_valid ? GL_NO_ERROR : GL_INVALID_OPERATION;
> +}
> diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h
> index d1208ef..9658a46 100644
> --- a/src/mesa/main/glformats.h
> +++ b/src/mesa/main/glformats.h
> @@ -117,6 +117,11 @@ extern GLenum
>   _mesa_es_error_check_format_and_type(GLenum format, GLenum type,
>                                        unsigned dimensions);
>
> +extern GLenum
> +_mesa_es3_error_check_format_and_type(GLenum format, GLenum type,
> +                                      GLenum internalFormat,
> +                                      unsigned dimensions);
> +
>
>   #ifdef __cplusplus
>   }
>



More information about the mesa-dev mailing list