That method is to be used to trace through assignments when computing a constant expression.
Signed-off-by: Olivier Galibert <galib...@pobox.com> --- src/glsl/ir.cpp | 31 +++++++++++++++++++++++++++++++ src/glsl/ir.h | 8 ++++++++ 2 files changed, 39 insertions(+) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index cfa806d..782d19a 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -857,6 +857,37 @@ ir_constant::get_record_field(const char *name) return (ir_constant *) node; } +void +ir_constant::copy_masked_offset(ir_constant *src, int offset, unsigned int mask) +{ + assert (!type->is_array() && !type->is_record()); + + if (!type->is_vector() && !type->is_matrix()) { + offset = 0; + mask = 1; + } + + int id = 0; + for (int i=0; i<4; i++) + if(mask & (1 << i)) + switch (this->type->base_type) { + case GLSL_TYPE_UINT: + value.u[i+offset] = src->get_uint_component(id++); + break; + case GLSL_TYPE_INT: + value.i[i+offset] = src->get_int_component(id++); + break; + case GLSL_TYPE_FLOAT: + value.f[i+offset] = src->get_float_component(id++); + break; + case GLSL_TYPE_BOOL: + value.b[i+offset] = src->get_bool_component(id++); + break; + default: + assert(!"Should not get here."); + return; + } +} bool ir_constant::has_value(const ir_constant *c) const diff --git a/src/glsl/ir.h b/src/glsl/ir.h index c211880..9db6c84 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1681,6 +1681,14 @@ public: ir_constant *get_record_field(const char *name); + /* Copy the values on another constant at a given offset and + * following an assign-like mask. + * + * The mask is ignored for scalars. + */ + + void copy_masked_offset(ir_constant *src, int offset, unsigned int mask); + /** * Determine whether a constant has the same value as another constant * -- 1.7.10.280.gaa39 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev