ir_constant::ir_constant(const struct glsl_type *type, const void *data)
: ir_rvalue()
{
- const unsigned elements =
- ((type->vector_elements == 0) ? 1 : type->vector_elements)
- * ((type->matrix_columns == 0) ? 1 : type->matrix_columns);
unsigned size = 0;
this->type = type;
break;
}
- memcpy(& this->value, data, size * elements);
+ memcpy(& this->value, data, size * type->components());
+}
+
+ir_constant::ir_constant(float f)
+ : ir_rvalue()
+{
+ this->type = glsl_type::float_type;
+ this->value.f[0] = f;
+}
+
+ir_constant::ir_constant(unsigned int u)
+ : ir_rvalue()
+{
+ this->type = glsl_type::uint_type;
+ this->value.u[0] = u;
+}
+
+ir_constant::ir_constant(int i)
+ : ir_rvalue()
+{
+ this->type = glsl_type::int_type;
+ this->value.i[0] = i;
+}
+
+ir_constant::ir_constant(bool b)
+ : ir_rvalue()
+{
+ this->type = glsl_type::bool_type;
+ this->value.b[0] = b;
}
{
this->mode = ir_reference_variable;
this->var = var;
- this->type = (var != NULL) ? var->type : glsl_error_type;
+ this->type = (var != NULL) ? var->type : glsl_type::error_type;
}
: ir_rvalue(), mode(ir_reference_array),
var(var)
{
- this->type = (var != NULL) ? var->type : glsl_error_type;
+ this->type = (var != NULL) ? var->type : glsl_type::error_type;
this->selector.array_index = array_index;
}
{
this->type = type;
this->name = name;
+
+ if (type && type->base_type == GLSL_TYPE_SAMPLER)
+ this->read_only = true;
}
{
ir_call *call = new ir_call;
- call->type = glsl_error_type;
+ call->type = glsl_type::error_type;
return call;
}