/**
* This is called just prior to changing any texture object state which
- * will not effect texture completeness.
+ * will not affect texture completeness.
*/
static inline void
flush(struct gl_context *ctx)
/**
* This is called just prior to changing any texture object state which
- * can effect texture completeness (texture base level, max level).
+ * could affect texture completeness (texture base level, max level).
* Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
* state flag and then mark the texture object as 'incomplete' so that any
* per-texture derived state gets recomputed.
pname, params, true);
}
-void GLAPIENTRY
-_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
+/**
+ * This isn't exposed to the rest of the driver because it is a part of the
+ * OpenGL API that is rarely used.
+ */
+static void
+get_tex_parameterfv(struct gl_context *ctx,
+ struct gl_texture_object *obj,
+ GLenum pname, GLfloat *params, bool dsa)
{
- struct gl_texture_object *obj;
- GET_CURRENT_CONTEXT(ctx);
-
- obj = get_texobj_by_target(ctx, target, GL_TRUE);
- if (!obj)
- return;
-
_mesa_lock_context_textures(ctx);
switch (pname) {
case GL_TEXTURE_MAG_FILTER:
invalid_pname:
_mesa_unlock_context_textures(ctx);
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)", pname);
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTex%sParameterfv(pname=0x%x)",
+ dsa ? "ture" : "", pname);
}
-void GLAPIENTRY
-_mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
+static void
+get_tex_parameteriv(struct gl_context *ctx,
+ struct gl_texture_object *obj,
+ GLenum pname, GLint *params, bool dsa)
{
- struct gl_texture_object *obj;
- GET_CURRENT_CONTEXT(ctx);
-
- obj = get_texobj_by_target(ctx, target, GL_TRUE);
- if (!obj)
- return;
-
_mesa_lock_texture(ctx, obj);
switch (pname) {
case GL_TEXTURE_MAG_FILTER:
case GL_TEXTURE_MIN_LOD:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
goto invalid_pname;
-
- *params = (GLint) obj->Sampler.MinLod;
+ /* GL spec 'Data Conversions' section specifies that floating-point
+ * value in integer Get function is rounded to nearest integer
+ */
+ *params = IROUND(obj->Sampler.MinLod);
break;
case GL_TEXTURE_MAX_LOD:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
goto invalid_pname;
-
- *params = (GLint) obj->Sampler.MaxLod;
+ /* GL spec 'Data Conversions' section specifies that floating-point
+ * value in integer Get function is rounded to nearest integer
+ */
+ *params = IROUND(obj->Sampler.MaxLod);
break;
case GL_TEXTURE_BASE_LEVEL:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
if (!ctx->Extensions.EXT_texture_filter_anisotropic)
goto invalid_pname;
- *params = (GLint) obj->Sampler.MaxAnisotropy;
+ /* GL spec 'Data Conversions' section specifies that floating-point
+ * value in integer Get function is rounded to nearest integer
+ */
+ *params = IROUND(obj->Sampler.MaxAnisotropy);
break;
case GL_GENERATE_MIPMAP_SGIS:
if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
invalid_pname:
_mesa_unlock_texture(ctx, obj);
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)", pname);
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTex%sParameteriv(pname=0x%x)",
+ dsa ? "ture" : "", pname);
+}
+
+static void
+get_tex_parameterIiv(struct gl_context *ctx,
+ struct gl_texture_object *obj,
+ GLenum pname, GLint *params, bool dsa)
+{
+ switch (pname) {
+ case GL_TEXTURE_BORDER_COLOR:
+ COPY_4V(params, obj->Sampler.BorderColor.i);
+ break;
+ default:
+ get_tex_parameteriv(ctx, obj, pname, params, dsa);
+ }
+}
+
+static void
+get_tex_parameterIuiv(struct gl_context *ctx,
+ struct gl_texture_object *obj,
+ GLenum pname, GLuint *params, bool dsa)
+{
+ switch (pname) {
+ case GL_TEXTURE_BORDER_COLOR:
+ COPY_4V(params, obj->Sampler.BorderColor.i);
+ break;
+ default:
+ {
+ GLint ip[4];
+ get_tex_parameteriv(ctx, obj, pname, ip, dsa);
+ params[0] = ip[0];
+ if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT ||
+ pname == GL_TEXTURE_CROP_RECT_OES) {
+ params[1] = ip[1];
+ params[2] = ip[2];
+ params[3] = ip[3];
+ }
+ }
+ }
+}
+
+void GLAPIENTRY
+_mesa_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
+{
+ struct gl_texture_object *obj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ obj = get_texobj_by_target(ctx, target, GL_TRUE);
+ if (!obj)
+ return;
+
+ get_tex_parameterfv(ctx, obj, pname, params, false);
+}
+
+void GLAPIENTRY
+_mesa_GetTexParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+ struct gl_texture_object *obj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ obj = get_texobj_by_target(ctx, target, GL_TRUE);
+ if (!obj)
+ return;
+
+ get_tex_parameteriv(ctx, obj, pname, params, false);
}
/** New in GL 3.0 */
if (!texObj)
return;
- switch (pname) {
- case GL_TEXTURE_BORDER_COLOR:
- COPY_4V(params, texObj->Sampler.BorderColor.i);
- break;
- default:
- _mesa_GetTexParameteriv(target, pname, params);
- }
+ get_tex_parameterIiv(ctx, texObj, pname, params, false);
}
if (!texObj)
return;
- switch (pname) {
- case GL_TEXTURE_BORDER_COLOR:
- COPY_4V(params, texObj->Sampler.BorderColor.i);
- break;
- default:
- {
- GLint ip[4];
- _mesa_GetTexParameteriv(target, pname, ip);
- params[0] = ip[0];
- if (pname == GL_TEXTURE_SWIZZLE_RGBA_EXT ||
- pname == GL_TEXTURE_CROP_RECT_OES) {
- params[1] = ip[1];
- params[2] = ip[2];
- params[3] = ip[3];
- }
- }
+ get_tex_parameterIuiv(ctx, texObj, pname, params, false);
+}
+
+
+void GLAPIENTRY
+_mesa_GetTextureParameterfv(GLuint texture, GLenum pname, GLfloat *params)
+{
+ struct gl_texture_object *obj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ obj = get_texobj_by_name(ctx, texture, GL_TRUE);
+ if (!obj) {
+ /* User passed a non-generated name. */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameterfv(texture)");
+ return;
+ }
+
+ get_tex_parameterfv(ctx, obj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_GetTextureParameteriv(GLuint texture, GLenum pname, GLint *params)
+{
+ struct gl_texture_object *obj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ obj = get_texobj_by_name(ctx, texture, GL_TRUE);
+ if (!obj) {
+ /* User passed a non-generated name. */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameteriv(texture)");
+ return;
+ }
+
+ get_tex_parameteriv(ctx, obj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_GetTextureParameterIiv(GLuint texture, GLenum pname, GLint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
+ if (!texObj) {
+ /* User passed a non-generated name. */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameterIiv(texture)");
+ return;
}
+
+ get_tex_parameterIiv(ctx, texObj, pname, params, true);
+}
+
+
+void GLAPIENTRY
+_mesa_GetTextureParameterIuiv(GLuint texture, GLenum pname, GLuint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
+ if (!texObj) {
+ /* User passed a non-generated name. */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameterIuiv(texture)");
+ return;
+ }
+
+ get_tex_parameterIuiv(ctx, texObj, pname, params, true);
}