diff options
author | Brian Paul <[email protected]> | 2015-07-22 07:53:01 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2015-07-23 20:19:50 -0600 |
commit | 3afa40e43368b29ca99018999936336c3879fa4d (patch) | |
tree | 627a7b3ef0dba0dde7717d993f84fbf687e2bab8 /src | |
parent | 05a44ab32832efe61a252ef4ac2d128c1101c286 (diff) |
mesa: do more thorough target checking in compressed_subtexture_target_check()
When we're error-checking the target, we also need to check if the
corresponding extension is supported.
Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/teximage.c | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 0726758076f..949eef0e285 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -4555,13 +4555,15 @@ compressed_subtexture_target_check(struct gl_context *ctx, GLenum target, case 2: switch (target) { case GL_TEXTURE_2D: + targetOK = GL_TRUE; + break; case GL_TEXTURE_CUBE_MAP_POSITIVE_X: case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - targetOK = GL_TRUE; + targetOK = ctx->Extensions.ARB_texture_cube_map; break; default: targetOK = GL_FALSE; @@ -4569,31 +4571,40 @@ compressed_subtexture_target_check(struct gl_context *ctx, GLenum target, } break; case 3: - targetOK = (target == GL_TEXTURE_3D) || - (target == GL_TEXTURE_2D_ARRAY) || - (target == GL_TEXTURE_CUBE_MAP_ARRAY) || - (target == GL_TEXTURE_CUBE_MAP && dsa); - - /* OpenGL 4.5 spec (30.10.2014) says in Section 8.7 Compressed Texture - * Images: - * "An INVALID_OPERATION error is generated by - * CompressedTex*SubImage3D if the internal format of the texture is - * one of the EAC, ETC2, or RGTC formats and either border is - * non-zero, or the effective target for the texture is not - * TEXTURE_2D_ARRAY." - * - * NOTE: that's probably a spec error. It should probably say - * "... or the effective target for the texture is not - * TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP, nor GL_TEXTURE_CUBE_MAP_ARRAY." - * since those targets are 2D images and they support all compression - * formats. - * - * Instead of listing all these, just list those which are allowed, - * which is (at this time) only bptc. Otherwise we'd say s3tc (and more) - * are valid here, which they are not, but of course not mentioned by - * core spec. - */ - if (target == GL_TEXTURE_3D) { + switch (target) { + case GL_TEXTURE_CUBE_MAP: + targetOK = dsa && ctx->Extensions.ARB_texture_cube_map; + break; + case GL_TEXTURE_2D_ARRAY: + targetOK = _mesa_is_gles3(ctx) || + (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array); + break; + case GL_TEXTURE_CUBE_MAP_ARRAY: + targetOK = ctx->Extensions.ARB_texture_cube_map_array; + break; + case GL_TEXTURE_3D: + targetOK = GL_TRUE; + /* + * OpenGL 4.5 spec (30.10.2014) says in Section 8.7 Compressed Texture + * Images: + * "An INVALID_OPERATION error is generated by + * CompressedTex*SubImage3D if the internal format of the texture + * is one of the EAC, ETC2, or RGTC formats and either border is + * non-zero, or the effective target for the texture is not + * TEXTURE_2D_ARRAY." + * + * NOTE: that's probably a spec error. It should probably say + * "... or the effective target for the texture is not + * TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP, nor + * GL_TEXTURE_CUBE_MAP_ARRAY." + * since those targets are 2D images and they support all compression + * formats. + * + * Instead of listing all these, just list those which are allowed, + * which is (at this time) only bptc. Otherwise we'd say s3tc (and + * more) are valid here, which they are not, but of course not + * mentioned by core spec. + */ switch (format) { /* These are the only 3D compression formats supported at this time */ case GL_COMPRESSED_RGBA_BPTC_UNORM: @@ -4610,6 +4621,9 @@ compressed_subtexture_target_check(struct gl_context *ctx, GLenum target, _mesa_enum_to_string(format)); return GL_TRUE; } + break; + default: + targetOK = GL_FALSE; } break; |