glsl2: Add new ir_constant::zero static method.
This conveniently creates a zero value of whatever type you want.
This commit is contained in:
@@ -326,6 +326,18 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ir_constant *
|
||||||
|
ir_constant::zero(void *mem_ctx, const glsl_type *type)
|
||||||
|
{
|
||||||
|
assert(type->is_numeric());
|
||||||
|
|
||||||
|
ir_constant *c = new(mem_ctx) ir_constant;
|
||||||
|
c->type = type;
|
||||||
|
memset(&c->value, 0, sizeof(c->value));
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ir_constant::get_bool_component(unsigned i) const
|
ir_constant::get_bool_component(unsigned i) const
|
||||||
{
|
{
|
||||||
|
@@ -1248,6 +1248,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
ir_constant(const ir_constant *c, unsigned i);
|
ir_constant(const ir_constant *c, unsigned i);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a new ir_constant of the specified type containing all zeros.
|
||||||
|
*/
|
||||||
|
static ir_constant *zero(void *mem_ctx, const glsl_type *type);
|
||||||
|
|
||||||
virtual ir_constant *clone(struct hash_table *) const;
|
virtual ir_constant *clone(struct hash_table *) const;
|
||||||
|
|
||||||
virtual ir_constant *constant_expression_value();
|
virtual ir_constant *constant_expression_value();
|
||||||
|
Reference in New Issue
Block a user