diff options
author | Chia-I Wu <[email protected]> | 2011-11-28 16:57:02 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2011-12-02 08:43:46 +0800 |
commit | d4a38e86d4b4d66cca20ee63222f940cb73fa709 (patch) | |
tree | 059bf69787804996049163ffa2ee809560bfc04a /src/mesa/main/teximage.c | |
parent | 51f4d2725417088c75d512b69a31a26ae5cb3ef2 (diff) |
mesa: add support for GL_OES_compressed_ETC1_RGB8_texture
Add support for GL_OES_compressed_ETC1_RGB8_texture to core mesa. There is no
driver support yet.
Unlike desktop GL compressed texture formats, GLES compressed texture formats
usually can only be used with glCompressedTexImage2D. All other gl*Tex*Image*
functions are updated to check for that.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r-- | src/mesa/main/teximage.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 2bc7abdc247..2bdcedc8c13 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -493,6 +493,15 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) } } + if (ctx->Extensions.OES_compressed_ETC1_RGB8_texture) { + switch (internalFormat) { + case GL_ETC1_RGB8_OES: + return GL_RGB; + default: + ; /* fallthrough */ + } + } + if (ctx->API == API_OPENGLES) { switch (internalFormat) { case GL_PALETTE4_RGB8_OES: @@ -1292,6 +1301,20 @@ legal_texture_size(struct gl_context *ctx, gl_format format, } +/** + * Return true if the format is only valid for glCompressedTexImage. + */ +static GLboolean +compressedteximage_only_format(const struct gl_context *ctx, GLenum format) +{ + switch (format) { + case GL_ETC1_RGB8_OES: + return GL_TRUE; + default: + return GL_FALSE; + } +} + /** * Helper function to determine whether a target and specific compression @@ -1639,6 +1662,11 @@ texture_error_check( struct gl_context *ctx, "glTexImage%dD(target)", dimensions); return GL_TRUE; } + if (compressedteximage_only_format(ctx, internalFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexImage%dD(no compression for format)", dimensions); + return GL_TRUE; + } if (border != 0) { if (!isProxy) { _mesa_error(ctx, GL_INVALID_OPERATION, @@ -1793,6 +1821,12 @@ subtexture_error_check2( struct gl_context *ctx, GLuint dimensions, if (_mesa_is_format_compressed(destTex->TexFormat)) { GLuint bw, bh; + if (compressedteximage_only_format(ctx, destTex->InternalFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glTexSubImage%dD(no compression for format)", dimensions); + return GL_TRUE; + } + /* do tests which depend on compression block size */ _mesa_get_format_block_size(destTex->TexFormat, &bw, &bh); @@ -1922,6 +1956,11 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions, "glCopyTexImage%dD(target)", dimensions); return GL_TRUE; } + if (compressedteximage_only_format(ctx, internalFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexImage%dD(no compression for format)", dimensions); + return GL_TRUE; + } if (border != 0) { _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexImage%dD(border!=0)", dimensions); @@ -2061,6 +2100,11 @@ copytexsubimage_error_check2( struct gl_context *ctx, GLuint dimensions, } if (_mesa_is_format_compressed(teximage->TexFormat)) { + if (compressedteximage_only_format(ctx, teximage->InternalFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCopyTexSubImage%dD(no compression for format)", dimensions); + return GL_TRUE; + } /* offset must be multiple of 4 */ if ((xoffset & 3) || (yoffset & 3)) { _mesa_error(ctx, GL_INVALID_VALUE, @@ -3244,6 +3288,13 @@ compressed_subtexture_error_check2(struct gl_context *ctx, GLuint dims, return GL_TRUE; } + if (compressedteximage_only_format(ctx, format)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glCompressedTexSubImage%uD(format=0x%x cannot be updated)" + , dims, format); + return GL_TRUE; + } + if (((width == 1 || width == 2) && width != (GLsizei) texImage->Width) || (width > (GLsizei) texImage->Width)) { |