From: Anuj Phogat Date: Mon, 7 Jan 2013 05:00:11 +0000 (+0530) Subject: mesa: Round float param in glTexparameterf() to nearest integer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d0ce8d6ceb5f597e9cb132e6395bce8fbd51b58e;p=mesa.git mesa: Round float param in glTexparameterf() to nearest integer OpenGL 4.2 specification suggests rounding the float data to nearest integer when the type of internal state is integer. Out of range floats should be clamped to {INT_MIN, INT_MAX}. This is not specified anywhere in gl/gles spec but below test expects this behavior. This patch makes gles3 conformance sgis_texture_lod_basic_getter.test pass. A GL spec bug will be raised to include clamping of out of range floats. V2: Round float to nearest integer for all cases where _mesa_Texparameterf() converts float param to int. Use the same block of float to int conversion code for GL_TEXTURE_SWIZZLE_{R,G,B,A}_EXT cases as well. Signed-off-by: Anuj Phogat Reviewed-by: Ian Romanick --- diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index ca5a21f788b..4d32fd6dd7a 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -662,21 +662,16 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param) case GL_DEPTH_TEXTURE_MODE_ARB: case GL_TEXTURE_SRGB_DECODE_EXT: case GL_TEXTURE_CUBE_MAP_SEAMLESS: - { - /* convert float param to int */ - GLint p[4]; - p[0] = (GLint) param; - p[1] = p[2] = p[3] = 0; - need_update = set_tex_parameteri(ctx, texObj, pname, p); - } - break; case GL_TEXTURE_SWIZZLE_R_EXT: case GL_TEXTURE_SWIZZLE_G_EXT: case GL_TEXTURE_SWIZZLE_B_EXT: case GL_TEXTURE_SWIZZLE_A_EXT: { GLint p[4]; - p[0] = (GLint) param; + p[0] = (param > 0) ? + ((param > INT_MAX) ? INT_MAX : (GLint) (param + 0.5)) : + ((param < INT_MIN) ? INT_MIN : (GLint) (param - 0.5)); + p[1] = p[2] = p[3] = 0; need_update = set_tex_parameteri(ctx, texObj, pname, p); }