+/**
+ * Helper used by _mesa_TexStorage1/2/3D().
+ */
+static void
+texstorage(GLuint dims, GLenum target, GLsizei levels, GLenum internalformat,
+ GLsizei width, GLsizei height, GLsizei depth)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* Check target. This is done here so that _mesa_texture_storage
+ * can receive unsized formats.
+ */
+ if (!legal_texobj_target(ctx, dims, target)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexStorage%uD(illegal target=%s)",
+ dims, _mesa_enum_to_string(target));
+ return;
+ }
+
+ if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glTexStorage%uD %s %d %s %d %d %d\n",
+ dims,
+ _mesa_enum_to_string(target), levels,
+ _mesa_enum_to_string(internalformat),
+ width, height, depth);
+
+ /* Check the format to make sure it is sized. */
+ if (!_mesa_is_legal_tex_storage_format(ctx, internalformat)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexStorage%uD(internalformat = %s)", dims,
+ _mesa_enum_to_string(internalformat));
+ return;
+ }
+
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ if (!texObj)
+ return;
+
+ _mesa_texture_storage(ctx, dims, texObj, target, levels,
+ internalformat, width, height, depth, false);
+}
+
+
+/**
+ * Helper used by _mesa_TextureStorage1/2/3D().
+ */
+static void
+texturestorage(GLuint dims, GLuint texture, GLsizei levels,
+ GLenum internalformat, GLsizei width, GLsizei height,
+ GLsizei depth)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glTextureStorage%uD %d %d %s %d %d %d\n",
+ dims, texture, levels,
+ _mesa_enum_to_string(internalformat),
+ width, height, depth);
+
+ /* Check the format to make sure it is sized. */
+ if (!_mesa_is_legal_tex_storage_format(ctx, internalformat)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTextureStorage%uD(internalformat = %s)", dims,
+ _mesa_enum_to_string(internalformat));
+ return;
+ }
+
+ /* Get the texture object by Name. */
+ texObj = _mesa_lookup_texture(ctx, texture);
+ if (!texObj) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureStorage%uD(texture = %d)", dims, texture);
+ return;
+ }
+
+ /* Check target. This is done here so that _mesa_texture_storage
+ * can receive unsized formats.
+ */
+ if (!legal_texobj_target(ctx, dims, texObj->Target)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTextureStorage%uD(illegal target=%s)",
+ dims, _mesa_enum_to_string(texObj->Target));
+ return;
+ }
+
+ _mesa_texture_storage(ctx, dims, texObj, texObj->Target,
+ levels, internalformat, width, height, depth, true);
+}
+
+