/**
* 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.
}
-void GLAPIENTRY
-_mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
+void
+_mesa_texture_parameteriv(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLenum pname, const GLint *params, bool dsa)
{
GLboolean need_update;
- struct gl_texture_object *texObj;
- GET_CURRENT_CONTEXT(ctx);
-
- texObj = get_texobj_by_target(ctx, target, GL_FALSE);
- if (!texObj)
- return;
switch (pname) {
case GL_TEXTURE_BORDER_COLOR:
fparams[1] = INT_TO_FLOAT(params[1]);
fparams[2] = INT_TO_FLOAT(params[2]);
fparams[3] = INT_TO_FLOAT(params[3]);
- need_update = set_tex_parameterf(ctx, texObj, pname, fparams, false);
+ need_update = set_tex_parameterf(ctx, texObj, pname, fparams, dsa);
}
break;
case GL_TEXTURE_MIN_LOD:
GLfloat fparams[4];
fparams[0] = (GLfloat) params[0];
fparams[1] = fparams[2] = fparams[3] = 0.0F;
- need_update = set_tex_parameterf(ctx, texObj, pname, fparams, false);
+ need_update = set_tex_parameterf(ctx, texObj, pname, fparams, dsa);
}
break;
default:
/* this will generate an error if pname is illegal */
- need_update = set_tex_parameteri(ctx, texObj, pname, params, false);
+ need_update = set_tex_parameteri(ctx, texObj, pname, params, dsa);
}
if (ctx->Driver.TexParameter && need_update) {
}
}
+void
+_mesa_texture_parameterIiv(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLenum pname, const GLint *params, bool dsa)
+{
+ switch (pname) {
+ case GL_TEXTURE_BORDER_COLOR:
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ /* set the integer-valued border color */
+ COPY_4V(texObj->Sampler.BorderColor.i, params);
+ break;
+ default:
+ _mesa_texture_parameteriv(ctx, texObj, pname, params, dsa);
+ break;
+ }
+ /* XXX no driver hook for TexParameterIiv() yet */
+}
+
+void
+_mesa_texture_parameterIuiv(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLenum pname, const GLuint *params, bool dsa)
+{
+ switch (pname) {
+ case GL_TEXTURE_BORDER_COLOR:
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ /* set the unsigned integer-valued border color */
+ COPY_4V(texObj->Sampler.BorderColor.ui, params);
+ break;
+ default:
+ _mesa_texture_parameteriv(ctx, texObj, pname, (const GLint *) params,
+ dsa);
+ break;
+ }
+ /* XXX no driver hook for TexParameterIuiv() yet */
+}
+
void GLAPIENTRY
_mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
{
_mesa_texture_parameteri(ctx, texObj, pname, param, false);
}
+void GLAPIENTRY
+_mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+ if (!texObj)
+ return;
+
+ _mesa_texture_parameteriv(ctx, texObj, pname, params, false);
+}
+
/**
* Set tex parameter to integer value(s). Primarily intended to set
* integer-valued texture border color (for integer-valued textures).
if (!texObj)
return;
- switch (pname) {
- case GL_TEXTURE_BORDER_COLOR:
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- /* set the integer-valued border color */
- COPY_4V(texObj->Sampler.BorderColor.i, params);
- break;
- default:
- _mesa_TexParameteriv(target, pname, params);
- break;
- }
- /* XXX no driver hook for TexParameterIiv() yet */
+ _mesa_texture_parameterIiv(ctx, texObj, pname, params, false);
}
-
/**
* Set tex parameter to unsigned integer value(s). Primarily intended to set
* uint-valued texture border color (for integer-valued textures).
if (!texObj)
return;
- switch (pname) {
- case GL_TEXTURE_BORDER_COLOR:
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- /* set the unsigned integer-valued border color */
- COPY_4V(texObj->Sampler.BorderColor.ui, params);
- break;
- default:
- _mesa_TexParameteriv(target, pname, (const GLint *) params);
- break;
- }
- /* XXX no driver hook for TexParameterIuiv() yet */
+ _mesa_texture_parameterIuiv(ctx, texObj, pname, params, false);
}
_mesa_texture_parameteri(ctx, texObj, pname, param, true);
}
+void GLAPIENTRY
+_mesa_TextureParameteriv(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, "glTextureParameteriv(texture)");
+ return;
+ }
+
+ _mesa_texture_parameteriv(ctx, texObj, pname, params, true);
+}
+
+
+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)
+legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target,
+ bool dsa)
{
switch (target) {
case GL_TEXTURE_1D:
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;
}
get_tex_level_parameter_image(struct gl_context *ctx,
const struct gl_texture_object *texObj,
GLenum target, GLint level,
- GLenum pname, GLint *params)
+ 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) {
!_mesa_is_proxy_texture(target)) {
*params = _mesa_format_image_size(texFormat, img->Width,
img->Height, img->Depth);
- }
- else {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTexLevelParameter[if]v(pname)");
- }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
+ _mesa_lookup_enum_by_nr(pname));
+ }
break;
case GL_TEXTURE_COMPRESSED:
*params = (GLint) _mesa_is_format_compressed(texFormat);
invalid_pname:
_mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname=%s)",
+ "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
_mesa_lookup_enum_by_nr(pname));
}
static void
get_tex_level_parameter_buffer(struct gl_context *ctx,
const struct gl_texture_object *texObj,
- GLenum pname, GLint *params)
+ GLenum pname, GLint *params, bool dsa)
{
const struct gl_buffer_object *bo = texObj->BufferObject;
mesa_format texFormat = texObj->_BufferObjectFormat;
GLenum internalFormat = texObj->BufferObjectFormat;
GLenum baseFormat = _mesa_get_format_base_format(texFormat);
+ const char *suffix = dsa ? "ture" : "";
if (!bo) {
/* undefined texture buffer object */
case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
/* Always illegal for GL_TEXTURE_BUFFER */
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTexLevelParameter[if]v(pname)");
+ "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
+ _mesa_lookup_enum_by_nr(pname));
break;
/* GL_ARB_texture_float */
invalid_pname:
_mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname=%s)",
+ "glGetTex%sLevelParameter[if]v(pname=%s)", suffix,
_mesa_lookup_enum_by_nr(pname));
}
-void GLAPIENTRY
-_mesa_GetTexLevelParameterfv( GLenum target, GLint level,
- GLenum pname, GLfloat *params )
-{
- GLint iparam;
- _mesa_GetTexLevelParameteriv( target, level, pname, &iparam );
- *params = (GLfloat) iparam;
-}
-
-
-void GLAPIENTRY
-_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
- GLenum pname, GLint *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_level_parameteriv(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLenum target, GLint level,
+ GLenum pname, GLint *params,
+ bool dsa)
{
- struct gl_texture_object *texObj;
GLint maxLevels;
- GET_CURRENT_CONTEXT(ctx);
+ const char *suffix = dsa ? "ture" : "";
+ /* Check for errors */
if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetTexLevelParameteriv(current unit)");
+ "glGetTex%sLevelParameter[if]v("
+ "current unit >= max combined texture units)", suffix);
return;
}
- if (!legal_get_tex_level_parameter_target(ctx, target)) {
+ if (!legal_get_tex_level_parameter_target(ctx, target, dsa)) {
_mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(target=0x%x)", target);
+ "glGetTex%sLevelParameter[if]v(target=%s)", suffix,
+ _mesa_lookup_enum_by_nr(target));
return;
}
assert(maxLevels != 0);
if (level < 0 || level >= maxLevels) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" );
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetTex%sLevelParameter[if]v(level out of range)", suffix);
return;
}
+ /* Get the level parameter */
+ if (target == GL_TEXTURE_BUFFER) {
+ get_tex_level_parameter_buffer(ctx, texObj, pname, params, dsa);
+ }
+ else {
+ get_tex_level_parameter_image(ctx, texObj, target,
+ level, pname, params, dsa);
+ }
+}
+
+void GLAPIENTRY
+_mesa_GetTexLevelParameterfv( GLenum target, GLint level,
+ GLenum pname, GLfloat *params )
+{
+ struct gl_texture_object *texObj;
+ GLint iparam;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ if (!texObj)
+ return;
+
+ get_tex_level_parameteriv(ctx, texObj, target, level,
+ pname, &iparam, false);
+
+ *params = (GLfloat) iparam;
+}
+
+void GLAPIENTRY
+_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
+ GLenum pname, GLint *params )
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
texObj = _mesa_get_current_tex_object(ctx, target);
+ if (!texObj)
+ return;
- if (target == GL_TEXTURE_BUFFER)
- get_tex_level_parameter_buffer(ctx, texObj, pname, params);
- else
- get_tex_level_parameter_image(ctx, texObj, target, level, pname, params);
+ get_tex_level_parameteriv(ctx, texObj, target, level,
+ pname, params, false);
}
+void GLAPIENTRY
+_mesa_GetTextureLevelParameterfv(GLuint texture, GLint level,
+ GLenum pname, GLfloat *params)
+{
+ struct gl_texture_object *texObj;
+ GLint iparam;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_lookup_texture_err(ctx, texture,
+ "glGetTextureLevelParameterfv");
+ if (!texObj)
+ return;
+
+ get_tex_level_parameteriv(ctx, texObj, texObj->Target, level,
+ pname, &iparam, true);
+
+ *params = (GLfloat) iparam;
+}
void GLAPIENTRY
-_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
+_mesa_GetTextureLevelParameteriv(GLuint texture, GLint level,
+ GLenum pname, GLint *params)
{
- struct gl_texture_object *obj;
+ struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- obj = get_texobj_by_target(ctx, target, GL_TRUE);
- if (!obj)
+ texObj = _mesa_lookup_texture_err(ctx, texture,
+ "glGetTextureLevelParameteriv");
+ if (!texObj)
return;
+ get_tex_level_parameteriv(ctx, texObj, texObj->Target, level,
+ pname, params, true);
+}
+
+/**
+ * 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)
+{
_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);
}