aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/ir_constant_expression.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-06-08 09:33:13 +0200
committermarha <marha@users.sourceforge.net>2012-06-08 09:33:13 +0200
commit990bc3f015a4f8fce2eb918375defcd44980a845 (patch)
tree8e8301f19482b52cc00bd95b4593522cc93267af /mesalib/src/glsl/ir_constant_expression.cpp
parent1af6fc1b5d93e54d6674de8b5870448b29f139a7 (diff)
downloadvcxsrv-990bc3f015a4f8fce2eb918375defcd44980a845.tar.gz
vcxsrv-990bc3f015a4f8fce2eb918375defcd44980a845.tar.bz2
vcxsrv-990bc3f015a4f8fce2eb918375defcd44980a845.zip
Used synchronise script to update files
Diffstat (limited to 'mesalib/src/glsl/ir_constant_expression.cpp')
-rw-r--r--mesalib/src/glsl/ir_constant_expression.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/mesalib/src/glsl/ir_constant_expression.cpp b/mesalib/src/glsl/ir_constant_expression.cpp
index 08a33285b..7a4d15f43 100644
--- a/mesalib/src/glsl/ir_constant_expression.cpp
+++ b/mesalib/src/glsl/ir_constant_expression.cpp
@@ -71,6 +71,29 @@ dot(ir_constant *op0, ir_constant *op1)
return result;
}
+/* This method is the only one supported by gcc. Unions in particular
+ * are iffy, and read-through-converted-pointer is killed by strict
+ * aliasing. OTOH, the compiler sees through the memcpy, so the
+ * resulting asm is reasonable.
+ */
+static float
+bitcast_u2f(unsigned int u)
+{
+ assert(sizeof(float) == sizeof(unsigned int));
+ float f;
+ memcpy(&f, &u, sizeof(f));
+ return f;
+}
+
+static unsigned int
+bitcast_f2u(float f)
+{
+ assert(sizeof(float) == sizeof(unsigned int));
+ unsigned int u;
+ memcpy(&u, &f, sizeof(f));
+ return u;
+}
+
ir_constant *
ir_rvalue::constant_expression_value(struct hash_table *variable_context)
{
@@ -207,6 +230,30 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
data.u[c] = op[0]->value.i[c];
}
break;
+ case ir_unop_bitcast_i2f:
+ assert(op[0]->type->base_type == GLSL_TYPE_INT);
+ for (unsigned c = 0; c < op[0]->type->components(); c++) {
+ data.f[c] = bitcast_u2f(op[0]->value.i[c]);
+ }
+ break;
+ case ir_unop_bitcast_f2i:
+ assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
+ for (unsigned c = 0; c < op[0]->type->components(); c++) {
+ data.i[c] = bitcast_f2u(op[0]->value.f[c]);
+ }
+ break;
+ case ir_unop_bitcast_u2f:
+ assert(op[0]->type->base_type == GLSL_TYPE_UINT);
+ for (unsigned c = 0; c < op[0]->type->components(); c++) {
+ data.f[c] = bitcast_u2f(op[0]->value.u[c]);
+ }
+ break;
+ case ir_unop_bitcast_f2u:
+ assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
+ for (unsigned c = 0; c < op[0]->type->components(); c++) {
+ data.u[c] = bitcast_f2u(op[0]->value.f[c]);
+ }
+ break;
case ir_unop_any:
assert(op[0]->type->is_boolean());
data.b[0] = false;