Mesa (master): mesa/main: Add conversion from double to uint64/ int64 in GetUniform*i64v()
Iago Toral Quiroga
itoral at kemper.freedesktop.org
Thu Jun 1 07:02:24 UTC 2017
Module: Mesa
Branch: master
Commit: c33308248357c40896872336258a66190e3c7048
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c33308248357c40896872336258a66190e3c7048
Author: Iago Toral Quiroga <itoral at igalia.com>
Date: Thu May 18 11:43:55 2017 +0200
mesa/main: Add conversion from double to uint64/int64 in GetUniform*i64v()
v2:
- need unsigned rounding for double->uint64 conversion (Nicolai)
- use round() instead of IROUND() macros (Iago)
Reviewed-by: Matt Turner <mattst88 at gmail.com>
---
src/mesa/main/uniform_query.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index aca54163bf..b53f60bc45 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -580,6 +580,13 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
memcpy(&dst[didx].u, &tmp, sizeof(tmp));
break;
}
+ case GLSL_TYPE_DOUBLE: {
+ double d;
+ memcpy(&d, &src[sidx].f, sizeof(d));
+ int64_t tmp = (int64_t) round(d);
+ memcpy(&dst[didx].u, &tmp, sizeof(tmp));
+ break;
+ }
default:
assert(!"Should not get here.");
break;
@@ -618,6 +625,13 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
memcpy(&dst[didx].u, &tmp, sizeof(tmp));
break;
}
+ case GLSL_TYPE_DOUBLE: {
+ double d;
+ memcpy(&d, &src[sidx].f, sizeof(d));
+ uint64_t tmp = (d < 0.0) ? 0ull : (uint64_t) round(d);
+ memcpy(&dst[didx].u, &tmp, sizeof(tmp));
+ break;
+ }
default:
assert(!"Should not get here.");
break;
More information about the mesa-commit
mailing list