summaryrefslogtreecommitdiff
path: root/ir.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-06-04 16:13:35 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-06-11 13:51:09 -0700
commit989cfc432ee7adef701a87783e0c6b064c1cfaee (patch)
treecb29a9510ff561ce0858076f7966a2fe4dee3945 /ir.cpp
parent565185cd8f3ea636d3d2aaad9218d63323390464 (diff)
Construct an ir_constant from a scalar component of another ir_constant
Diffstat (limited to 'ir.cpp')
-rw-r--r--ir.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/ir.cpp b/ir.cpp
index c5eb94d2d5..f7e03cb58d 100644
--- a/ir.cpp
+++ b/ir.cpp
@@ -227,6 +227,19 @@ ir_constant::ir_constant(bool b)
this->value.b[0] = b;
}
+ir_constant::ir_constant(const ir_constant *c, unsigned i)
+{
+ this->type = c->type->get_base_type();
+
+ switch (this->type->base_type) {
+ case GLSL_TYPE_UINT: this->value.u[0] = c->value.u[i]; break;
+ case GLSL_TYPE_INT: this->value.i[0] = c->value.i[i]; break;
+ case GLSL_TYPE_FLOAT: this->value.f[0] = c->value.f[i]; break;
+ case GLSL_TYPE_BOOL: this->value.b[0] = c->value.b[i]; break;
+ default: assert(!"Should not get here."); break;
+ }
+}
+
ir_dereference_variable::ir_dereference_variable(ir_variable *var)
{