diff options
author | Samuel Iglesias Gonsalvez <siglesias@igalia.com> | 2014-12-11 23:34:14 +0100 |
---|---|---|
committer | Iago Toral Quiroga <itoral@igalia.com> | 2015-01-13 12:19:32 +0100 |
commit | d8d59202af1d409ad2e10c2893612ff6fa05d3a2 (patch) | |
tree | b5e6f4795381c74b63da7625ce72a34ee877b267 | |
parent | 8e49a3e028b9526d2ab7662a9f6683a72b6b6787 (diff) | |
download | external_mesa3d-d8d59202af1d409ad2e10c2893612ff6fa05d3a2.zip external_mesa3d-d8d59202af1d409ad2e10c2893612ff6fa05d3a2.tar.gz external_mesa3d-d8d59202af1d409ad2e10c2893612ff6fa05d3a2.tar.bz2 |
main: round floating-point value to nearest integer in glGetTexParameteriv()
Previously, a cast was done to convert from float to int but there
were rounding errors.
The spec specificies in Data Conversion chapter that Floating-point values are
rounded to the nearest integer.
This patch fixes the following 8 dEQP tests:
dEQP-GLES3.functional.state_query.texture.texture_2d_texture_min_lod_gettexparameteri
dEQP-GLES3.functional.state_query.texture.texture_2d_texture_max_lod_gettexparameteri
dEQP-GLES3.functional.state_query.texture.texture_3d_texture_min_lod_gettexparameteri
dEQP-GLES3.functional.state_query.texture.texture_3d_texture_max_lod_gettexparameteri
dEQP-GLES3.functional.state_query.texture.texture_2d_array_texture_min_lod_gettexparameteri
dEQP-GLES3.functional.state_query.texture.texture_2d_array_texture_max_lod_gettexparameteri
dEQP-GLES3.functional.state_query.texture.texture_cube_map_texture_min_lod_gettexparameteri
dEQP-GLES3.functional.state_query.texture.texture_cube_map_texture_max_lod_gettexparameteri
Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
-rw-r--r-- | src/mesa/main/texparam.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 772e699..c4a5841 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -1957,14 +1957,18 @@ get_tex_parameteriv(struct gl_context *ctx, 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)) @@ -1978,7 +1982,10 @@ get_tex_parameteriv(struct gl_context *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) |