diff options
author | Matt Turner <[email protected]> | 2012-12-06 14:51:29 -0800 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2013-01-14 20:47:59 -0800 |
commit | 9cfcac45283e12188de915bd6be3522f13b690d3 (patch) | |
tree | fda403d449ecb68435db876f4d0d512e10eb5b8c | |
parent | cf300eaab68153d818f6c29f4b487162a589dcfa (diff) |
glformats: add _mesa_es3_error_check_format_and_type
This function checks for ES3 compatible
format/type/internalFormat/dimension combinations.
[[email protected]: additional tweaks for gles3-gtf]
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
-rw-r--r-- | src/mesa/main/glformats.c | 439 | ||||
-rw-r--r-- | src/mesa/main/glformats.h | 5 |
2 files changed, 444 insertions, 0 deletions
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index ff56ffad04f..678ba95b5b7 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -1670,3 +1670,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: /* GL_EXT_texture_type_2_10_10_10_REV */ + 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: /* GL_EXT_texture_type_2_10_10_10_REV */ + 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 fe604ddc973..4cbc82f5e01 100644 --- a/src/mesa/main/glformats.h +++ b/src/mesa/main/glformats.h @@ -120,6 +120,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 } |