Mesa (master): glsl: Extend ir_constant::zero to handle more types.
Kenneth Graunke
kwg at kemper.freedesktop.org
Tue May 8 19:59:12 UTC 2012
Module: Mesa
Branch: master
Commit: 27a198388ed78c83d9a255efc0fb2294d985f3ad
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=27a198388ed78c83d9a255efc0fb2294d985f3ad
Author: Olivier Galibert <galibert at pobox.com>
Date: Wed May 2 23:11:37 2012 +0200
glsl: Extend ir_constant::zero to handle more types.
Signed-off-by: Olivier Galibert <galibert at pobox.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Eric Anholt <eric at anholt.net> [v1]
---
src/glsl/ir.cpp | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 1ba8751..d0a6d09 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -716,12 +716,27 @@ 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() || type->is_boolean());
+ assert(type->is_scalar() || type->is_vector() || type->is_matrix()
+ || type->is_record() || type->is_array());
ir_constant *c = new(mem_ctx) ir_constant;
c->type = type;
memset(&c->value, 0, sizeof(c->value));
+ if (type->is_array()) {
+ c->array_elements = ralloc_array(c, ir_constant *, type->length);
+
+ for (unsigned i = 0; i < type->length; i++)
+ c->array_elements[i] = ir_constant::zero(c, type->element_type());
+ }
+
+ if (type->is_record()) {
+ for (unsigned i = 0; i < type->length; i++) {
+ ir_constant *comp = ir_constant::zero(mem_ctx, type->fields.structure[i].type);
+ c->components.push_tail(comp);
+ }
+ }
+
return c;
}
More information about the mesa-commit
mailing list