v2: Use SET_BITS macro instead of left shift (Ken).
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
/* Helpers for SEND instruction:
*/
-void brw_set_sampler_message(struct brw_codegen *p,
- brw_inst *insn,
- unsigned binding_table_index,
- unsigned sampler,
- unsigned msg_type,
- unsigned response_length,
- unsigned msg_length,
- unsigned header_present,
- unsigned simd_mode,
- unsigned return_format);
-
void brw_set_dp_read_message(struct brw_codegen *p,
brw_inst *insn,
unsigned binding_table_index,
}
}
+/**
+ * Construct a message descriptor immediate with the specified sampler
+ * function controls.
+ */
+static inline uint32_t
+brw_sampler_desc(const struct gen_device_info *devinfo,
+ unsigned binding_table_index,
+ unsigned sampler,
+ unsigned msg_type,
+ unsigned simd_mode,
+ unsigned return_format)
+{
+ const unsigned desc = (SET_BITS(binding_table_index, 7, 0) |
+ SET_BITS(sampler, 11, 8));
+ if (devinfo->gen >= 7)
+ return (desc | SET_BITS(msg_type, 16, 12) |
+ SET_BITS(simd_mode, 18, 17));
+ else if (devinfo->gen >= 5)
+ return (desc | SET_BITS(msg_type, 15, 12) |
+ SET_BITS(simd_mode, 17, 16));
+ else if (devinfo->is_g4x)
+ return desc | SET_BITS(msg_type, 15, 12);
+ else
+ return (desc | SET_BITS(return_format, 13, 12) |
+ SET_BITS(msg_type, 15, 14));
+}
void brw_urb_WRITE(struct brw_codegen *p,
struct brw_reg dest,
brw_inst_set_dp_read_target_cache(devinfo, insn, target_cache);
}
-void
-brw_set_sampler_message(struct brw_codegen *p,
- brw_inst *inst,
- unsigned binding_table_index,
- unsigned sampler,
- unsigned msg_type,
- unsigned response_length,
- unsigned msg_length,
- unsigned header_present,
- unsigned simd_mode,
- unsigned return_format)
-{
- const struct gen_device_info *devinfo = p->devinfo;
-
- brw_set_desc(p, inst, brw_message_desc(
- devinfo, msg_length, response_length, header_present));
-
- const unsigned opcode = brw_inst_opcode(devinfo, inst);
- if (opcode == BRW_OPCODE_SEND || opcode == BRW_OPCODE_SENDC)
- brw_inst_set_sfid(devinfo, inst, BRW_SFID_SAMPLER);
- brw_inst_set_binding_table_index(devinfo, inst, binding_table_index);
- brw_inst_set_sampler(devinfo, inst, sampler);
- brw_inst_set_sampler_msg_type(devinfo, inst, msg_type);
- if (devinfo->gen >= 5) {
- brw_inst_set_sampler_simd_mode(devinfo, inst, simd_mode);
- } else if (devinfo->gen == 4 && !devinfo->is_g4x) {
- brw_inst_set_sampler_return_format(devinfo, inst, return_format);
- }
-}
-
static void
gen7_set_dp_scratch_message(struct brw_codegen *p,
brw_inst *inst,
gen6_resolve_implied_move(p, &src0, msg_reg_nr);
insn = next_insn(p, BRW_OPCODE_SEND);
+ brw_inst_set_sfid(devinfo, insn, BRW_SFID_SAMPLER);
brw_inst_set_pred_control(devinfo, insn, BRW_PREDICATE_NONE); /* XXX */
/* From the 965 PRM (volume 4, part 1, section 14.2.41):
brw_set_dest(p, insn, dest);
brw_set_src0(p, insn, src0);
- brw_set_sampler_message(p, insn,
- binding_table_index,
- sampler,
- msg_type,
- response_length,
- msg_length,
- header_present,
- simd_mode,
- return_format);
+ brw_set_desc(p, insn,
+ brw_message_desc(devinfo, msg_length, response_length,
+ header_present) |
+ brw_sampler_desc(devinfo, binding_table_index, sampler,
+ msg_type, simd_mode, return_format));
}
/* Adjust the message header's sampler state pointer to
brw_pop_insn_state(p);
/* dst = send(offset, a0.0 | <descriptor>) */
- brw_inst *insn = brw_send_indirect_message(
- p, BRW_SFID_SAMPLER, dst, src, addr, 0);
- brw_set_sampler_message(p, insn,
- 0 /* surface */,
- 0 /* sampler */,
- msg_type,
- inst->size_written / REG_SIZE,
- inst->mlen /* mlen */,
- inst->header_size != 0 /* header */,
- simd_mode,
- return_format);
+ brw_send_indirect_message(
+ p, BRW_SFID_SAMPLER, dst, src, addr,
+ brw_message_desc(devinfo, inst->mlen, inst->size_written / REG_SIZE,
+ inst->header_size) |
+ brw_sampler_desc(devinfo,
+ 0 /* surface */,
+ 0 /* sampler */,
+ msg_type,
+ simd_mode,
+ return_format));
/* visitor knows more than we do about the surface limit required,
* so has already done marking.
brw_inst *send = brw_next_insn(p, BRW_OPCODE_SEND);
brw_inst_set_compression(devinfo, send, false);
+ brw_inst_set_sfid(devinfo, send, BRW_SFID_SAMPLER);
brw_set_dest(p, send, retype(dst, BRW_REGISTER_TYPE_UW));
brw_set_src0(p, send, header);
if (devinfo->gen < 6)
* stored in it.
*/
uint32_t return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;
- brw_set_sampler_message(p, send,
- surf_index,
- 0, /* sampler (unused) */
- msg_type,
- rlen,
- inst->mlen,
- inst->header_size != 0,
- simd_mode,
- return_format);
+ brw_set_desc(p, send,
+ brw_message_desc(devinfo, inst->mlen, rlen, inst->header_size) |
+ brw_sampler_desc(devinfo, surf_index,
+ 0, /* sampler (unused) */
+ msg_type, simd_mode, return_format));
}
void
uint32_t surf_index = index.ud;
brw_inst *send = brw_next_insn(p, BRW_OPCODE_SEND);
+ brw_inst_set_sfid(devinfo, send, BRW_SFID_SAMPLER);
brw_set_dest(p, send, retype(dst, BRW_REGISTER_TYPE_UW));
brw_set_src0(p, send, offset);
- brw_set_sampler_message(p, send,
- surf_index,
- 0, /* LD message ignores sampler unit */
- GEN5_SAMPLER_MESSAGE_SAMPLE_LD,
- rlen,
- mlen,
- false, /* no header */
- simd_mode,
- 0);
+ brw_set_desc(p, send,
+ brw_message_desc(devinfo, mlen, rlen, false) |
+ brw_sampler_desc(devinfo, surf_index,
+ 0, /* LD message ignores sampler unit */
+ GEN5_SAMPLER_MESSAGE_SAMPLE_LD,
+ simd_mode, 0));
} else {
brw_pop_insn_state(p);
/* dst = send(offset, a0.0 | <descriptor>) */
- brw_inst *insn = brw_send_indirect_message(
+ brw_send_indirect_message(
p, BRW_SFID_SAMPLER, retype(dst, BRW_REGISTER_TYPE_UW),
- offset, addr, 0);
- brw_set_sampler_message(p, insn,
- 0 /* surface */,
- 0 /* sampler */,
- GEN5_SAMPLER_MESSAGE_SAMPLE_LD,
- rlen /* rlen */,
- mlen /* mlen */,
- false /* header */,
- simd_mode,
- 0);
+ offset, addr,
+ brw_message_desc(devinfo, mlen, rlen, false) |
+ brw_sampler_desc(devinfo,
+ 0 /* surface */,
+ 0 /* sampler */,
+ GEN5_SAMPLER_MESSAGE_SAMPLE_LD,
+ simd_mode,
+ 0));
}
}
gen6_resolve_implied_move(p, &src, inst->base_mrf);
/* dst = send(offset, a0.0 | <descriptor>) */
- brw_inst *insn = brw_send_indirect_message(
- p, BRW_SFID_SAMPLER, dst, src, addr, 0);
- brw_set_sampler_message(p, insn,
- 0 /* surface */,
- 0 /* sampler */,
- msg_type,
- 1 /* rlen */,
- inst->mlen /* mlen */,
- inst->header_size != 0 /* header */,
- BRW_SAMPLER_SIMD_MODE_SIMD4X2,
- return_format);
+ brw_send_indirect_message(
+ p, BRW_SFID_SAMPLER, dst, src, addr,
+ brw_message_desc(devinfo, inst->mlen, 1, inst->header_size) |
+ brw_sampler_desc(devinfo,
+ 0 /* surface */,
+ 0 /* sampler */,
+ msg_type,
+ BRW_SAMPLER_SIMD_MODE_SIMD4X2,
+ return_format));
/* visitor knows more than we do about the surface limit required,
* so has already done marking.
struct brw_reg surf_index,
struct brw_reg offset)
{
+ const struct gen_device_info *devinfo = p->devinfo;
assert(surf_index.type == BRW_REGISTER_TYPE_UD);
if (surf_index.file == BRW_IMMEDIATE_VALUE) {
brw_inst *insn = brw_next_insn(p, BRW_OPCODE_SEND);
+ brw_inst_set_sfid(devinfo, insn, BRW_SFID_SAMPLER);
brw_set_dest(p, insn, dst);
brw_set_src0(p, insn, offset);
- brw_set_sampler_message(p, insn,
- surf_index.ud,
- 0, /* LD message ignores sampler unit */
- GEN5_SAMPLER_MESSAGE_SAMPLE_LD,
- 1, /* rlen */
- inst->mlen,
- inst->header_size != 0,
- BRW_SAMPLER_SIMD_MODE_SIMD4X2,
- 0);
+ brw_set_desc(p, insn,
+ brw_message_desc(devinfo, inst->mlen, 1, inst->header_size) |
+ brw_sampler_desc(devinfo, surf_index.ud,
+ 0, /* LD message ignores sampler unit */
+ GEN5_SAMPLER_MESSAGE_SAMPLE_LD,
+ BRW_SAMPLER_SIMD_MODE_SIMD4X2, 0));
brw_mark_surface_used(&prog_data->base, surf_index.ud);
/* a0.0 = surf_index & 0xff */
brw_inst *insn_and = brw_next_insn(p, BRW_OPCODE_AND);
- brw_inst_set_exec_size(p->devinfo, insn_and, BRW_EXECUTE_1);
+ brw_inst_set_exec_size(devinfo, insn_and, BRW_EXECUTE_1);
brw_set_dest(p, insn_and, addr);
brw_set_src0(p, insn_and, vec1(retype(surf_index, BRW_REGISTER_TYPE_UD)));
brw_set_src1(p, insn_and, brw_imm_ud(0x0ff));
brw_pop_insn_state(p);
/* dst = send(offset, a0.0 | <descriptor>) */
- brw_inst *insn = brw_send_indirect_message(
- p, BRW_SFID_SAMPLER, dst, offset, addr, 0);
- brw_set_sampler_message(p, insn,
- 0 /* surface */,
- 0 /* sampler */,
- GEN5_SAMPLER_MESSAGE_SAMPLE_LD,
- 1 /* rlen */,
- inst->mlen,
- inst->header_size != 0,
- BRW_SAMPLER_SIMD_MODE_SIMD4X2,
- 0);
+ brw_send_indirect_message(
+ p, BRW_SFID_SAMPLER, dst, offset, addr,
+ brw_message_desc(devinfo, inst->mlen, 1, inst->header_size) |
+ brw_sampler_desc(devinfo,
+ 0 /* surface */,
+ 0 /* sampler */,
+ GEN5_SAMPLER_MESSAGE_SAMPLE_LD,
+ BRW_SAMPLER_SIMD_MODE_SIMD4X2,
+ 0));
}
}