Module: Mesa Branch: master Commit: a9eace326ece7496109a8e2a55aae8fc802e89d8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a9eace326ece7496109a8e2a55aae8fc802e89d8
Author: Dave Airlie <[email protected]> Date: Thu Oct 15 05:07:40 2015 +0100 mesa/uniform_query: add IROUNDD and use for doubles->ints (v2) 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 <[email protected]> Signed-off-by: Dave Airlie <[email protected]> --- src/mesa/main/imports.h | 7 +++++++ src/mesa/main/uniform_query.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 042147f..ad7af5c 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -151,6 +151,13 @@ static inline int IROUND(float f) 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. diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index b2ac65f..766a465 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -437,7 +437,7 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location, 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."); _______________________________________________ mesa-commit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-commit
