main: round floating-point value to nearest integer in glGetSamplerParameteriv()
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 2 dEQP tests: dEQP-GLES3.functional.state_query.sampler.sampler_texture_min_lod_getsamplerparameteri dEQP-GLES3.functional.state_query.sampler.sampler_texture_max_lod_getsamplerparameteri Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
d8d59202af
commit
719e3f016e
|
@ -1271,13 +1271,22 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
|
||||||
*params = sampObj->MagFilter;
|
*params = sampObj->MagFilter;
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_MIN_LOD:
|
case GL_TEXTURE_MIN_LOD:
|
||||||
*params = (GLint) sampObj->MinLod;
|
/* GL spec 'Data Conversions' section specifies that floating-point
|
||||||
|
* value in integer Get function is rounded to nearest integer
|
||||||
|
*/
|
||||||
|
*params = IROUND(sampObj->MinLod);
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_MAX_LOD:
|
case GL_TEXTURE_MAX_LOD:
|
||||||
*params = (GLint) sampObj->MaxLod;
|
/* GL spec 'Data Conversions' section specifies that floating-point
|
||||||
|
* value in integer Get function is rounded to nearest integer
|
||||||
|
*/
|
||||||
|
*params = IROUND(sampObj->MaxLod);
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_LOD_BIAS:
|
case GL_TEXTURE_LOD_BIAS:
|
||||||
*params = (GLint) sampObj->LodBias;
|
/* GL spec 'Data Conversions' section specifies that floating-point
|
||||||
|
* value in integer Get function is rounded to nearest integer
|
||||||
|
*/
|
||||||
|
*params = IROUND(sampObj->LodBias);
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_COMPARE_MODE:
|
case GL_TEXTURE_COMPARE_MODE:
|
||||||
if (!ctx->Extensions.ARB_shadow)
|
if (!ctx->Extensions.ARB_shadow)
|
||||||
|
@ -1290,7 +1299,10 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
|
||||||
*params = sampObj->CompareFunc;
|
*params = sampObj->CompareFunc;
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
||||||
*params = (GLint) sampObj->MaxAnisotropy;
|
/* GL spec 'Data Conversions' section specifies that floating-point
|
||||||
|
* value in integer Get function is rounded to nearest integer
|
||||||
|
*/
|
||||||
|
*params = IROUND(sampObj->MaxAnisotropy);
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_BORDER_COLOR:
|
case GL_TEXTURE_BORDER_COLOR:
|
||||||
params[0] = FLOAT_TO_INT(sampObj->BorderColor.f[0]);
|
params[0] = FLOAT_TO_INT(sampObj->BorderColor.f[0]);
|
||||||
|
|
Loading…
Reference in New Issue