diff --git a/src/mesa/main/externalobjects.c b/src/mesa/main/externalobjects.c index 01c859f8301..972f1279e63 100644 --- a/src/mesa/main/externalobjects.c +++ b/src/mesa/main/externalobjects.c @@ -25,6 +25,7 @@ #include "mtypes.h" #include "bufferobj.h" #include "context.h" +#include "enums.h" #include "externalobjects.h" #include "teximage.h" #include "texobj.h" @@ -302,6 +303,21 @@ texstorage_memory(GLuint dims, GLenum target, GLsizei levels, return; } + if (!_mesa_is_legal_tex_storage_target(ctx, dims, target)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "%s(illegal target=%s)", + func, _mesa_enum_to_string(target)); + return; + } + + /* Check the format to make sure it is sized. */ + if (!_mesa_is_legal_tex_storage_format(ctx, internalFormat)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "%s(internalformat = %s)", func, + _mesa_enum_to_string(internalFormat)); + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) return; @@ -363,10 +379,25 @@ texturestorage_memory(GLuint dims, GLuint texture, GLsizei levels, return; } + /* Check the format to make sure it is sized. */ + if (!_mesa_is_legal_tex_storage_format(ctx, internalFormat)) { + _mesa_error(ctx, GL_INVALID_ENUM, + "%s(internalformat = %s)", func, + _mesa_enum_to_string(internalFormat)); + return; + } + texObj = _mesa_lookup_texture(ctx, texture); if (!texObj) return; + if (!_mesa_is_legal_tex_storage_target(ctx, dims, texObj->Target)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(illegal target=%s)", func, + _mesa_enum_to_string(texObj->Target)); + return; + } + memObj = lookup_memory_object_err(ctx, memory, func); if (!memObj) return; diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c index 932308c6471..77abc6c511f 100644 --- a/src/mesa/main/texstorage.c +++ b/src/mesa/main/texstorage.c @@ -48,11 +48,12 @@ * This is a bit different than legal_teximage_target() when it comes * to cube maps. */ -static bool -legal_texobj_target(const struct gl_context *ctx, GLuint dims, GLenum target) +bool +_mesa_is_legal_tex_storage_target(const struct gl_context *ctx, + GLuint dims, GLenum target) { if (dims < 1 || dims > 3) { - _mesa_problem(ctx, "invalid dims=%u in legal_texobj_target()", dims); + _mesa_problem(ctx, "invalid dims=%u in _mesa_is_legal_tex_storage_target()", dims); return false; } @@ -530,7 +531,7 @@ texstorage_error(GLuint dims, GLenum target, GLsizei levels, /* Check target. This is done here so that texture_storage * can receive unsized formats. */ - if (!legal_texobj_target(ctx, dims, target)) { + if (!_mesa_is_legal_tex_storage_target(ctx, dims, target)) { _mesa_error(ctx, GL_INVALID_ENUM, "%s(illegal target=%s)", caller, _mesa_enum_to_string(target)); @@ -605,7 +606,7 @@ texturestorage_error(GLuint dims, GLuint texture, GLsizei levels, /* Check target. This is done here so that texture_storage * can receive unsized formats. */ - if (!legal_texobj_target(ctx, dims, texObj->Target)) { + if (!_mesa_is_legal_tex_storage_target(ctx, dims, texObj->Target)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s(illegal target=%s)", caller, _mesa_enum_to_string(texObj->Target)); diff --git a/src/mesa/main/texstorage.h b/src/mesa/main/texstorage.h index f184dfd86eb..74abf1797f6 100644 --- a/src/mesa/main/texstorage.h +++ b/src/mesa/main/texstorage.h @@ -131,6 +131,10 @@ extern GLboolean _mesa_is_legal_tex_storage_format(const struct gl_context *ctx, GLenum internalformat); +extern bool +_mesa_is_legal_tex_storage_target(const struct gl_context *ctx, + GLuint dims, GLenum target); + extern GLboolean _mesa_AllocTextureStorage_sw(struct gl_context *ctx, struct gl_texture_object *texObj,