[Mesa-dev] [PATCH 08/16] main: round floating-point value to nearest integer in glGetTexParameteriv()

Ian Romanick idr at freedesktop.org
Thu Dec 11 18:15:46 PST 2014


This patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

On 12/11/2014 02:34 PM, Eduardo Lima Mitev wrote:
> From: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
> 
> 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 at igalia.com>
> ---
>  src/mesa/main/texparam.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
> index e40fb24..2d5a9b7 100644
> --- a/src/mesa/main/texparam.c
> +++ b/src/mesa/main/texparam.c
> @@ -1658,14 +1658,18 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
>        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))
> @@ -1679,7 +1683,10 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
>        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)
> 



More information about the mesa-dev mailing list