From: Iago Toral Quiroga Date: Wed, 17 Feb 2016 09:05:02 +0000 (+0100) Subject: i965/vec4: fix scratch offset for 64bit data X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e4d9ab609f217bde95722e76a98d646890c9abc9;p=mesa.git i965/vec4: fix scratch offset for 64bit data A vec4 is 16 bytes and a dvec4 is 32 bytes so for doubles we have to multiply the reladdr by 2. The reg_offset part is in units of 16 bytes and is used to select the low/high 16-byte chunk of a full dvec4, so we don't want to multiply that part of the address. Reviewed-by: Matt Turner --- diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 9a9890631c2..d4fe4fa5def 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -1443,13 +1443,23 @@ vec4_visitor::get_scratch_offset(bblock_t *block, vec4_instruction *inst, message_header_scale *= 16; if (reladdr) { + /* A vec4 is 16 bytes and a dvec4 is 32 bytes so for doubles we have + * to multiply the reladdr by 2. Notice that the reg_offset part + * is in units of 16 bytes and is used to select the low/high 16-byte + * chunk of a full dvec4, so we don't want to multiply that part. + */ src_reg index = src_reg(this, glsl_type::int_type); - - emit_before(block, inst, ADD(dst_reg(index), *reladdr, - brw_imm_d(reg_offset))); - emit_before(block, inst, MUL(dst_reg(index), index, - brw_imm_d(message_header_scale))); - + if (type_sz(inst->dst.type) < 8) { + emit_before(block, inst, ADD(dst_reg(index), *reladdr, + brw_imm_d(reg_offset))); + emit_before(block, inst, MUL(dst_reg(index), index, + brw_imm_d(message_header_scale))); + } else { + emit_before(block, inst, MUL(dst_reg(index), *reladdr, + brw_imm_d(message_header_scale * 2))); + emit_before(block, inst, ADD(dst_reg(index), index, + brw_imm_d(reg_offset * message_header_scale))); + } return index; } else { return brw_imm_d(reg_offset * message_header_scale);