void compute_sample_position(fs_reg dst, fs_reg int_sample_pos);
fs_reg rescale_texcoord(fs_reg coordinate, const glsl_type *coord_type,
bool is_rect, uint32_t sampler, int texunit);
- fs_inst *emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate,
+ fs_inst *emit_texture_gen4(ir_texture *ir, fs_reg dst,
+ fs_reg coordinate, int coord_components,
fs_reg shadow_comp, fs_reg lod, fs_reg lod2,
uint32_t sampler);
- fs_inst *emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
+ fs_inst *emit_texture_gen5(ir_texture *ir, fs_reg dst,
+ fs_reg coordinate, int coord_components,
fs_reg shadow_comp, fs_reg lod, fs_reg lod2,
fs_reg sample_index, uint32_t sampler,
bool has_offset);
- fs_inst *emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
+ fs_inst *emit_texture_gen7(ir_texture *ir, fs_reg dst,
+ fs_reg coordinate, int coord_components,
fs_reg shadow_comp, fs_reg lod, fs_reg lod2,
fs_reg sample_index, fs_reg mcs, fs_reg sampler,
fs_reg offset_value);
unreachable("not reached");
}
- ir_constant_data junk_data;
- ir->coordinate = new(mem_ctx) ir_constant(coordinate_type, &junk_data);
+ int coord_components = coordinate_type->vector_elements;
if (fpi->TexShadow)
shadow_c = offset(coordinate, 2);
fs_inst *inst;
if (brw->gen >= 7) {
- inst = emit_texture_gen7(ir, dst, coordinate, shadow_c, lod, dpdy, sample_index, fs_reg(0u), fs_reg(fpi->TexSrcUnit), texel_offset);
+ inst = emit_texture_gen7(ir, dst, coordinate, coord_components, shadow_c, lod, dpdy, sample_index, fs_reg(0u), fs_reg(fpi->TexSrcUnit), texel_offset);
} else if (brw->gen >= 5) {
- inst = emit_texture_gen5(ir, dst, coordinate, shadow_c, lod, dpdy, sample_index, fpi->TexSrcUnit, false);
+ inst = emit_texture_gen5(ir, dst, coordinate, coord_components, shadow_c, lod, dpdy, sample_index, fpi->TexSrcUnit, false);
} else {
- inst = emit_texture_gen4(ir, dst, coordinate, shadow_c, lod, dpdy, fpi->TexSrcUnit);
+ inst = emit_texture_gen4(ir, dst, coordinate, coord_components, shadow_c, lod, dpdy, fpi->TexSrcUnit);
}
inst->shadow_compare = fpi->TexShadow;
}
fs_inst *
-fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate,
+fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst,
+ fs_reg coordinate, int coord_components,
fs_reg shadow_c, fs_reg lod, fs_reg dPdy,
uint32_t sampler)
{
mlen = 1;
if (shadow_c.file != BAD_FILE) {
- for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+ for (int i = 0; i < coord_components; i++) {
emit(MOV(fs_reg(MRF, base_mrf + mlen + i), coordinate));
coordinate = offset(coordinate, 1);
}
/* gen4's SIMD8 sampler always has the slots for u,v,r present.
* the unused slots must be zeroed.
*/
- for (int i = ir->coordinate->type->vector_elements; i < 3; i++) {
+ for (int i = coord_components; i < 3; i++) {
emit(MOV(fs_reg(MRF, base_mrf + mlen + i), fs_reg(0.0f)));
}
mlen += 3;
emit(MOV(fs_reg(MRF, base_mrf + mlen), shadow_c));
mlen++;
} else if (ir->op == ir_tex) {
- for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+ for (int i = 0; i < coord_components; i++) {
emit(MOV(fs_reg(MRF, base_mrf + mlen + i), coordinate));
coordinate = offset(coordinate, 1);
}
/* zero the others. */
- for (int i = ir->coordinate->type->vector_elements; i<3; i++) {
+ for (int i = coord_components; i<3; i++) {
emit(MOV(fs_reg(MRF, base_mrf + mlen + i), fs_reg(0.0f)));
}
/* gen4's SIMD8 sampler always has the slots for u,v,r present. */
} else if (ir->op == ir_txd) {
fs_reg &dPdx = lod;
- for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+ for (int i = 0; i < coord_components; i++) {
emit(MOV(fs_reg(MRF, base_mrf + mlen + i), coordinate));
coordinate = offset(coordinate, 1);
}
/* the slots for u and v are always present, but r is optional */
- mlen += MAX2(ir->coordinate->type->vector_elements, 2);
+ mlen += MAX2(coord_components, 2);
/* P = u, v, r
* dPdx = dudx, dvdx, drdx
simd16 = true;
assert(ir->op == ir_txb || ir->op == ir_txl || ir->op == ir_txf);
- for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+ for (int i = 0; i < coord_components; i++) {
emit(MOV(fs_reg(MRF, base_mrf + mlen + i * 2, coordinate.type),
coordinate));
coordinate = offset(coordinate, 1);
/* Initialize the rest of u/v/r with 0.0. Empirically, this seems to
* be necessary for TXF (ld), but seems wise to do for all messages.
*/
- for (int i = ir->coordinate->type->vector_elements; i < 3; i++) {
+ for (int i = coord_components; i < 3; i++) {
emit(MOV(fs_reg(MRF, base_mrf + mlen + i * 2), fs_reg(0.0f)));
}
* surprising in the disassembly.
*/
fs_inst *
-fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
+fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst,
+ fs_reg coordinate, int vector_elements,
fs_reg shadow_c, fs_reg lod, fs_reg lod2,
fs_reg sample_index, uint32_t sampler,
bool has_offset)
{
int reg_width = dispatch_width / 8;
bool header_present = false;
- const int vector_elements =
- ir->coordinate ? ir->coordinate->type->vector_elements : 0;
fs_reg message(MRF, 2, BRW_REGISTER_TYPE_F, dispatch_width);
fs_reg msg_coords = message;
}
fs_inst *
-fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
+fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst,
+ fs_reg coordinate, int coord_components,
fs_reg shadow_c, fs_reg lod, fs_reg lod2,
fs_reg sample_index, fs_reg mcs, fs_reg sampler,
fs_reg offset_value)
/* Load dPdx and the coordinate together:
* [hdr], [ref], x, dPdx.x, dPdy.x, y, dPdx.y, dPdy.y, z, dPdx.z, dPdy.z
*/
- for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+ for (int i = 0; i < coord_components; i++) {
emit(MOV(sources[length], coordinate));
coordinate = offset(coordinate, 1);
length++;
emit(MOV(retype(sources[length], BRW_REGISTER_TYPE_D), lod));
length++;
- for (int i = 1; i < ir->coordinate->type->vector_elements; i++) {
+ for (int i = 1; i < coord_components; i++) {
emit(MOV(retype(sources[length], BRW_REGISTER_TYPE_D), coordinate));
coordinate = offset(coordinate, 1);
length++;
/* there is no offsetting for this message; just copy in the integer
* texture coordinates
*/
- for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+ for (int i = 0; i < coord_components; i++) {
emit(MOV(retype(sources[length], BRW_REGISTER_TYPE_D), coordinate));
coordinate = offset(coordinate, 1);
length++;
length++;
}
- if (ir->coordinate->type->vector_elements == 3) { /* r if present */
+ if (coord_components == 3) { /* r if present */
emit(MOV(sources[length], coordinate));
coordinate = offset(coordinate, 1);
length++;
}
/* Set up the coordinate (except for cases where it was done above) */
- if (ir->coordinate && !coordinate_done) {
- for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+ if (!coordinate_done) {
+ for (int i = 0; i < coord_components; i++) {
emit(MOV(sources[length], coordinate));
coordinate = offset(coordinate, 1);
length++;
sampler, texunit);
}
+ int coord_components =
+ ir->coordinate ? ir->coordinate->type->vector_elements : 0;
+
fs_reg shadow_comparitor;
if (ir->shadow_comparitor) {
ir->shadow_comparitor->accept(this);
fs_reg dst = fs_reg(this, glsl_type::get_instance(ir->type->base_type, 4, 1));
if (brw->gen >= 7) {
- inst = emit_texture_gen7(ir, dst, coordinate, shadow_comparitor,
+ inst = emit_texture_gen7(ir, dst, coordinate, coord_components,
+ shadow_comparitor,
lod, lod2, sample_index, mcs, sampler_reg,
offset_value);
} else if (brw->gen >= 5) {
- inst = emit_texture_gen5(ir, dst, coordinate, shadow_comparitor,
+ inst = emit_texture_gen5(ir, dst, coordinate, coord_components,
+ shadow_comparitor,
lod, lod2, sample_index, sampler,
ir->offset != NULL);
} else {
- inst = emit_texture_gen4(ir, dst, coordinate, shadow_comparitor,
- lod, lod2, sampler);
+ inst = emit_texture_gen4(ir, dst, coordinate, coord_components,
+ shadow_comparitor, lod, lod2, sampler);
}
if (offset_value.file == IMM)