summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2012-09-08 09:27:46 -0600
committerIan Romanick <ian.d.romanick@intel.com>2012-10-24 11:41:07 -0700
commit59b1e4a29e756d291f815d4429c8af0e4cf068aa (patch)
treeb02421435fefa3d648f81021b1ba4cd0552414be
parent9afcb18146c457a789266eafa8596c96445d7c5e (diff)
downloadmesa-59b1e4a29e756d291f815d4429c8af0e4cf068aa.tar.gz
mesa: do internal format error checking for glTexStorage()
Turns out we weren't doing any format checking before. Now check the internal format and, in particular, make sure that unsized internal formats aren't accepted. Note: This is a candidate for the stable branches. (cherry picked from commit 2e4fc54977977e674ee77294e6632a24e594d17f)
-rw-r--r--src/mesa/main/texstorage.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c
index 5e1f31a9377..68847f1f97e 100644
--- a/src/mesa/main/texstorage.c
+++ b/src/mesa/main/texstorage.c
@@ -244,6 +244,54 @@ tex_storage_error_check(struct gl_context *ctx, GLuint dims, GLenum target,
const GLboolean isProxy = _mesa_is_proxy_texture(target);
struct gl_texture_object *texObj;
GLuint maxDim;
+ GLboolean legalFormat;
+
+ /* check internal format - note that only sized formats are allowed */
+ switch (internalformat) {
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ case GL_RED:
+ case GL_RG:
+ case GL_RGB:
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_STENCIL:
+ case GL_COMPRESSED_ALPHA:
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ case GL_COMPRESSED_LUMINANCE:
+ case GL_COMPRESSED_INTENSITY:
+ case GL_COMPRESSED_RGB:
+ case GL_COMPRESSED_RGBA:
+ case GL_COMPRESSED_SRGB:
+ case GL_COMPRESSED_SRGB_ALPHA:
+ case GL_COMPRESSED_SLUMINANCE:
+ case GL_COMPRESSED_SLUMINANCE_ALPHA:
+ case GL_RED_INTEGER:
+ case GL_GREEN_INTEGER:
+ case GL_BLUE_INTEGER:
+ case GL_ALPHA_INTEGER:
+ case GL_RGB_INTEGER:
+ case GL_RGBA_INTEGER:
+ case GL_BGR_INTEGER:
+ case GL_BGRA_INTEGER:
+ case GL_LUMINANCE_INTEGER_EXT:
+ case GL_LUMINANCE_ALPHA_INTEGER_EXT:
+ /* these unsized formats are illegal */
+ legalFormat = GL_FALSE;
+ break;
+ default:
+ legalFormat = _mesa_base_tex_format(ctx, internalformat) > 0;
+ }
+
+ if (!legalFormat) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexStorage%uD(internalformat = %s)", dims,
+ _mesa_lookup_enum_by_nr(internalformat));
+ return GL_TRUE;
+ }
/* size check */
if (width < 1 || height < 1 || depth < 1) {