Commit ade1db65 authored by Jason Ekstrand's avatar Jason Ekstrand
Browse files

i965/fs: Use the GRF for untyped surface reads

parent 84896659
......@@ -2618,7 +2618,7 @@ brw_set_dp_untyped_surface_read_message(struct brw_compile *p,
void
brw_untyped_surface_read(struct brw_compile *p,
struct brw_reg dest,
struct brw_reg mrf,
struct brw_reg src,
unsigned bind_table_index,
unsigned msg_length,
unsigned response_length)
......@@ -2627,7 +2627,7 @@ brw_untyped_surface_read(struct brw_compile *p,
brw_inst *insn = next_insn(p, BRW_OPCODE_SEND);
brw_set_dest(p, insn, retype(dest, BRW_REGISTER_TYPE_UD));
brw_set_src0(p, insn, retype(mrf, BRW_REGISTER_TYPE_UD));
brw_set_src0(p, insn, retype(src, BRW_REGISTER_TYPE_UD));
brw_set_dp_untyped_surface_read_message(
p, insn, bind_table_index, msg_length, response_length,
brw_inst_access_mode(brw, insn) == BRW_ALIGN_1);
......
......@@ -371,6 +371,7 @@ fs_inst::is_send_from_grf() const
return (opcode == FS_OPCODE_VARYING_PULL_CONSTANT_LOAD_GEN7 ||
opcode == SHADER_OPCODE_SHADER_TIME_ADD ||
opcode == SHADER_OPCODE_UNTYPED_ATOMIC ||
opcode == SHADER_OPCODE_UNTYPED_SURFACE_READ ||
opcode == FS_OPCODE_INTERPOLATE_AT_CENTROID ||
opcode == FS_OPCODE_INTERPOLATE_AT_SAMPLE ||
opcode == FS_OPCODE_INTERPOLATE_AT_SHARED_OFFSET ||
......@@ -775,6 +776,8 @@ fs_inst::regs_read(fs_visitor *v, int arg) const
return payload_count;
} else if (opcode == SHADER_OPCODE_UNTYPED_ATOMIC && arg == 2) {
return payload_count;
} else if (opcode == SHADER_OPCODE_UNTYPED_SURFACE_READ && arg == 1) {
return payload_count;
}
return 1;
......
......@@ -667,7 +667,8 @@ private:
void generate_untyped_surface_read(fs_inst *inst,
struct brw_reg dst,
struct brw_reg surf_index);
struct brw_reg surf_index,
struct brw_reg payload);
bool patch_discard_jumps_to_fb_writes();
......
......@@ -1331,12 +1331,31 @@ fs_generator::generate_untyped_atomic(fs_inst *inst, struct brw_reg dst,
void
fs_generator::generate_untyped_surface_read(fs_inst *inst, struct brw_reg dst,
struct brw_reg surf_index)
struct brw_reg surf_index,
struct brw_reg payload)
{
assert(surf_index.file == BRW_IMMEDIATE_VALUE &&
surf_index.type == BRW_REGISTER_TYPE_UD);
brw_untyped_surface_read(p, dst, brw_message_reg(inst->base_mrf),
brw_push_insn_state(p);
brw_set_default_mask_control(p, BRW_MASK_DISABLE);
brw_set_default_compression_control(p, BRW_COMPRESSION_NONE);
if (dispatch_width == 16)
payload.nr++;
brw_MOV(p, payload, brw_imm_ud(0u));
if (fp->UsesKill) {
brw_MOV(p, get_element_ud(payload, 7), brw_flag_reg(0, 1));
} else {
brw_MOV(p, get_element_ud(payload, 7),
retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UD));
}
brw_pop_insn_state(p);
brw_untyped_surface_read(p, dst, payload,
surf_index.dw1.ud,
inst->mlen, dispatch_width / 8);
......@@ -1734,7 +1753,7 @@ fs_generator::generate_code(exec_list *instructions)
break;
case SHADER_OPCODE_UNTYPED_SURFACE_READ:
generate_untyped_surface_read(inst, dst, src[0]);
generate_untyped_surface_read(inst, dst, src[0], src[1]);
break;
case FS_OPCODE_SET_SIMD4X2_OFFSET:
......
......@@ -2589,35 +2589,18 @@ void
fs_visitor::emit_untyped_surface_read(unsigned surf_index, fs_reg dst,
fs_reg offset)
{
const unsigned operand_len = dispatch_width / 8;
unsigned mlen = 0;
/* Initialize the sample mask in the message header. */
emit(MOV(brw_uvec_mrf(8, mlen, 0), fs_reg(0u)))
->force_writemask_all = true;
if (fp->UsesKill) {
emit(MOV(brw_uvec_mrf(1, mlen, 7), brw_flag_reg(0, 1)))
->force_writemask_all = true;
} else {
emit(MOV(brw_uvec_mrf(1, mlen, 7),
retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UD)))
->force_writemask_all = true;
}
const unsigned reg_width = dispatch_width / 8;
mlen++;
fs_reg payload = fs_reg(this, glsl_type::uvec2_type);
/* Set the surface read offset. */
emit(MOV(brw_uvec_mrf(dispatch_width, mlen, 0), offset));
mlen += operand_len;
emit(MOV(::offset(payload, 1), offset));
/* Emit the instruction. */
fs_inst *inst = new(mem_ctx)
fs_inst(SHADER_OPCODE_UNTYPED_SURFACE_READ, dst, surf_index);
inst->base_mrf = 0;
inst->mlen = mlen;
fs_inst *inst = emit(SHADER_OPCODE_UNTYPED_SURFACE_READ, dst,
surf_index, payload);
inst->mlen = 1 + reg_width;
inst->header_present = true;
emit(inst);
}
fs_inst *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment