summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/uniform_query.cpp
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2016-06-09 09:20:19 +1000
committerIan Romanick <[email protected]>2017-01-20 15:41:23 -0800
commit249007d13cf10cdc1359a15939b50f947f1cae6a (patch)
tree3914a1c63b5099546796bb8a7ffc42eb0320f3ca /src/mesa/main/uniform_query.cpp
parent8ce53d4a2f3f44b8fa00a6a04ec0816f38d788db (diff)
mesa: Add support for 64-bit integer uniforms
This hooks up the API to the internals for 64-bit integer uniforms. v2: update to use non-strict aliased alternatives Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mesa/main/uniform_query.cpp')
-rw-r--r--src/mesa/main/uniform_query.cpp82
1 files changed, 79 insertions, 3 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 145eff01756..f505986fcfc 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -332,7 +332,8 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
&uni->storage[offset * elements * dmul];
assert(returnType == GLSL_TYPE_FLOAT || returnType == GLSL_TYPE_INT ||
- returnType == GLSL_TYPE_UINT || returnType == GLSL_TYPE_DOUBLE);
+ returnType == GLSL_TYPE_UINT || returnType == GLSL_TYPE_DOUBLE ||
+ returnType == GLSL_TYPE_UINT64 || returnType == GLSL_TYPE_INT64);
/* doubles have a different size than the other 3 types */
unsigned bytes = sizeof(src[0]) * elements * rmul;
@@ -354,7 +355,11 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
(uni->type->base_type == GLSL_TYPE_INT
|| uni->type->base_type == GLSL_TYPE_UINT
|| uni->type->base_type == GLSL_TYPE_SAMPLER
- || uni->type->base_type == GLSL_TYPE_IMAGE))) {
+ || uni->type->base_type == GLSL_TYPE_IMAGE))
+ || ((returnType == GLSL_TYPE_UINT64 ||
+ returnType == GLSL_TYPE_INT64 ) &&
+ (uni->type->base_type == GLSL_TYPE_UINT64 ||
+ uni->type->base_type == GLSL_TYPE_INT64))) {
memcpy(paramsOut, src, bytes);
} else {
union gl_constant_value *const dst =
@@ -387,6 +392,18 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
dst[didx].f = tmp;
break;
}
+ case GLSL_TYPE_UINT64: {
+ uint64_t tmp;
+ memcpy(&tmp, &src[sidx].u, sizeof(tmp));
+ dst[didx].f = tmp;
+ break;
+ }
+ case GLSL_TYPE_INT64: {
+ uint64_t tmp;
+ memcpy(&tmp, &src[sidx].i, sizeof(tmp));
+ dst[didx].f = tmp;
+ break;
+ }
default:
assert(!"Should not get here.");
break;
@@ -416,6 +433,22 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
memcpy(&dst[didx].f, &tmp, sizeof(tmp));
break;
}
+ case GLSL_TYPE_UINT64: {
+ uint64_t tmpu;
+ double tmp;
+ memcpy(&tmpu, &src[sidx].u, sizeof(tmpu));
+ tmp = tmpu;
+ memcpy(&dst[didx].f, &tmp, sizeof(tmp));
+ break;
+ }
+ case GLSL_TYPE_INT64: {
+ int64_t tmpi;
+ double tmp;
+ memcpy(&tmpi, &src[sidx].i, sizeof(tmpi));
+ tmp = tmpi;
+ memcpy(&dst[didx].f, &tmp, sizeof(tmp));
+ break;
+ }
default:
assert(!"Should not get here.");
break;
@@ -453,12 +486,45 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
dst[didx].i = IROUNDD(tmp);
break;
}
+ case GLSL_TYPE_UINT64: {
+ uint64_t tmp;
+ memcpy(&tmp, &src[sidx].u, sizeof(tmp));
+ dst[didx].i = tmp;
+ break;
+ }
+ case GLSL_TYPE_INT64: {
+ int64_t tmp;
+ memcpy(&tmp, &src[sidx].i, sizeof(tmp));
+ dst[didx].i = tmp;
+ break;
+ }
default:
assert(!"Should not get here.");
break;
}
break;
-
+ case GLSL_TYPE_INT64:
+ case GLSL_TYPE_UINT64:
+ switch (uni->type->base_type) {
+ case GLSL_TYPE_UINT:
+ *(int64_t *)&dst[didx].u = (int64_t) src[sidx].u;
+ break;
+ case GLSL_TYPE_INT:
+ case GLSL_TYPE_SAMPLER:
+ case GLSL_TYPE_IMAGE:
+ *(int64_t *)&dst[didx].u = (int64_t) src[sidx].i;
+ break;
+ case GLSL_TYPE_BOOL:
+ *(int64_t *)&dst[didx].u = src[sidx].i ? 1.0f : 0.0f;
+ break;
+ case GLSL_TYPE_FLOAT:
+ *(int64_t *)&dst[didx].u = (int64_t) src[sidx].f;
+ break;
+ default:
+ assert(!"Should not get here.");
+ break;
+ }
+ break;
default:
assert(!"Should not get here.");
break;
@@ -496,6 +562,12 @@ log_uniform(const void *values, enum glsl_base_type basicType,
case GLSL_TYPE_INT:
printf("%d ", v[i].i);
break;
+ case GLSL_TYPE_UINT64:
+ printf("%lu ", *(uint64_t* )&v[i * 2].u);
+ break;
+ case GLSL_TYPE_INT64:
+ printf("%ld ", *(int64_t* )&v[i * 2].u);
+ break;
case GLSL_TYPE_FLOAT:
printf("%g ", v[i].f);
break;
@@ -667,6 +739,10 @@ glsl_type_name(enum glsl_base_type type)
return "float";
case GLSL_TYPE_DOUBLE:
return "double";
+ case GLSL_TYPE_UINT64:
+ return "uint64";
+ case GLSL_TYPE_INT64:
+ return "int64";
case GLSL_TYPE_BOOL:
return "bool";
case GLSL_TYPE_SAMPLER: