#include "main/teximage.h"
#include "main/texstate.h"
#include "program/prog_instruction.h"
+#include "util/u_math.h"
/**
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (texObj->Sampler.MinFilter == params[0])
return GL_FALSE;
case GL_TEXTURE_MAG_FILTER:
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (texObj->Sampler.MagFilter == params[0])
return GL_FALSE;
case GL_TEXTURE_WRAP_S:
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (texObj->Sampler.WrapS == params[0])
return GL_FALSE;
case GL_TEXTURE_WRAP_T:
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (texObj->Sampler.WrapT == params[0])
return GL_FALSE;
case GL_TEXTURE_WRAP_R:
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (texObj->Sampler.WrapR == params[0])
return GL_FALSE;
|| _mesa_is_gles3(ctx)) {
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (texObj->Sampler.CompareMode == params[0])
return GL_FALSE;
|| _mesa_is_gles3(ctx)) {
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (texObj->Sampler.CompareFunc == params[0])
return GL_FALSE;
GLenum decode = params[0];
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (decode == GL_DECODE_EXT || decode == GL_SKIP_DECODE_EXT) {
if (texObj->Sampler.sRGBDecode != decode) {
GLenum param = params[0];
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (param != GL_TRUE && param != GL_FALSE) {
goto invalid_param;
goto invalid_pname;
case GL_TEXTURE_TILING_EXT:
- if (ctx->Extensions.EXT_memory_object) {
- texObj->TextureTiling = params[0];
+ if (ctx->Extensions.EXT_memory_object && !texObj->Immutable) {
+ texObj->TextureTiling = params[0];
return GL_TRUE;
}
suffix, _mesa_enum_to_string(params[0]));
return GL_FALSE;
+invalid_dsa:
+ if (!dsa)
+ goto invalid_enum;
+
invalid_operation:
_mesa_error(ctx, GL_INVALID_OPERATION, "glTex%sParameter(pname=%s)",
suffix, _mesa_enum_to_string(pname));
goto invalid_pname;
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (texObj->Sampler.MinLod == params[0])
return GL_FALSE;
goto invalid_pname;
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (texObj->Sampler.MaxLod == params[0])
return GL_FALSE;
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
if (ctx->Extensions.EXT_texture_filter_anisotropic) {
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (texObj->Sampler.MaxAnisotropy == params[0])
return GL_FALSE;
goto invalid_pname;
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target))
- goto invalid_enum;
+ goto invalid_dsa;
if (texObj->Sampler.LodBias != params[0]) {
flush(ctx);
suffix, _mesa_enum_to_string(pname));
return GL_FALSE;
+invalid_dsa:
+ if (!dsa)
+ goto invalid_enum;
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glTex%sParameter(pname=%s)",
+ suffix, _mesa_enum_to_string(pname));
+ return GL_FALSE;
invalid_enum:
_mesa_error(ctx, GL_INVALID_ENUM, "glTex%sParameter(pname=%s)",
suffix, _mesa_enum_to_string(pname));
case GL_TEXTURE_PRIORITY:
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
case GL_TEXTURE_LOD_BIAS:
- case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
{
GLfloat fparam[4];
fparam[0] = (GLfloat) param;
case GL_TEXTURE_PRIORITY:
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
case GL_TEXTURE_LOD_BIAS:
- case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
{
/* convert int param to float */
GLfloat fparams[4];
}
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glTextureParameterIiv(texture)");
+ _mesa_error(ctx, dsa ? GL_INVALID_OPERATION : GL_INVALID_ENUM, "glTextureParameterIiv(texture)");
return;
}
FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
}
if (!_mesa_target_allows_setting_sampler_parameters(texObj->Target)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glTextureParameterIuiv(texture)");
+ _mesa_error(ctx, dsa ? GL_INVALID_OPERATION : GL_INVALID_ENUM, "glTextureParameterIuiv(texture)");
return;
}
FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
_mesa_texture_parameterIiv(ctx, texObj, pname, params, true);
}
+void GLAPIENTRY
+_mesa_TextureParameterIivEXT(GLuint texture, GLenum target, GLenum pname,
+ const GLint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+ "glTextureParameterIivEXT");
+ if (!texObj)
+ return;
+
+ _mesa_texture_parameterIiv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_MultiTexParameterIivEXT(GLenum texunit, GLenum target, GLenum pname,
+ const GLint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ texunit - GL_TEXTURE0,
+ true,
+ "glMultiTexParameterIivEXT");
+ if (!texObj)
+ return;
+
+ _mesa_texture_parameterIiv(ctx, texObj, pname, params, true);
+}
+
void GLAPIENTRY
_mesa_TextureParameterIuiv(GLuint texture, GLenum pname, const GLuint *params)
{
_mesa_texture_parameterIuiv(ctx, texObj, pname, params, true);
}
+void GLAPIENTRY
+_mesa_TextureParameterIuivEXT(GLuint texture, GLenum target, GLenum pname,
+ const GLuint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+ "glTextureParameterIuivEXT");
+ if (!texObj)
+ return;
+
+ _mesa_texture_parameterIuiv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_MultiTexParameterIuivEXT(GLenum texunit, GLenum target, GLenum pname,
+ const GLuint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ texunit - GL_TEXTURE0,
+ true,
+ "glMultiTexParameterIuivEXT");
+ if (!texObj)
+ return;
+
+ _mesa_texture_parameterIuiv(ctx, texObj, pname, params, true);
+}
+
GLboolean
_mesa_legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target,
bool dsa)
}
if (*params == 0 && pname == GL_TEXTURE_INTENSITY_SIZE) {
/* Gallium may store intensity as LA */
- *params = _mesa_get_format_bits(texFormat,
+ *params = _mesa_get_format_bits(texFormat,
GL_TEXTURE_ALPHA_SIZE);
}
}
*params = (GLfloat) iparam;
}
+void GLAPIENTRY
+_mesa_GetMultiTexLevelParameterfvEXT(GLenum texunit, GLenum target, GLint level,
+ GLenum pname, GLfloat *params)
+{
+ struct gl_texture_object *texObj;
+ GLint iparam;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ texunit - GL_TEXTURE0,
+ true,
+ "glGetMultiTexLevelParameterfvEXT");
+ if (!texObj)
+ return;
+
+ if (!valid_tex_level_parameteriv_target(ctx, texObj->Target, true))
+ return;
+
+ get_tex_level_parameteriv(ctx, texObj, texObj->Target, level,
+ pname, &iparam, true);
+
+ *params = (GLfloat) iparam;
+}
+
void GLAPIENTRY
_mesa_GetTextureLevelParameteriv(GLuint texture, GLint level,
GLenum pname, GLint *params)
pname, params, true);
}
+void GLAPIENTRY
+_mesa_GetMultiTexLevelParameterivEXT(GLenum texunit, GLenum target, GLint level,
+ GLenum pname, GLint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ texunit - GL_TEXTURE0,
+ true,
+ "glGetMultiTexLevelParameterivEXT");
+ if (!texObj)
+ return;
+
+ if (!valid_tex_level_parameteriv_target(ctx, texObj->Target, true))
+ 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
!ctx->Extensions.ARB_texture_border_clamp)
goto invalid_pname;
- if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
- _mesa_update_state_locked(ctx);
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
params[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F);
params[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F);
goto invalid_pname;
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
+ *
+ * Section 2.2.2 (Data Conversions For State Query Commands) of the
+ * OpenGL 4.5 spec says:
+ *
+ * Following these steps, if a value is so large in magnitude that
+ * it cannot be represented by the returned data type, then the
+ * nearest value representable using that type is returned.
*/
- *params = IROUND(obj->Sampler.MinLod);
+ *params = CLAMP(lroundf(obj->Sampler.MinLod), INT_MIN, INT_MAX);
break;
case GL_TEXTURE_MAX_LOD:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
goto invalid_pname;
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
+ *
+ * Section 2.2.2 (Data Conversions For State Query Commands) of the
+ * OpenGL 4.5 spec says:
+ *
+ * Following these steps, if a value is so large in magnitude that
+ * it cannot be represented by the returned data type, then the
+ * nearest value representable using that type is returned.
*/
- *params = IROUND(obj->Sampler.MaxLod);
+ *params = CLAMP(lroundf(obj->Sampler.MaxLod), INT_MIN, INT_MAX);
break;
case GL_TEXTURE_BASE_LEVEL:
if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
goto invalid_pname;
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
+ *
+ * Section 2.2.2 (Data Conversions For State Query Commands) of the
+ * OpenGL 4.5 spec says:
+ *
+ * Following these steps, if a value is so large in magnitude that
+ * it cannot be represented by the returned data type, then the
+ * nearest value representable using that type is returned.
*/
- *params = IROUND(obj->Sampler.MaxAnisotropy);
+ *params = CLAMP(lroundf(obj->Sampler.MaxAnisotropy), INT_MIN, INT_MAX);
break;
case GL_GENERATE_MIPMAP_SGIS:
if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
/* GL spec 'Data Conversions' section specifies that floating-point
* value in integer Get function is rounded to nearest integer
+ *
+ * Section 2.2.2 (Data Conversions For State Query Commands) of the
+ * OpenGL 4.5 spec says:
+ *
+ * Following these steps, if a value is so large in magnitude that
+ * it cannot be represented by the returned data type, then the
+ * nearest value representable using that type is returned.
*/
- *params = IROUND(obj->Sampler.LodBias);
+ *params = CLAMP(lroundf(obj->Sampler.LodBias), INT_MIN, INT_MAX);
break;
case GL_TEXTURE_CROP_RECT_OES:
if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture)
get_tex_parameterfv(ctx, texObj, pname, params, true);
}
+void GLAPIENTRY
+_mesa_GetMultiTexParameterfvEXT(GLenum texunit, GLenum target, GLenum pname, GLfloat *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ texunit - GL_TEXTURE0,
+ false,
+ "glGetMultiTexParameterfvEXT");
+ if (!texObj)
+ return;
+
+ if (!is_texparameteri_target_valid(texObj->Target)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMultiTexParameterfvEXT");
+ return;
+ }
+ get_tex_parameterfv(ctx, texObj, pname, params, true);
+}
+
void GLAPIENTRY
_mesa_GetTextureParameterfv(GLuint texture, GLenum pname, GLfloat *params)
{
return;
}
get_tex_parameteriv(ctx, texObj, pname, params, true);
- }
+}
+
+void GLAPIENTRY
+_mesa_GetMultiTexParameterivEXT(GLenum texunit, GLenum target, GLenum pname, GLint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ texunit - GL_TEXTURE0,
+ false,
+ "glGetMultiTexParameterivEXT");
+ if (!texObj)
+ return;
+
+ if (!is_texparameteri_target_valid(texObj->Target)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMultiTexParameterivEXT");
+ return;
+ }
+ get_tex_parameteriv(ctx, texObj, pname, params, true);
+}
void GLAPIENTRY
_mesa_GetTextureParameteriv(GLuint texture, GLenum pname, GLint *params)
get_tex_parameterIiv(ctx, texObj, pname, params, true);
}
+void GLAPIENTRY
+_mesa_GetTextureParameterIivEXT(GLuint texture, GLenum target, GLenum pname, GLint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+ "glGetTextureParameterIivEXT");
+ if (!texObj)
+ return;
+
+
+ get_tex_parameterIiv(ctx, texObj, pname, params, true);
+}
+
+void GLAPIENTRY
+_mesa_GetMultiTexParameterIivEXT(GLenum texunit, GLenum target, GLenum pname,
+ GLint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ texunit - GL_TEXTURE0,
+ true,
+ "glGetMultiTexParameterIiv");
+ if (!texObj)
+ return;
+
+ get_tex_parameterIiv(ctx, texObj, pname, params, true);
+}
void GLAPIENTRY
_mesa_GetTextureParameterIuiv(GLuint texture, GLenum pname, GLuint *params)
get_tex_parameterIiv(ctx, texObj, pname, (GLint *) params, true);
}
+
+void GLAPIENTRY
+_mesa_GetTextureParameterIuivEXT(GLuint texture, GLenum target, GLenum pname,
+ GLuint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_lookup_or_create_texture(ctx, target, texture, false, true,
+ "glGetTextureParameterIuvEXT");
+ if (!texObj)
+ return;
+
+ get_tex_parameterIiv(ctx, texObj, pname, (GLint *) params, true);
+}
+
+void GLAPIENTRY
+_mesa_GetMultiTexParameterIuivEXT(GLenum texunit, GLenum target, GLenum pname,
+ GLuint *params)
+{
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ texunit - GL_TEXTURE0,
+ true,
+ "glGetMultiTexParameterIuiv");
+ if (!texObj)
+ return;
+
+ get_tex_parameterIiv(ctx, texObj, pname, (GLint *) params, true);
+}