X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fglformats.c;h=ba79f193b3f93383aa275ea58a19fbc5f07dc2ec;hb=aab0ea935290cdbf6c74e4d001d4bbc8178fc14a;hp=047a613a1314bc8ac52b4824a1c057d2b2a6d5a2;hpb=88233b0bc301eb0ccdf23ffcb0245b3faad43b04;p=mesa.git diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 047a613a131..ba79f193b3f 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -791,8 +791,10 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) return ctx->Extensions.EXT_texture_compression_s3tc; case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return _mesa_is_desktop_gl(ctx) - && ctx->Extensions.EXT_texture_compression_s3tc; + return (_mesa_is_desktop_gl(ctx) && + ctx->Extensions.EXT_texture_compression_s3tc) || + (ctx->API == API_OPENGLES2 && + ctx->Extensions.ANGLE_texture_compression_dxt); case GL_RGB_S3TC: case GL_RGB4_S3TC: case GL_RGBA_S3TC: @@ -827,7 +829,6 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) case GL_ETC1_RGB8_OES: return _mesa_is_gles(ctx) && ctx->Extensions.OES_compressed_ETC1_RGB8_texture; -#if FEATURE_ES case GL_PALETTE4_RGB8_OES: case GL_PALETTE4_RGBA8_OES: case GL_PALETTE4_R5_G6_B5_OES: @@ -839,7 +840,6 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) case GL_PALETTE8_RGBA4_OES: case GL_PALETTE8_RGB5_A1_OES: return ctx->API == API_OPENGLES; -#endif default: return GL_FALSE; } @@ -1372,3 +1372,72 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx, } return GL_NO_ERROR; } + + +/** + * Do error checking of format/type combinations for OpenGL ES glReadPixels + * and glTex[Sub]Image. + * \return error code, or GL_NO_ERROR. + */ +GLenum +_mesa_es_error_check_format_and_type(GLenum format, GLenum type, + unsigned dimensions) +{ + GLboolean type_valid = GL_TRUE; + + switch (format) { + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + type_valid = (type == GL_UNSIGNED_BYTE + || type == GL_FLOAT + || type == GL_HALF_FLOAT_OES); + break; + + case GL_RGB: + type_valid = (type == GL_UNSIGNED_BYTE + || type == GL_UNSIGNED_SHORT_5_6_5 + || type == GL_FLOAT + || type == GL_HALF_FLOAT_OES); + break; + + case GL_RGBA: + type_valid = (type == GL_UNSIGNED_BYTE + || type == GL_UNSIGNED_SHORT_4_4_4_4 + || type == GL_UNSIGNED_SHORT_5_5_5_1 + || type == GL_FLOAT + || type == GL_HALF_FLOAT_OES + || type == GL_UNSIGNED_INT_2_10_10_10_REV); + break; + + case GL_DEPTH_COMPONENT: + /* This format is filtered against invalid dimensionalities elsewhere. + */ + type_valid = (type == GL_UNSIGNED_SHORT + || type == GL_UNSIGNED_INT); + break; + + case GL_DEPTH_STENCIL: + /* This format is filtered against invalid dimensionalities elsewhere. + */ + type_valid = (type == GL_UNSIGNED_INT_24_8); + break; + + case GL_BGRA_EXT: + type_valid = (type == GL_UNSIGNED_BYTE); + + /* This feels like a bug in the EXT_texture_format_BGRA8888 spec, but + * the format does not appear to be allowed for 3D textures in OpenGL + * ES. + */ + if (dimensions != 2) + return GL_INVALID_VALUE; + + break; + + default: + return GL_INVALID_VALUE; + } + + return type_valid ? GL_NO_ERROR : GL_INVALID_OPERATION; +}