diff options
author | Iago Toral Quiroga <[email protected]> | 2017-05-18 11:43:54 +0200 |
---|---|---|
committer | Iago Toral Quiroga <[email protected]> | 2017-06-01 08:44:34 +0200 |
commit | cc972c2845e7c8554918e3aaaab95c1581ff5599 (patch) | |
tree | 6aa1e6802abaa422a4e20a7d35a877e9b9e3d4c6 /src/mesa/main | |
parent | 83e74d7dc14ee0f31652cd2a6c0bb66380458f2b (diff) |
mesa/main: Clamp GetUniformui64v values to be >= 0
Like we do for the 32-bit case.
v2:
- need unsigned rounding for float->uint64 conversion (Nicolai)
- use roundf() instead of IROUND() macros (Iago)
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/uniform_query.cpp | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 314f7d8a1b0..aca54163bff 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -550,7 +550,6 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location, break; case GLSL_TYPE_INT64: - case GLSL_TYPE_UINT64: switch (uni->type->base_type) { case GLSL_TYPE_UINT: { uint64_t tmp = src[sidx].u; @@ -569,6 +568,13 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location, memcpy(&dst[didx].u, &tmp, sizeof(tmp)); break; } + case GLSL_TYPE_UINT64: { + uint64_t u64; + memcpy(&u64, &src[sidx].u, sizeof(u64)); + int64_t tmp = MIN2(u64, INT_MAX); + memcpy(&dst[didx].u, &tmp, sizeof(tmp)); + break; + } case GLSL_TYPE_FLOAT: { int64_t tmp = src[sidx].f; memcpy(&dst[didx].u, &tmp, sizeof(tmp)); @@ -580,6 +586,44 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location, } break; + case GLSL_TYPE_UINT64: + switch (uni->type->base_type) { + case GLSL_TYPE_UINT: { + uint64_t tmp = src[sidx].u; + memcpy(&dst[didx].u, &tmp, sizeof(tmp)); + break; + } + case GLSL_TYPE_INT: + case GLSL_TYPE_SAMPLER: + case GLSL_TYPE_IMAGE: { + int64_t tmp = MAX2(src[sidx].i, 0); + memcpy(&dst[didx].u, &tmp, sizeof(tmp)); + break; + } + case GLSL_TYPE_BOOL: { + int64_t tmp = src[sidx].i ? 1.0f : 0.0f; + memcpy(&dst[didx].u, &tmp, sizeof(tmp)); + break; + } + case GLSL_TYPE_INT64: { + uint64_t i64; + memcpy(&i64, &src[sidx].i, sizeof(i64)); + uint64_t tmp = MAX2(i64, 0); + memcpy(&dst[didx].u, &tmp, sizeof(tmp)); + break; + } + case GLSL_TYPE_FLOAT: { + uint64_t tmp = src[sidx].f < 0.0f ? + 0ull : (uint64_t) roundf(src[sidx].f); + memcpy(&dst[didx].u, &tmp, sizeof(tmp)); + break; + } + default: + assert(!"Should not get here."); + break; + } + break; + default: assert(!"Should not get here."); break; |