The extra mul should end up const folded away in the backend. --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index dbb01b5..e0f5718 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2194,20 +2194,31 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op) const_offset = const_offset_ir->value.u[0]; cbuf.index = const_offset / 16; offset_expr->operands[0]->accept(this); offset = this->result; } } /* Relative/variable index into constant buffer */ emit_asm(ir, TGSI_OPCODE_USHR, st_dst_reg(index_reg), offset, st_src_reg_for_int(4)); + + if (ctx->Const.PackedDriverUniformStorage) { + st_src_reg tmp_reg = + get_temp(native_integers ? glsl_type::int_type : + glsl_type::float_type); + emit_asm(ir, TGSI_OPCODE_MUL, st_dst_reg(tmp_reg), + index_reg, st_src_reg_for_type(index_reg.type, 4)); + + index_reg = tmp_reg; + } + cbuf.reladdr = ralloc(mem_ctx, st_src_reg); memcpy(cbuf.reladdr, &index_reg, sizeof(index_reg)); } if (const_uniform_block) { /* Constant constant buffer */ cbuf.reladdr2 = NULL; cbuf.index2D = const_block; cbuf.has_index2 = true; } @@ -2873,20 +2884,42 @@ glsl_to_tgsi_visitor::visit(ir_dereference_array *ir) if (element_size == 1) { index_reg = this->result; } else { index_reg = get_temp(native_integers ? glsl_type::int_type : glsl_type::float_type); emit_asm(ir, TGSI_OPCODE_MUL, st_dst_reg(index_reg), this->result, st_src_reg_for_type(index_reg.type, element_size)); } + ir_variable *var = ir->array->variable_referenced(); + if (ctx->Const.PackedDriverUniformStorage && + var && var->data.mode == ir_var_uniform) { + unsigned comps = ir->type->without_array()->vector_elements; + + /* FIXME: This will only works if the struct has a single member. + * Even the non-packed path has this bug so this is enough to stop + * piglit regressions for now. + */ + comps = ir->type->is_record() ? + ir->type->fields.structure[0].type->without_array()->vector_elements : + comps; + + st_src_reg tmp_reg = + get_temp(native_integers ? glsl_type::int_type : + glsl_type::float_type); + emit_asm(ir, TGSI_OPCODE_MUL, st_dst_reg(tmp_reg), + index_reg, st_src_reg_for_type(index_reg.type, comps)); + + index_reg = tmp_reg; + } + /* If there was already a relative address register involved, add the * new and the old together to get the new offset. */ if (!is_2D && src.reladdr != NULL) { st_src_reg accum_reg = get_temp(native_integers ? glsl_type::int_type : glsl_type::float_type); emit_asm(ir, TGSI_OPCODE_ADD, st_dst_reg(accum_reg), index_reg, *src.reladdr); -- 2.9.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev