For the case where we convert a double to an int, we should
round the same as we do for floats.
This fixes GL41-CTS.gpu_shader_fp64.state_query
v2: add IROUNDD (Ilia)
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Dave Airlie <airlied@redhat.com>
return (int) ((f >= 0.0F) ? (f + 0.5F) : (f - 0.5F));
}
+/**
+ * Convert double to int by rounding to nearest integer, away from zero.
+ */
+static inline int IROUNDD(double d)
+{
+ return (int) ((d >= 0.0) ? (d + 0.5) : (d - 0.5));
+}
/**
* Convert float to int64 by rounding to nearest integer.
dst[didx].i = src[sidx].i ? 1 : 0;
break;
case GLSL_TYPE_DOUBLE:
- dst[didx].i = *(double *)&src[sidx].f;
+ dst[didx].i = IROUNDD(*(double *)&src[sidx].f);
break;
default:
assert(!"Should not get here.");