aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-06-18 12:07:27 -0700
committerJason Ekstrand <[email protected]>2015-06-30 16:13:48 -0700
commitf7dcc1160331462a071c54ca1067f9e2f57b55be (patch)
treeab471cafed1bd40a479787ed981388ff28a4298e /src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
parent7fcbe141076d18bf0245de1fd589c82f7c543fdf (diff)
i965/fs: Add a builder argument to offset()
Reviewed-by: Topi Pohjolainen <[email protected]> Acked-by: Francisco Jerez <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_fs_visitor.cpp')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_visitor.cpp143
1 files changed, 72 insertions, 71 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 69d3cfa8897..9b91f47d264 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -95,7 +95,7 @@ fs_visitor::emit_texture_gen4(ir_texture_opcode op, fs_reg dst,
if (shadow_c.file != BAD_FILE) {
for (int i = 0; i < coord_components; i++) {
bld.MOV(fs_reg(MRF, base_mrf + mlen + i), coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
}
/* gen4's SIMD8 sampler always has the slots for u,v,r present.
@@ -124,7 +124,7 @@ fs_visitor::emit_texture_gen4(ir_texture_opcode op, fs_reg dst,
} else if (op == ir_tex) {
for (int i = 0; i < coord_components; i++) {
bld.MOV(fs_reg(MRF, base_mrf + mlen + i), coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
}
/* zero the others. */
for (int i = coord_components; i<3; i++) {
@@ -137,7 +137,7 @@ fs_visitor::emit_texture_gen4(ir_texture_opcode op, fs_reg dst,
for (int i = 0; i < coord_components; i++) {
bld.MOV(fs_reg(MRF, base_mrf + mlen + i), coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
}
/* the slots for u and v are always present, but r is optional */
mlen += MAX2(coord_components, 2);
@@ -158,13 +158,13 @@ fs_visitor::emit_texture_gen4(ir_texture_opcode op, fs_reg dst,
*/
for (int i = 0; i < grad_components; i++) {
bld.MOV(fs_reg(MRF, base_mrf + mlen), dPdx);
- dPdx = offset(dPdx, 1);
+ dPdx = offset(dPdx, bld, 1);
}
mlen += MAX2(grad_components, 2);
for (int i = 0; i < grad_components; i++) {
bld.MOV(fs_reg(MRF, base_mrf + mlen), dPdy);
- dPdy = offset(dPdy, 1);
+ dPdy = offset(dPdy, bld, 1);
}
mlen += MAX2(grad_components, 2);
} else if (op == ir_txs) {
@@ -182,7 +182,7 @@ fs_visitor::emit_texture_gen4(ir_texture_opcode op, fs_reg dst,
for (int i = 0; i < coord_components; i++) {
bld.MOV(fs_reg(MRF, base_mrf + mlen + i * 2, coordinate.type),
coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
}
/* Initialize the rest of u/v/r with 0.0. Empirically, this seems to
@@ -232,8 +232,8 @@ fs_visitor::emit_texture_gen4(ir_texture_opcode op, fs_reg dst,
if (simd16) {
for (int i = 0; i < 4; i++) {
bld.MOV(orig_dst, dst);
- orig_dst = offset(orig_dst, 1);
- dst = offset(dst, 2);
+ orig_dst = offset(orig_dst, bld, 1);
+ dst = offset(dst, bld, 2);
}
}
@@ -257,31 +257,31 @@ fs_visitor::emit_texture_gen4_simd16(ir_texture_opcode op, fs_reg dst,
/* Copy the coordinates. */
for (int i = 0; i < vector_elements; i++) {
- bld.MOV(retype(offset(message, i), coordinate.type), coordinate);
- coordinate = offset(coordinate, 1);
+ bld.MOV(retype(offset(message, bld, i), coordinate.type), coordinate);
+ coordinate = offset(coordinate, bld, 1);
}
- fs_reg msg_end = offset(message, vector_elements);
+ fs_reg msg_end = offset(message, bld, vector_elements);
/* Messages other than sample and ld require all three components */
if (vector_elements > 0 && (has_lod || shadow_c.file != BAD_FILE)) {
for (int i = vector_elements; i < 3; i++) {
- bld.MOV(offset(message, i), fs_reg(0.0f));
+ bld.MOV(offset(message, bld, i), fs_reg(0.0f));
}
- msg_end = offset(message, 3);
+ msg_end = offset(message, bld, 3);
}
if (has_lod) {
fs_reg msg_lod = retype(msg_end, op == ir_txf ?
BRW_REGISTER_TYPE_UD : BRW_REGISTER_TYPE_F);
bld.MOV(msg_lod, lod);
- msg_end = offset(msg_lod, 1);
+ msg_end = offset(msg_lod, bld, 1);
}
if (shadow_c.file != BAD_FILE) {
- fs_reg msg_ref = offset(message, 3 + has_lod);
+ fs_reg msg_ref = offset(message, bld, 3 + has_lod);
bld.MOV(msg_ref, shadow_c);
- msg_end = offset(msg_ref, 1);
+ msg_end = offset(msg_ref, bld, 1);
}
enum opcode opcode;
@@ -335,16 +335,16 @@ fs_visitor::emit_texture_gen5(ir_texture_opcode op, fs_reg dst,
}
for (int i = 0; i < vector_elements; i++) {
- bld.MOV(retype(offset(msg_coords, i), coordinate.type), coordinate);
- coordinate = offset(coordinate, 1);
+ bld.MOV(retype(offset(msg_coords, bld, i), coordinate.type), coordinate);
+ coordinate = offset(coordinate, bld, 1);
}
- fs_reg msg_end = offset(msg_coords, vector_elements);
- fs_reg msg_lod = offset(msg_coords, 4);
+ fs_reg msg_end = offset(msg_coords, bld, vector_elements);
+ fs_reg msg_lod = offset(msg_coords, bld, 4);
if (shadow_c.file != BAD_FILE) {
fs_reg msg_shadow = msg_lod;
bld.MOV(msg_shadow, shadow_c);
- msg_lod = offset(msg_shadow, 1);
+ msg_lod = offset(msg_shadow, bld, 1);
msg_end = msg_lod;
}
@@ -355,13 +355,13 @@ fs_visitor::emit_texture_gen5(ir_texture_opcode op, fs_reg dst,
break;
case ir_txb:
bld.MOV(msg_lod, lod);
- msg_end = offset(msg_lod, 1);
+ msg_end = offset(msg_lod, bld, 1);
opcode = FS_OPCODE_TXB;
break;
case ir_txl:
bld.MOV(msg_lod, lod);
- msg_end = offset(msg_lod, 1);
+ msg_end = offset(msg_lod, bld, 1);
opcode = SHADER_OPCODE_TXL;
break;
@@ -378,12 +378,12 @@ fs_visitor::emit_texture_gen5(ir_texture_opcode op, fs_reg dst,
msg_end = msg_lod;
for (int i = 0; i < grad_components; i++) {
bld.MOV(msg_end, lod);
- lod = offset(lod, 1);
- msg_end = offset(msg_end, 1);
+ lod = offset(lod, bld, 1);
+ msg_end = offset(msg_end, bld, 1);
bld.MOV(msg_end, lod2);
- lod2 = offset(lod2, 1);
- msg_end = offset(msg_end, 1);
+ lod2 = offset(lod2, bld, 1);
+ msg_end = offset(msg_end, bld, 1);
}
opcode = SHADER_OPCODE_TXD;
@@ -392,31 +392,31 @@ fs_visitor::emit_texture_gen5(ir_texture_opcode op, fs_reg dst,
case ir_txs:
msg_lod = retype(msg_end, BRW_REGISTER_TYPE_UD);
bld.MOV(msg_lod, lod);
- msg_end = offset(msg_lod, 1);
+ msg_end = offset(msg_lod, bld, 1);
opcode = SHADER_OPCODE_TXS;
break;
case ir_query_levels:
msg_lod = msg_end;
bld.MOV(retype(msg_lod, BRW_REGISTER_TYPE_UD), fs_reg(0u));
- msg_end = offset(msg_lod, 1);
+ msg_end = offset(msg_lod, bld, 1);
opcode = SHADER_OPCODE_TXS;
break;
case ir_txf:
- msg_lod = offset(msg_coords, 3);
+ msg_lod = offset(msg_coords, bld, 3);
bld.MOV(retype(msg_lod, BRW_REGISTER_TYPE_UD), lod);
- msg_end = offset(msg_lod, 1);
+ msg_end = offset(msg_lod, bld, 1);
opcode = SHADER_OPCODE_TXF;
break;
case ir_txf_ms:
- msg_lod = offset(msg_coords, 3);
+ msg_lod = offset(msg_coords, bld, 3);
/* lod */
bld.MOV(retype(msg_lod, BRW_REGISTER_TYPE_UD), fs_reg(0u));
/* sample index */
- bld.MOV(retype(offset(msg_lod, 1), BRW_REGISTER_TYPE_UD), sample_index);
- msg_end = offset(msg_lod, 2);
+ bld.MOV(retype(offset(msg_lod, bld, 1), BRW_REGISTER_TYPE_UD), sample_index);
+ msg_end = offset(msg_lod, bld, 2);
opcode = SHADER_OPCODE_TXF_CMS;
break;
@@ -526,7 +526,7 @@ fs_visitor::emit_texture_gen7(ir_texture_opcode op, fs_reg dst,
*/
for (int i = 0; i < coord_components; i++) {
bld.MOV(sources[length], coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
length++;
/* For cube map array, the coordinate is (u,v,r,ai) but there are
@@ -534,11 +534,11 @@ fs_visitor::emit_texture_gen7(ir_texture_opcode op, fs_reg dst,
*/
if (i < grad_components) {
bld.MOV(sources[length], lod);
- lod = offset(lod, 1);
+ lod = offset(lod, bld, 1);
length++;
bld.MOV(sources[length], lod2);
- lod2 = offset(lod2, 1);
+ lod2 = offset(lod2, bld, 1);
length++;
}
}
@@ -560,13 +560,13 @@ fs_visitor::emit_texture_gen7(ir_texture_opcode op, fs_reg dst,
*/
bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D), coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
length++;
if (devinfo->gen >= 9) {
if (coord_components >= 2) {
bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D), coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
}
length++;
}
@@ -576,7 +576,7 @@ fs_visitor::emit_texture_gen7(ir_texture_opcode op, fs_reg dst,
for (int i = devinfo->gen >= 9 ? 2 : 1; i < coord_components; i++) {
bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D), coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
length++;
}
@@ -595,7 +595,7 @@ fs_visitor::emit_texture_gen7(ir_texture_opcode op, fs_reg dst,
*/
for (int i = 0; i < coord_components; i++) {
bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D), coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
length++;
}
@@ -609,19 +609,19 @@ fs_visitor::emit_texture_gen7(ir_texture_opcode op, fs_reg dst,
/* More crazy intermixing */
for (int i = 0; i < 2; i++) { /* u, v */
bld.MOV(sources[length], coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
length++;
}
for (int i = 0; i < 2; i++) { /* offu, offv */
bld.MOV(retype(sources[length], BRW_REGISTER_TYPE_D), offset_value);
- offset_value = offset(offset_value, 1);
+ offset_value = offset(offset_value, bld, 1);
length++;
}
if (coord_components == 3) { /* r if present */
bld.MOV(sources[length], coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
length++;
}
@@ -634,7 +634,7 @@ fs_visitor::emit_texture_gen7(ir_texture_opcode op, fs_reg dst,
if (!coordinate_done) {
for (int i = 0; i < coord_components; i++) {
bld.MOV(sources[length], coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
length++;
}
}
@@ -747,8 +747,8 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components,
coordinate = dst;
bld.MUL(dst, src, scale_x);
- dst = offset(dst, 1);
- src = offset(src, 1);
+ dst = offset(dst, bld, 1);
+ src = offset(src, bld, 1);
bld.MUL(dst, src, scale_y);
} else if (is_rect) {
/* On gen6+, the sampler handles the rectangle coordinates
@@ -761,7 +761,7 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components,
for (int i = 0; i < 2; i++) {
if (key_tex->gl_clamp_mask[i] & (1 << sampler)) {
fs_reg chan = coordinate;
- chan = offset(chan, i);
+ chan = offset(chan, bld, i);
set_condmod(BRW_CONDITIONAL_GE,
bld.emit(BRW_OPCODE_SEL, chan, chan, fs_reg(0.0f)));
@@ -786,7 +786,7 @@ fs_visitor::rescale_texcoord(fs_reg coordinate, int coord_components,
for (int i = 0; i < MIN2(coord_components, 3); i++) {
if (key_tex->gl_clamp_mask[i] & (1 << sampler)) {
fs_reg chan = coordinate;
- chan = offset(chan, i);
+ chan = offset(chan, bld, i);
set_saturate(true, bld.MOV(chan, chan));
}
}
@@ -808,7 +808,7 @@ fs_visitor::emit_mcs_fetch(fs_reg coordinate, int components, fs_reg sampler)
for (int i = 0; i < components; i++) {
sources[i] = vgrf(glsl_type::float_type);
bld.MOV(retype(sources[i], BRW_REGISTER_TYPE_D), coordinate);
- coordinate = offset(coordinate, 1);
+ coordinate = offset(coordinate, bld, 1);
}
bld.LOAD_PAYLOAD(payload, sources, components, 0);
@@ -854,7 +854,7 @@ fs_visitor::emit_texture(ir_texture_opcode op,
for (int i=0; i<4; i++) {
bld.MOV(res, fs_reg(swiz == SWIZZLE_ZERO ? 0.0f : 1.0f));
- res = offset(res, 1);
+ res = offset(res, bld, 1);
}
return;
}
@@ -908,7 +908,7 @@ fs_visitor::emit_texture(ir_texture_opcode op,
/* fixup #layers for cube map arrays */
if (op == ir_txs && is_cube_array) {
- fs_reg depth = offset(dst, 2);
+ fs_reg depth = offset(dst, bld, 2);
fs_reg fixed_depth = vgrf(glsl_type::int_type);
bld.emit(SHADER_OPCODE_INT_QUOTIENT, fixed_depth, depth, fs_reg(6));
@@ -918,7 +918,7 @@ fs_visitor::emit_texture(ir_texture_opcode op,
if (i == 2) {
fixed_payload[i] = fixed_depth;
} else {
- fixed_payload[i] = offset(dst, i);
+ fixed_payload[i] = offset(dst, bld, i);
}
}
bld.LOAD_PAYLOAD(dst, fixed_payload, components, 0);
@@ -953,7 +953,7 @@ fs_visitor::emit_gen6_gather_wa(uint8_t wa, fs_reg dst)
bld.ASR(dst, dst, fs_reg(32 - width));
}
- dst = offset(dst, 1);
+ dst = offset(dst, bld, 1);
}
}
@@ -990,7 +990,7 @@ fs_visitor::swizzle_result(ir_texture_opcode op, int dest_components,
{
if (op == ir_query_levels) {
/* # levels is in .w */
- this->result = offset(orig_val, 3);
+ this->result = offset(orig_val, bld, 3);
return;
}
@@ -1011,15 +1011,15 @@ fs_visitor::swizzle_result(ir_texture_opcode op, int dest_components,
for (int i = 0; i < 4; i++) {
int swiz = GET_SWZ(key_tex->swizzles[sampler], i);
fs_reg l = swizzled_result;
- l = offset(l, i);
+ l = offset(l, bld, i);
if (swiz == SWIZZLE_ZERO) {
bld.MOV(l, fs_reg(0.0f));
} else if (swiz == SWIZZLE_ONE) {
bld.MOV(l, fs_reg(1.0f));
} else {
- bld.MOV(l, offset(orig_val,
- GET_SWZ(key_tex->swizzles[sampler], i)));
+ bld.MOV(l, offset(orig_val, bld,
+ GET_SWZ(key_tex->swizzles[sampler], i)));
}
}
this->result = swizzled_result;
@@ -1316,14 +1316,14 @@ fs_visitor::emit_interpolation_setup_gen4()
if (devinfo->has_pln && dispatch_width == 16) {
for (unsigned i = 0; i < 2; i++) {
- abld.half(i).ADD(half(offset(delta_xy, i), 0),
+ abld.half(i).ADD(half(offset(delta_xy, abld, i), 0),
half(this->pixel_x, i), xstart);
- abld.half(i).ADD(half(offset(delta_xy, i), 1),
+ abld.half(i).ADD(half(offset(delta_xy, abld, i), 1),
half(this->pixel_y, i), ystart);
}
} else {
- abld.ADD(offset(delta_xy, 0), this->pixel_x, xstart);
- abld.ADD(offset(delta_xy, 1), this->pixel_y, ystart);
+ abld.ADD(offset(delta_xy, abld, 0), this->pixel_x, xstart);
+ abld.ADD(offset(delta_xy, abld, 1), this->pixel_y, ystart);
}
abld = bld.annotate("compute pos.w and 1/pos.w");
@@ -1421,7 +1421,7 @@ fs_visitor::setup_color_payload(fs_reg *dst, fs_reg color, unsigned components,
fs_reg tmp = vgrf(glsl_type::vec4_type);
assert(color.type == BRW_REGISTER_TYPE_F);
for (unsigned i = 0; i < components; i++) {
- inst = bld.MOV(offset(tmp, i), offset(color, i));
+ inst = bld.MOV(offset(tmp, bld, i), offset(color, bld, i));
inst->saturate = true;
}
color = tmp;
@@ -1430,10 +1430,10 @@ fs_visitor::setup_color_payload(fs_reg *dst, fs_reg color, unsigned components,
if (exec_size < dispatch_width) {
unsigned half_idx = use_2nd_half ? 1 : 0;
for (unsigned i = 0; i < components; i++)
- dst[i] = half(offset(color, i), half_idx);
+ dst[i] = half(offset(color, bld, i), half_idx);
} else {
for (unsigned i = 0; i < components; i++)
- dst[i] = offset(color, i);
+ dst[i] = offset(color, bld, i);
}
}
@@ -1481,7 +1481,7 @@ fs_visitor::emit_alpha_test()
BRW_CONDITIONAL_NEQ);
} else {
/* RT0 alpha */
- fs_reg color = offset(outputs[0], 3);
+ fs_reg color = offset(outputs[0], bld, 3);
/* f0.1 &= func(color, ref) */
cmp = abld.CMP(bld.null_reg_f(), color, fs_reg(key->alpha_test_ref),
@@ -1558,7 +1558,8 @@ fs_visitor::emit_single_fb_write(const fs_builder &bld,
* alpha-testing, alpha-to-coverage, and so on.
*/
if (this->outputs[0].file != BAD_FILE)
- setup_color_payload(&sources[length + 3], offset(this->outputs[0], 3),
+ setup_color_payload(&sources[length + 3],
+ offset(this->outputs[0], bld, 3),
1, exec_size, false);
length += 4;
} else if (color1.file == BAD_FILE) {
@@ -1694,7 +1695,7 @@ fs_visitor::emit_fb_writes()
fs_reg src0_alpha;
if (devinfo->gen >= 6 && key->replicate_alpha && target != 0)
- src0_alpha = offset(outputs[0], 3);
+ src0_alpha = offset(outputs[0], bld, 3);
inst = emit_single_fb_write(abld, this->outputs[target], reg_undef,
src0_alpha,
@@ -1787,7 +1788,7 @@ void fs_visitor::compute_clip_distance(gl_clip_plane *clip_planes)
abld.MUL(output, outputs[clip_vertex], u);
for (int j = 1; j < 4; j++) {
u.reg = userplane[i].reg + j;
- abld.MAD(output, output, offset(outputs[clip_vertex], j), u);
+ abld.MAD(output, output, offset(outputs[clip_vertex], bld, j), u);
}
}
}
@@ -1904,13 +1905,13 @@ fs_visitor::emit_urb_writes()
*/
for (int i = 0; i < 4; i++) {
reg = fs_reg(GRF, alloc.allocate(1), outputs[varying].type);
- src = offset(this->outputs[varying], i);
+ src = offset(this->outputs[varying], bld, i);
set_saturate(true, bld.MOV(reg, src));
sources[length++] = reg;
}
} else {
for (int i = 0; i < 4; i++)
- sources[length++] = offset(this->outputs[varying], i);
+ sources[length++] = offset(this->outputs[varying], bld, i);
}
break;
}