}
void
-gen8_vec4_generator::generate_tex(vec4_instruction *ir, struct brw_reg dst)
+gen8_vec4_generator::generate_tex(vec4_instruction *ir, struct brw_reg dst,
+ struct brw_reg sampler_index)
{
int msg_type = 0;
unreachable("should not get here: invalid VS texture opcode");
}
+ assert(sampler_index.file == BRW_IMMEDIATE_VALUE);
+ assert(sampler_index.type == BRW_REGISTER_TYPE_UD);
+
+ uint32_t sampler = sampler_index.dw1.ud;
+
if (ir->header_present) {
MOV_RAW(retype(brw_message_reg(ir->base_mrf), BRW_REGISTER_TYPE_UD),
retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD));
brw_imm_ud(ir->texture_offset));
}
- if (ir->sampler >= 16) {
+ if (sampler >= 16) {
/* The "Sampler Index" field can only store values between 0 and 15.
* However, we can add an offset to the "Sampler State Pointer"
* field, effectively selecting a different set of 16 samplers.
gen8_instruction *add =
ADD(get_element_ud(brw_message_reg(ir->base_mrf), 3),
get_element_ud(brw_vec8_grf(0, 0), 3),
- brw_imm_ud(16 * (ir->sampler / 16) * sampler_state_size));
+ brw_imm_ud(16 * (sampler / 16) * sampler_state_size));
gen8_set_mask_control(add, BRW_MASK_DISABLE);
}
}
uint32_t surf_index =
- prog_data->base.binding_table.texture_start + ir->sampler;
+ prog_data->base.binding_table.texture_start + sampler;
gen8_instruction *inst = next_inst(BRW_OPCODE_SEND);
gen8_set_dst(brw, inst, dst);
gen8_set_src0(brw, inst, brw_message_reg(ir->base_mrf));
gen8_set_sampler_message(brw, inst,
surf_index,
- ir->sampler % 16,
+ sampler % 16,
msg_type,
1,
ir->mlen,
case SHADER_OPCODE_TXS:
case SHADER_OPCODE_TG4:
case SHADER_OPCODE_TG4_OFFSET:
- generate_tex(ir, dst);
+ /* note: src[0] is unused. */
+ generate_tex(ir, dst, src[1]);
break;
case VS_OPCODE_URB_WRITE: