+/* Sample from the MCS surface attached to this multisample texture. */
+fs_reg
+fs_visitor::emit_mcs_fetch(ir_texture *ir, fs_reg coordinate, int sampler)
+{
+ int reg_width = dispatch_width / 8;
+ fs_reg payload = fs_reg(this, glsl_type::float_type);
+ fs_reg dest = fs_reg(this, glsl_type::uvec4_type);
+ fs_reg next = payload;
+
+ /* parameters are: u, v, r, lod; missing parameters are treated as zero */
+ for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+ emit(MOV(retype(next, BRW_REGISTER_TYPE_D), coordinate));
+ coordinate.reg_offset++;
+ next.reg_offset++;
+ }
+
+ fs_inst *inst = emit(SHADER_OPCODE_TXF_MCS, dest, payload);
+ virtual_grf_sizes[payload.reg] = next.reg_offset;
+ inst->base_mrf = -1;
+ inst->mlen = next.reg_offset * reg_width;
+ inst->header_present = false;
+ inst->regs_written = 4 * reg_width; /* we only care about one reg of response,
+ * but the sampler always writes 4/8
+ */
+ inst->sampler = sampler;
+
+ return dest;
+}
+