+
+void GLAPIENTRY
+_mesa_TextureParameterIiv(GLuint texture, GLenum pname, const GLint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
+ if (!texObj) {
+ /* User passed a non-generated name. */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterIiv(texture)");
+ return;
+ }
+
+ _mesa_texture_parameterIiv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_TextureParameterIuiv(GLuint texture, GLenum pname, const GLuint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
+ if (!texObj) {
+ /* User passed a non-generated name. */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterIuiv(texture)");
+ return;
+ }
+
+ _mesa_texture_parameterIuiv(ctx, texObj, pname, params, true);
+}
+
+static GLboolean
+legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target,
+ bool dsa)
+{
+ switch (target) {
+ case GL_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_3D:
+ return GL_TRUE;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ return ctx->Extensions.ARB_texture_cube_map;
+ case GL_TEXTURE_CUBE_MAP_ARRAY_ARB:
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB:
+ return ctx->Extensions.ARB_texture_cube_map_array;
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ return ctx->Extensions.NV_texture_rectangle;
+ case GL_TEXTURE_1D_ARRAY_EXT:
+ case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
+ case GL_TEXTURE_2D_ARRAY_EXT:
+ case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
+ return ctx->Extensions.EXT_texture_array;
+ case GL_TEXTURE_BUFFER:
+ /* GetTexLevelParameter accepts GL_TEXTURE_BUFFER in GL 3.1+ contexts,
+ * but not in earlier versions that expose ARB_texture_buffer_object.
+ *
+ * From the ARB_texture_buffer_object spec:
+ * "(7) Do buffer textures support texture parameters (TexParameter) or
+ * queries (GetTexParameter, GetTexLevelParameter, GetTexImage)?
+ *
+ * RESOLVED: No. [...] Note that the spec edits above don't add
+ * explicit error language for any of these cases. That is because
+ * each of the functions enumerate the set of valid <target>
+ * parameters. Not editing the spec to allow TEXTURE_BUFFER_ARB in
+ * these cases means that target is not legal, and an INVALID_ENUM
+ * error should be generated."
+ *
+ * From the OpenGL 3.1 spec:
+ * "target may also be TEXTURE_BUFFER, indicating the texture buffer."
+ */
+ return ctx->API == API_OPENGL_CORE && ctx->Version >= 31;
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
+ case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ return ctx->Extensions.ARB_texture_multisample;
+
+ /* This is a valid target for dsa, but the OpenGL 4.5 core spec
+ * (30.10.2014) Section 8.11 Texture Queries says:
+ * "For GetTextureLevelParameter* only, texture may also be a cube
+ * map texture object. In this case the query is always performed
+ * for face zero (the TEXTURE_CUBE_MAP_POSITIVE_X face), since there
+ * is no way to specify another face."
+ */
+ case GL_TEXTURE_CUBE_MAP:
+ return dsa;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+static void
+get_tex_level_parameter_image(struct gl_context *ctx,
+ const struct gl_texture_object *texObj,
+ GLenum target, GLint level,
+ GLenum pname, GLint *params,
+ bool dsa)
+{
+ const struct gl_texture_image *img = NULL;
+ struct gl_texture_image dummy_image;
+ mesa_format texFormat;
+ const char *suffix = dsa ? "ture" : "";
+
+ img = _mesa_select_tex_image(texObj, target, level);
+ if (!img || img->TexFormat == MESA_FORMAT_NONE) {
+ /* In case of undefined texture image return the default values.
+ *
+ * From OpenGL 4.0 spec, page 398:
+ * "The initial internal format of a texel array is RGBA
+ * instead of 1. TEXTURE_COMPONENTS is deprecated; always
+ * use TEXTURE_INTERNAL_FORMAT."
+ */
+ memset(&dummy_image, 0, sizeof(dummy_image));
+ dummy_image.TexFormat = MESA_FORMAT_NONE;
+ dummy_image.InternalFormat = GL_RGBA;
+ dummy_image._BaseFormat = GL_NONE;
+
+ img = &dummy_image;
+ }
+
+ texFormat = img->TexFormat;