On 03/12/2014 04:11 PM, Connor Abbott wrote: > On Wed, Mar 12, 2014 at 6:49 PM, Ian Romanick <i...@freedesktop.org> wrote: >> From: Ian Romanick <ian.d.roman...@intel.com> >> >> Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> >> --- >> src/glsl/ir_clone.cpp | 10 +- >> src/glsl/ir_constant_expression.cpp | 195 >> +++++++++++++++++++----------------- >> 2 files changed, 109 insertions(+), 96 deletions(-) >> >> diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp >> index 311c992..167b80c 100644 >> --- a/src/glsl/ir_clone.cpp >> +++ b/src/glsl/ir_clone.cpp >> @@ -265,10 +265,12 @@ ir_assignment::clone(void *mem_ctx, struct hash_table >> *ht) const >> if (this->condition) >> new_condition = this->condition->clone(mem_ctx, ht); >> >> - return new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht), >> - this->rhs->clone(mem_ctx, ht), >> - new_condition, >> - this->write_mask); >> + ir_assignment *cloned = >> + new(mem_ctx) ir_assignment(this->lhs->clone(mem_ctx, ht), >> + this->rhs->clone(mem_ctx, ht), >> + new_condition); >> + cloned->write_mask = this->write_mask; >> + return cloned; > > Looks like this is leftover from something else...
Aye, that it is. Good catch. I'll remove it. >> } >> >> ir_function * >> diff --git a/src/glsl/ir_constant_expression.cpp >> b/src/glsl/ir_constant_expression.cpp >> index 7fa5a09..a31e579 100644 >> --- a/src/glsl/ir_constant_expression.cpp >> +++ b/src/glsl/ir_constant_expression.cpp >> @@ -386,6 +386,109 @@ unpack_half_1x16(uint16_t u) >> return _mesa_half_to_float(u); >> } >> >> +/** >> + * \name Functions to get the constant referenced by an r-value >> + * >> + * Get the constant that is ultimately referenced by an r-value, in a >> constant >> + * expression evaluation context. >> + * >> + * The offset is used when the reference is to a specific column of a >> matrix. >> + */ >> +/*@{*/ >> +void >> +ir_dereference_variable::constant_referenced(struct hash_table >> *variable_context, >> + ir_constant *&store, int >> &offset) const >> +{ >> + if (variable_context) { >> + store = (ir_constant *)hash_table_find(variable_context, var); >> + offset = 0; >> + } else { >> + store = NULL; >> + offset = 0; >> + } >> +} >> + >> +void >> +ir_dereference_array::constant_referenced(struct hash_table >> *variable_context, >> + ir_constant *&store, int &offset) >> const >> +{ >> + ir_constant *index_c = >> array_index->constant_expression_value(variable_context); >> + >> + if (!index_c || !index_c->type->is_scalar() || >> !index_c->type->is_integer()) { >> + store = 0; >> + offset = 0; >> + return; >> + } >> + >> + int index = index_c->type->base_type == GLSL_TYPE_INT ? >> + index_c->get_int_component(0) : >> + index_c->get_uint_component(0); >> + >> + ir_constant *substore; >> + int suboffset; >> + const ir_dereference *deref = array->as_dereference(); >> + if (!deref) { >> + store = 0; >> + offset = 0; >> + return; >> + } >> + >> + deref->constant_referenced(variable_context, substore, suboffset); >> + >> + if (!substore) { >> + store = 0; >> + offset = 0; >> + return; >> + } >> + >> + const glsl_type *vt = array->type; >> + if (vt->is_array()) { >> + store = substore->get_array_element(index); >> + offset = 0; >> + return; >> + } >> + if (vt->is_matrix()) { >> + store = substore; >> + offset = index * vt->vector_elements; >> + return; >> + } >> + if (vt->is_vector()) { >> + store = substore; >> + offset = suboffset + index; >> + return; >> + } >> + >> + store = 0; >> + offset = 0; >> +} >> + >> +void >> +ir_dereference_record::constant_referenced(struct hash_table >> *variable_context, >> + ir_constant *&store, int &offset) >> const >> +{ >> + ir_constant *substore; >> + int suboffset; >> + const ir_dereference *deref = record->as_dereference(); >> + if (!deref) { >> + store = 0; >> + offset = 0; >> + return; >> + } >> + >> + deref->constant_referenced(variable_context, substore, suboffset); >> + >> + if (!substore) { >> + store = 0; >> + offset = 0; >> + return; >> + } >> + >> + store = substore->get_record_field(field); >> + offset = 0; >> +} >> +/*@}*/ >> + >> + >> ir_constant * >> ir_rvalue::constant_expression_value(struct hash_table *variable_context) >> { >> @@ -1570,19 +1673,6 @@ ir_swizzle::constant_expression_value(struct >> hash_table *variable_context) >> } >> >> >> -void >> -ir_dereference_variable::constant_referenced(struct hash_table >> *variable_context, >> - ir_constant *&store, int >> &offset) const >> -{ >> - if (variable_context) { >> - store = (ir_constant *)hash_table_find(variable_context, var); >> - offset = 0; >> - } else { >> - store = NULL; >> - offset = 0; >> - } >> -} >> - >> ir_constant * >> ir_dereference_variable::constant_expression_value(struct hash_table >> *variable_context) >> { >> @@ -1610,60 +1700,6 @@ >> ir_dereference_variable::constant_expression_value(struct hash_table >> *variable_c >> } >> >> >> -void >> -ir_dereference_array::constant_referenced(struct hash_table >> *variable_context, >> - ir_constant *&store, int &offset) >> const >> -{ >> - ir_constant *index_c = >> array_index->constant_expression_value(variable_context); >> - >> - if (!index_c || !index_c->type->is_scalar() || >> !index_c->type->is_integer()) { >> - store = 0; >> - offset = 0; >> - return; >> - } >> - >> - int index = index_c->type->base_type == GLSL_TYPE_INT ? >> - index_c->get_int_component(0) : >> - index_c->get_uint_component(0); >> - >> - ir_constant *substore; >> - int suboffset; >> - const ir_dereference *deref = array->as_dereference(); >> - if (!deref) { >> - store = 0; >> - offset = 0; >> - return; >> - } >> - >> - deref->constant_referenced(variable_context, substore, suboffset); >> - >> - if (!substore) { >> - store = 0; >> - offset = 0; >> - return; >> - } >> - >> - const glsl_type *vt = array->type; >> - if (vt->is_array()) { >> - store = substore->get_array_element(index); >> - offset = 0; >> - return; >> - } >> - if (vt->is_matrix()) { >> - store = substore; >> - offset = index * vt->vector_elements; >> - return; >> - } >> - if (vt->is_vector()) { >> - store = substore; >> - offset = suboffset + index; >> - return; >> - } >> - >> - store = 0; >> - offset = 0; >> -} >> - >> ir_constant * >> ir_dereference_array::constant_expression_value(struct hash_table >> *variable_context) >> { >> @@ -1719,31 +1755,6 @@ >> ir_dereference_array::constant_expression_value(struct hash_table >> *variable_cont >> } >> >> >> -void >> -ir_dereference_record::constant_referenced(struct hash_table >> *variable_context, >> - ir_constant *&store, int &offset) >> const >> -{ >> - ir_constant *substore; >> - int suboffset; >> - const ir_dereference *deref = record->as_dereference(); >> - if (!deref) { >> - store = 0; >> - offset = 0; >> - return; >> - } >> - >> - deref->constant_referenced(variable_context, substore, suboffset); >> - >> - if (!substore) { >> - store = 0; >> - offset = 0; >> - return; >> - } >> - >> - store = substore->get_record_field(field); >> - offset = 0; >> -} >> - >> ir_constant * >> ir_dereference_record::constant_expression_value(struct hash_table >> *variable_context) >> { >> -- >> 1.8.1.4 >> >> _______________________________________________ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev