intel/eu: Use descriptor constructors for dataport read messages.

v2: Use SET_BITS macro instead of left shift (Ken).

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Francisco Jerez 2018-06-07 10:50:20 -07:00
parent 27c211e30f
commit 2bac890bf5
4 changed files with 85 additions and 95 deletions

View file

@ -245,16 +245,6 @@ ROUND(RNDE)
/* Helpers for SEND instruction: /* Helpers for SEND instruction:
*/ */
void brw_set_dp_read_message(struct brw_codegen *p,
brw_inst *insn,
unsigned binding_table_index,
unsigned msg_control,
unsigned msg_type,
unsigned target_cache,
unsigned msg_length,
bool header_present,
unsigned response_length);
void brw_set_dp_write_message(struct brw_codegen *p, void brw_set_dp_write_message(struct brw_codegen *p,
brw_inst *insn, brw_inst *insn,
unsigned binding_table_index, unsigned binding_table_index,
@ -315,6 +305,34 @@ brw_sampler_desc(const struct gen_device_info *devinfo,
SET_BITS(msg_type, 15, 14)); SET_BITS(msg_type, 15, 14));
} }
/**
* Construct a message descriptor immediate with the specified dataport read
* function controls.
*/
static inline uint32_t
brw_dp_read_desc(const struct gen_device_info *devinfo,
unsigned binding_table_index,
unsigned msg_control,
unsigned msg_type,
unsigned target_cache)
{
const unsigned desc = SET_BITS(binding_table_index, 7, 0);
if (devinfo->gen >= 7)
return (desc | SET_BITS(msg_control, 13, 8) |
SET_BITS(msg_type, 17, 14));
else if (devinfo->gen >= 6)
return (desc | SET_BITS(msg_control, 12, 8) |
SET_BITS(msg_type, 16, 13));
else if (devinfo->gen >= 5 || devinfo->is_g4x)
return (desc | SET_BITS(msg_control, 10, 8) |
SET_BITS(msg_type, 13, 11) |
SET_BITS(target_cache, 15, 14));
else
return (desc | SET_BITS(msg_control, 11, 8) |
SET_BITS(msg_type, 13, 12) |
SET_BITS(target_cache, 15, 14));
}
void brw_urb_WRITE(struct brw_codegen *p, void brw_urb_WRITE(struct brw_codegen *p,
struct brw_reg dest, struct brw_reg dest,
unsigned msg_reg_nr, unsigned msg_reg_nr,

View file

@ -524,34 +524,6 @@ brw_set_dp_write_message(struct brw_codegen *p,
brw_inst_set_null_rt(devinfo, insn, false); brw_inst_set_null_rt(devinfo, insn, false);
} }
void
brw_set_dp_read_message(struct brw_codegen *p,
brw_inst *insn,
unsigned binding_table_index,
unsigned msg_control,
unsigned msg_type,
unsigned target_cache,
unsigned msg_length,
bool header_present,
unsigned response_length)
{
const struct gen_device_info *devinfo = p->devinfo;
const unsigned sfid = (devinfo->gen >= 6 ? target_cache :
BRW_SFID_DATAPORT_READ);
brw_set_desc(p, insn, brw_message_desc(
devinfo, msg_length, response_length, header_present));
const unsigned opcode = brw_inst_opcode(devinfo, insn);
if (opcode == BRW_OPCODE_SEND || opcode == BRW_OPCODE_SENDC)
brw_inst_set_sfid(devinfo, insn, sfid);
brw_inst_set_binding_table_index(devinfo, insn, binding_table_index);
brw_inst_set_dp_read_msg_type(devinfo, insn, msg_type);
brw_inst_set_dp_read_msg_control(devinfo, insn, msg_control);
if (devinfo->gen < 6)
brw_inst_set_dp_read_target_cache(devinfo, insn, target_cache);
}
static void static void
gen7_set_dp_scratch_message(struct brw_codegen *p, gen7_set_dp_scratch_message(struct brw_codegen *p,
brw_inst *inst, brw_inst *inst,
@ -2104,7 +2076,7 @@ brw_oword_block_read_scratch(struct brw_codegen *p,
const unsigned target_cache = const unsigned target_cache =
(devinfo->gen >= 7 ? GEN7_SFID_DATAPORT_DATA_CACHE : (devinfo->gen >= 7 ? GEN7_SFID_DATAPORT_DATA_CACHE :
devinfo->gen >= 6 ? GEN6_SFID_DATAPORT_RENDER_CACHE : devinfo->gen >= 6 ? GEN6_SFID_DATAPORT_RENDER_CACHE :
BRW_DATAPORT_READ_TARGET_RENDER_CACHE); BRW_SFID_DATAPORT_READ);
{ {
brw_push_insn_state(p); brw_push_insn_state(p);
@ -2124,6 +2096,7 @@ brw_oword_block_read_scratch(struct brw_codegen *p,
{ {
brw_inst *insn = next_insn(p, BRW_OPCODE_SEND); brw_inst *insn = next_insn(p, BRW_OPCODE_SEND);
brw_inst_set_sfid(devinfo, insn, target_cache);
assert(brw_inst_pred_control(devinfo, insn) == 0); assert(brw_inst_pred_control(devinfo, insn) == 0);
brw_inst_set_compression(devinfo, insn, false); brw_inst_set_compression(devinfo, insn, false);
@ -2135,15 +2108,12 @@ brw_oword_block_read_scratch(struct brw_codegen *p,
brw_inst_set_base_mrf(devinfo, insn, mrf.nr); brw_inst_set_base_mrf(devinfo, insn, mrf.nr);
} }
brw_set_dp_read_message(p, brw_set_desc(p, insn,
insn, brw_message_desc(devinfo, 1, rlen, true) |
brw_scratch_surface_idx(p), brw_dp_read_desc(devinfo, brw_scratch_surface_idx(p),
BRW_DATAPORT_OWORD_BLOCK_DWORDS(num_regs * 8), BRW_DATAPORT_OWORD_BLOCK_DWORDS(num_regs * 8),
BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ, /* msg_type */ BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ,
target_cache, BRW_DATAPORT_READ_TARGET_RENDER_CACHE));
1, /* msg_length */
true, /* header_present */
rlen);
} }
} }
@ -2195,7 +2165,7 @@ void brw_oword_block_read(struct brw_codegen *p,
const struct gen_device_info *devinfo = p->devinfo; const struct gen_device_info *devinfo = p->devinfo;
const unsigned target_cache = const unsigned target_cache =
(devinfo->gen >= 6 ? GEN6_SFID_DATAPORT_CONSTANT_CACHE : (devinfo->gen >= 6 ? GEN6_SFID_DATAPORT_CONSTANT_CACHE :
BRW_DATAPORT_READ_TARGET_DATA_CACHE); BRW_SFID_DATAPORT_READ);
const unsigned exec_size = 1 << brw_get_default_exec_size(p); const unsigned exec_size = 1 << brw_get_default_exec_size(p);
/* On newer hardware, offset is in units of owords. */ /* On newer hardware, offset is in units of owords. */
@ -2224,6 +2194,8 @@ void brw_oword_block_read(struct brw_codegen *p,
brw_inst *insn = next_insn(p, BRW_OPCODE_SEND); brw_inst *insn = next_insn(p, BRW_OPCODE_SEND);
brw_inst_set_sfid(devinfo, insn, target_cache);
/* cast dest to a uword[8] vector */ /* cast dest to a uword[8] vector */
dest = retype(vec8(dest), BRW_REGISTER_TYPE_UW); dest = retype(vec8(dest), BRW_REGISTER_TYPE_UW);
@ -2235,13 +2207,12 @@ void brw_oword_block_read(struct brw_codegen *p,
brw_inst_set_base_mrf(devinfo, insn, mrf.nr); brw_inst_set_base_mrf(devinfo, insn, mrf.nr);
} }
brw_set_dp_read_message(p, insn, bind_table_index, brw_set_desc(p, insn,
BRW_DATAPORT_OWORD_BLOCK_DWORDS(exec_size), brw_message_desc(devinfo, 1, DIV_ROUND_UP(exec_size, 8), true) |
BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ, brw_dp_read_desc(devinfo, bind_table_index,
target_cache, BRW_DATAPORT_OWORD_BLOCK_DWORDS(exec_size),
1, /* msg_length */ BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ,
true, /* header_present */ BRW_DATAPORT_READ_TARGET_DATA_CACHE));
DIV_ROUND_UP(exec_size, 8)); /* response_length */
brw_pop_insn_state(p); brw_pop_insn_state(p);
} }
@ -2324,14 +2295,16 @@ gen9_fb_READ(struct brw_codegen *p,
brw_get_default_exec_size(p) == BRW_EXECUTE_16 ? 0 : 1; brw_get_default_exec_size(p) == BRW_EXECUTE_16 ? 0 : 1;
brw_inst *insn = next_insn(p, BRW_OPCODE_SENDC); brw_inst *insn = next_insn(p, BRW_OPCODE_SENDC);
brw_inst_set_sfid(devinfo, insn, GEN6_SFID_DATAPORT_RENDER_CACHE);
brw_set_dest(p, insn, dst); brw_set_dest(p, insn, dst);
brw_set_src0(p, insn, payload); brw_set_src0(p, insn, payload);
brw_set_dp_read_message(p, insn, binding_table_index, brw_set_desc(
per_sample << 5 | msg_subtype, p, insn,
GEN9_DATAPORT_RC_RENDER_TARGET_READ, brw_message_desc(devinfo, msg_length, response_length, true) |
GEN6_SFID_DATAPORT_RENDER_CACHE, brw_dp_read_desc(devinfo, binding_table_index,
msg_length, true /* header_present */, per_sample << 5 | msg_subtype,
response_length); GEN9_DATAPORT_RC_RENDER_TARGET_READ,
BRW_DATAPORT_READ_TARGET_RENDER_CACHE));
brw_inst_set_rt_slot_group(devinfo, insn, brw_get_default_group(p) / 16); brw_inst_set_rt_slot_group(devinfo, insn, brw_get_default_group(p) / 16);
return insn; return insn;

View file

@ -1421,15 +1421,16 @@ fs_generator::generate_uniform_pull_constant_load_gen7(fs_inst *inst,
brw_inst *send = brw_next_insn(p, BRW_OPCODE_SEND); brw_inst *send = brw_next_insn(p, BRW_OPCODE_SEND);
brw_pop_insn_state(p); brw_pop_insn_state(p);
brw_inst_set_sfid(devinfo, send, GEN6_SFID_DATAPORT_CONSTANT_CACHE);
brw_set_dest(p, send, retype(dst, BRW_REGISTER_TYPE_UD)); brw_set_dest(p, send, retype(dst, BRW_REGISTER_TYPE_UD));
brw_set_src0(p, send, retype(payload, BRW_REGISTER_TYPE_UD)); brw_set_src0(p, send, retype(payload, BRW_REGISTER_TYPE_UD));
brw_set_dp_read_message(p, send, surf_index, brw_set_desc(p, send,
BRW_DATAPORT_OWORD_BLOCK_DWORDS(inst->exec_size), brw_message_desc(devinfo, 1, DIV_ROUND_UP(inst->size_written,
GEN7_DATAPORT_DC_OWORD_BLOCK_READ, REG_SIZE), true) |
GEN6_SFID_DATAPORT_CONSTANT_CACHE, brw_dp_read_desc(devinfo, surf_index,
1, /* mlen */ BRW_DATAPORT_OWORD_BLOCK_DWORDS(inst->exec_size),
true, /* header */ GEN7_DATAPORT_DC_OWORD_BLOCK_READ,
DIV_ROUND_UP(inst->size_written, REG_SIZE)); BRW_DATAPORT_READ_TARGET_DATA_CACHE));
} else { } else {
struct brw_reg addr = vec1(retype(brw_address_reg(0), BRW_REGISTER_TYPE_UD)); struct brw_reg addr = vec1(retype(brw_address_reg(0), BRW_REGISTER_TYPE_UD));
@ -1445,17 +1446,16 @@ fs_generator::generate_uniform_pull_constant_load_gen7(fs_inst *inst,
brw_set_src1(p, insn_and, brw_imm_ud(0x0ff)); brw_set_src1(p, insn_and, brw_imm_ud(0x0ff));
/* dst = send(payload, a0.0 | <descriptor>) */ /* dst = send(payload, a0.0 | <descriptor>) */
brw_inst *insn = brw_send_indirect_message( brw_send_indirect_message(
p, GEN6_SFID_DATAPORT_CONSTANT_CACHE, p, GEN6_SFID_DATAPORT_CONSTANT_CACHE,
retype(dst, BRW_REGISTER_TYPE_UD), retype(dst, BRW_REGISTER_TYPE_UD),
retype(payload, BRW_REGISTER_TYPE_UD), addr, 0); retype(payload, BRW_REGISTER_TYPE_UD), addr,
brw_set_dp_read_message(p, insn, 0 /* surface */, brw_message_desc(devinfo, 1,
BRW_DATAPORT_OWORD_BLOCK_DWORDS(inst->exec_size), DIV_ROUND_UP(inst->size_written, REG_SIZE), true) |
GEN7_DATAPORT_DC_OWORD_BLOCK_READ, brw_dp_read_desc(devinfo, 0 /* surface */,
GEN6_SFID_DATAPORT_CONSTANT_CACHE, BRW_DATAPORT_OWORD_BLOCK_DWORDS(inst->exec_size),
1, /* mlen */ GEN7_DATAPORT_DC_OWORD_BLOCK_READ,
true, /* header */ BRW_DATAPORT_READ_TARGET_DATA_CACHE));
DIV_ROUND_UP(inst->size_written, REG_SIZE));
brw_pop_insn_state(p); brw_pop_insn_state(p);
} }

View file

@ -1155,23 +1155,23 @@ generate_scratch_read(struct brw_codegen *p,
const unsigned target_cache = const unsigned target_cache =
devinfo->gen >= 7 ? GEN7_SFID_DATAPORT_DATA_CACHE : devinfo->gen >= 7 ? GEN7_SFID_DATAPORT_DATA_CACHE :
devinfo->gen >= 6 ? GEN6_SFID_DATAPORT_RENDER_CACHE : devinfo->gen >= 6 ? GEN6_SFID_DATAPORT_RENDER_CACHE :
BRW_DATAPORT_READ_TARGET_RENDER_CACHE; BRW_SFID_DATAPORT_READ;
/* Each of the 8 channel enables is considered for whether each /* Each of the 8 channel enables is considered for whether each
* dword is written. * dword is written.
*/ */
brw_inst *send = brw_next_insn(p, BRW_OPCODE_SEND); brw_inst *send = brw_next_insn(p, BRW_OPCODE_SEND);
brw_inst_set_sfid(devinfo, send, target_cache);
brw_set_dest(p, send, dst); brw_set_dest(p, send, dst);
brw_set_src0(p, send, header); brw_set_src0(p, send, header);
if (devinfo->gen < 6) if (devinfo->gen < 6)
brw_inst_set_cond_modifier(devinfo, send, inst->base_mrf); brw_inst_set_cond_modifier(devinfo, send, inst->base_mrf);
brw_set_dp_read_message(p, send, brw_set_desc(p, send,
brw_scratch_surface_idx(p), brw_message_desc(devinfo, 2, 1, true) |
BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD, brw_dp_read_desc(devinfo,
msg_type, target_cache, brw_scratch_surface_idx(p),
2, /* mlen */ BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD,
true, /* header_present */ msg_type, BRW_DATAPORT_READ_TARGET_RENDER_CACHE));
1 /* rlen */);
} }
static void static void
@ -1265,7 +1265,7 @@ generate_pull_constant_load(struct brw_codegen *p,
const struct gen_device_info *devinfo = p->devinfo; const struct gen_device_info *devinfo = p->devinfo;
const unsigned target_cache = const unsigned target_cache =
(devinfo->gen >= 6 ? GEN6_SFID_DATAPORT_SAMPLER_CACHE : (devinfo->gen >= 6 ? GEN6_SFID_DATAPORT_SAMPLER_CACHE :
BRW_DATAPORT_READ_TARGET_DATA_CACHE); BRW_SFID_DATAPORT_READ);
assert(index.file == BRW_IMMEDIATE_VALUE && assert(index.file == BRW_IMMEDIATE_VALUE &&
index.type == BRW_REGISTER_TYPE_UD); index.type == BRW_REGISTER_TYPE_UD);
uint32_t surf_index = index.ud; uint32_t surf_index = index.ud;
@ -1303,18 +1303,17 @@ generate_pull_constant_load(struct brw_codegen *p,
* dword is written. * dword is written.
*/ */
brw_inst *send = brw_next_insn(p, BRW_OPCODE_SEND); brw_inst *send = brw_next_insn(p, BRW_OPCODE_SEND);
brw_inst_set_sfid(devinfo, send, target_cache);
brw_set_dest(p, send, dst); brw_set_dest(p, send, dst);
brw_set_src0(p, send, header); brw_set_src0(p, send, header);
if (devinfo->gen < 6) if (devinfo->gen < 6)
brw_inst_set_cond_modifier(p->devinfo, send, inst->base_mrf); brw_inst_set_cond_modifier(p->devinfo, send, inst->base_mrf);
brw_set_dp_read_message(p, send, brw_set_desc(p, send,
surf_index, brw_message_desc(devinfo, 2, 1, true) |
BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD, brw_dp_read_desc(devinfo, surf_index,
msg_type, BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD,
target_cache, msg_type,
2, /* mlen */ BRW_DATAPORT_READ_TARGET_DATA_CACHE));
true, /* header_present */
1 /* rlen */);
} }
static void static void