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 <mattst88@gmail.com>
This commit is contained in:
Iago Toral Quiroga 2016-02-17 10:05:02 +01:00 committed by Samuel Iglesias Gonsálvez
parent 07bc6a35d3
commit e4d9ab609f
1 changed files with 16 additions and 6 deletions

View File

@ -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);