Signed-off-by: Topi Pohjolainen <topi.pohjolai...@intel.com> --- src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 340 ++++++++++++------------ src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp | 28 +- src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h | 110 +------- 3 files changed, 189 insertions(+), 289 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp index 4fc3b7c..0ceb7ed 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp @@ -1030,8 +1030,8 @@ brw_blorp_blit_program::compute_frag_coords() * Then, we need to add the repeating sequence (0, 1, 0, 1, ...) to the * result, since pixels n+1 and n+3 are in the right half of the subspan. */ - emit_add(vec16(retype(X, BRW_REGISTER_TYPE_UW)), - stride(suboffset(R1, 4), 2, 4, 0), brw_imm_v(0x10101010)); + emit(ADD(vec16(retype(X, BRW_REGISTER_TYPE_UW)), + stride(suboffset(R1, 4), 2, 4, 0), brw_imm_v(0x10101010))); /* Similarly, Y coordinates for subspans come from R1.2[31:16] through * R1.5[31:16], so to get pixel Y coordinates we need to start at the 5th @@ -1041,12 +1041,12 @@ brw_blorp_blit_program::compute_frag_coords() * And we need to add the repeating sequence (0, 0, 1, 1, ...), since * pixels n+2 and n+3 are in the bottom half of the subspan. */ - emit_add(vec16(retype(Y, BRW_REGISTER_TYPE_UW)), - stride(suboffset(R1, 5), 2, 4, 0), brw_imm_v(0x11001100)); + emit(ADD(vec16(retype(Y, BRW_REGISTER_TYPE_UW)), + stride(suboffset(R1, 5), 2, 4, 0), brw_imm_v(0x11001100))); /* Move the coordinates to UD registers. */ - emit_mov(vec16(Xp), retype(X, BRW_REGISTER_TYPE_UW)); - emit_mov(vec16(Yp), retype(Y, BRW_REGISTER_TYPE_UW)); + emit(MOV(vec16(Xp), retype(X, BRW_REGISTER_TYPE_UW))); + emit(MOV(vec16(Yp), retype(Y, BRW_REGISTER_TYPE_UW))); SWAP_XY_AND_XPYP(); if (key->persample_msaa_dispatch) { @@ -1062,10 +1062,11 @@ brw_blorp_blit_program::compute_frag_coords() * then copy from it using vstride=1, width=4, hstride=0. */ struct brw_reg t1_uw1 = retype(t1, BRW_REGISTER_TYPE_UW); - emit_mov(vec16(t1_uw1), brw_imm_v(0x3210)); + emit(MOV(vec16(t1_uw1), brw_imm_v(0x3210))); /* Move to UD sample_index register. */ - emit_mov_8(S, stride(t1_uw1, 1, 4, 0)); - emit_mov_8(offset(S, 1), suboffset(stride(t1_uw1, 1, 4, 0), 2)); + emit(MOV(S, stride(t1_uw1, 1, 4, 0)))->force_uncompressed = true; + emit(MOV(offset(S, 1), suboffset(stride(t1_uw1, 1, 4, 0), 2))) + ->force_uncompressed = true; break; } case 8: { @@ -1085,14 +1086,15 @@ brw_blorp_blit_program::compute_frag_coords() struct brw_reg t1_ud1 = vec1(retype(t1, BRW_REGISTER_TYPE_UD)); struct brw_reg t2_uw1 = retype(t2, BRW_REGISTER_TYPE_UW); struct brw_reg r0_ud1 = vec1(retype(R0, BRW_REGISTER_TYPE_UD)); - emit_and(t1_ud1, r0_ud1, brw_imm_ud(0xc0)); - emit_shr(t1_ud1, t1_ud1, brw_imm_ud(5)); - emit_mov(vec16(t2_uw1), brw_imm_v(0x3210)); - emit_add(vec16(S), retype(t1_ud1, BRW_REGISTER_TYPE_UW), - stride(t2_uw1, 1, 4, 0)); - emit_add_8(offset(S, 1), - retype(t1_ud1, BRW_REGISTER_TYPE_UW), - suboffset(stride(t2_uw1, 1, 4, 0), 2)); + emit(AND(t1_ud1, r0_ud1, brw_imm_ud(0xc0))); + emit(SHR(t1_ud1, t1_ud1, brw_imm_ud(5))); + emit(MOV(vec16(t2_uw1), brw_imm_v(0x3210))); + emit(ADD(vec16(S), retype(t1_ud1, BRW_REGISTER_TYPE_UW), + stride(t2_uw1, 1, 4, 0))); + emit(ADD(offset(S, 1), + retype(t1_ud1, BRW_REGISTER_TYPE_UW), + suboffset(stride(t2_uw1, 1, 4, 0), 2))) + ->force_uncompressed = true; break; } default: @@ -1162,21 +1164,21 @@ brw_blorp_blit_program::translate_tiling(bool old_tiled_w, bool new_tiled_w) * X' = (X & ~0b1011) >> 1 | (Y & 0b1) << 2 | X & 0b1 (4) * Y' = (Y & ~0b1) << 1 | (X & 0b1000) >> 2 | (X & 0b10) >> 1 */ - emit_and(t1, X, brw_imm_uw(0xfff4)); /* X & ~0b1011 */ - emit_shr(t1, t1, brw_imm_uw(1)); /* (X & ~0b1011) >> 1 */ - emit_and(t2, Y, brw_imm_uw(1)); /* Y & 0b1 */ - emit_shl(t2, t2, brw_imm_uw(2)); /* (Y & 0b1) << 2 */ - emit_or(t1, t1, t2); /* (X & ~0b1011) >> 1 | (Y & 0b1) << 2 */ - emit_and(t2, X, brw_imm_uw(1)); /* X & 0b1 */ - emit_or(Xp, t1, t2); - emit_and(t1, Y, brw_imm_uw(0xfffe)); /* Y & ~0b1 */ - emit_shl(t1, t1, brw_imm_uw(1)); /* (Y & ~0b1) << 1 */ - emit_and(t2, X, brw_imm_uw(8)); /* X & 0b1000 */ - emit_shr(t2, t2, brw_imm_uw(2)); /* (X & 0b1000) >> 2 */ - emit_or(t1, t1, t2); /* (Y & ~0b1) << 1 | (X & 0b1000) >> 2 */ - emit_and(t2, X, brw_imm_uw(2)); /* X & 0b10 */ - emit_shr(t2, t2, brw_imm_uw(1)); /* (X & 0b10) >> 1 */ - emit_or(Yp, t1, t2); + emit(AND(t1, X, brw_imm_uw(0xfff4))); /* X & ~0b1011 */ + emit(SHR(t1, t1, brw_imm_uw(1))); /* (X & ~0b1011) >> 1 */ + emit(AND(t2, Y, brw_imm_uw(1))); /* Y & 0b1 */ + emit(SHL(t2, t2, brw_imm_uw(2))); /* (Y & 0b1) << 2 */ + emit(OR(t1, t1, t2)); /* (X & ~0b1011) >> 1 | (Y & 0b1) << 2 */ + emit(AND(t2, X, brw_imm_uw(1))); /* X & 0b1 */ + emit(OR(Xp, t1, t2)); + emit(AND(t1, Y, brw_imm_uw(0xfffe))); /* Y & ~0b1 */ + emit(SHL(t1, t1, brw_imm_uw(1))); /* (Y & ~0b1) << 1 */ + emit(AND(t2, X, brw_imm_uw(8))); /* X & 0b1000 */ + emit(SHR(t2, t2, brw_imm_uw(2))); /* (X & 0b1000) >> 2 */ + emit(OR(t1, t1, t2)); /* (Y & ~0b1) << 1 | (X & 0b1000) >> 2 */ + emit(AND(t2, X, brw_imm_uw(2))); /* X & 0b10 */ + emit(SHR(t2, t2, brw_imm_uw(1))); /* (X & 0b10) >> 1 */ + emit(OR(Yp, t1, t2)); SWAP_XY_AND_XPYP(); } else { /* Applying the same logic as above, but in reverse, we obtain the @@ -1185,22 +1187,22 @@ brw_blorp_blit_program::translate_tiling(bool old_tiled_w, bool new_tiled_w) * X' = (X & ~0b101) << 1 | (Y & 0b10) << 2 | (Y & 0b1) << 1 | X & 0b1 * Y' = (Y & ~0b11) >> 1 | (X & 0b100) >> 2 */ - emit_and(t1, X, brw_imm_uw(0xfffa)); /* X & ~0b101 */ - emit_shl(t1, t1, brw_imm_uw(1)); /* (X & ~0b101) << 1 */ - emit_and(t2, Y, brw_imm_uw(2)); /* Y & 0b10 */ - emit_shl(t2, t2, brw_imm_uw(2)); /* (Y & 0b10) << 2 */ - emit_or(t1, t1, t2); /* (X & ~0b101) << 1 | (Y & 0b10) << 2 */ - emit_and(t2, Y, brw_imm_uw(1)); /* Y & 0b1 */ - emit_shl(t2, t2, brw_imm_uw(1)); /* (Y & 0b1) << 1 */ - emit_or(t1, t1, t2); /* (X & ~0b101) << 1 | (Y & 0b10) << 2 - | (Y & 0b1) << 1 */ - emit_and(t2, X, brw_imm_uw(1)); /* X & 0b1 */ - emit_or(Xp, t1, t2); - emit_and(t1, Y, brw_imm_uw(0xfffc)); /* Y & ~0b11 */ - emit_shr(t1, t1, brw_imm_uw(1)); /* (Y & ~0b11) >> 1 */ - emit_and(t2, X, brw_imm_uw(4)); /* X & 0b100 */ - emit_shr(t2, t2, brw_imm_uw(2)); /* (X & 0b100) >> 2 */ - emit_or(Yp, t1, t2); + emit(AND(t1, X, brw_imm_uw(0xfffa))); /* X & ~0b101 */ + emit(SHL(t1, t1, brw_imm_uw(1))); /* (X & ~0b101) << 1 */ + emit(AND(t2, Y, brw_imm_uw(2))); /* Y & 0b10 */ + emit(SHL(t2, t2, brw_imm_uw(2))); /* (Y & 0b10) << 2 */ + emit(OR(t1, t1, t2)); /* (X & ~0b101) << 1 | (Y & 0b10) << 2 */ + emit(AND(t2, Y, brw_imm_uw(1))); /* Y & 0b1 */ + emit(SHL(t2, t2, brw_imm_uw(1))); /* (Y & 0b1) << 1 */ + emit(OR(t1, t1, t2)); /* (X & ~0b101) << 1 | (Y & 0b10) << 2 + | (Y & 0b1) << 1 */ + emit(AND(t2, X, brw_imm_uw(1))); /* X & 0b1 */ + emit(OR(Xp, t1, t2)); + emit(AND(t1, Y, brw_imm_uw(0xfffc))); /* Y & ~0b11 */ + emit(SHR(t1, t1, brw_imm_uw(1))); /* (Y & ~0b11) >> 1 */ + emit(AND(t2, X, brw_imm_uw(4))); /* X & 0b100 */ + emit(SHR(t2, t2, brw_imm_uw(2))); /* (X & 0b100) >> 2 */ + emit(OR(Yp, t1, t2)); SWAP_XY_AND_XPYP(); } } @@ -1240,23 +1242,23 @@ brw_blorp_blit_program::encode_msaa(unsigned num_samples, * where X' = (X & ~0b1) << 1 | (S & 0b1) << 1 | (X & 0b1) * Y' = (Y & ~0b1) << 1 | (S & 0b10) | (Y & 0b1) */ - emit_and(t1, X, brw_imm_uw(0xfffe)); /* X & ~0b1 */ + emit(AND(t1, X, brw_imm_uw(0xfffe))); /* X & ~0b1 */ if (!s_is_zero) { - emit_and(t2, S, brw_imm_uw(1)); /* S & 0b1 */ - emit_or(t1, t1, t2); /* (X & ~0b1) | (S & 0b1) */ + emit(AND(t2, S, brw_imm_uw(1))); /* S & 0b1 */ + emit(OR(t1, t1, t2)); /* (X & ~0b1) | (S & 0b1) */ } - emit_shl(t1, t1, brw_imm_uw(1)); /* (X & ~0b1) << 1 + emit(SHL(t1, t1, brw_imm_uw(1))); /* (X & ~0b1) << 1 | (S & 0b1) << 1 */ - emit_and(t2, X, brw_imm_uw(1)); /* X & 0b1 */ - emit_or(Xp, t1, t2); - emit_and(t1, Y, brw_imm_uw(0xfffe)); /* Y & ~0b1 */ - emit_shl(t1, t1, brw_imm_uw(1)); /* (Y & ~0b1) << 1 */ + emit(AND(t2, X, brw_imm_uw(1))); /* X & 0b1 */ + emit(OR(Xp, t1, t2)); + emit(AND(t1, Y, brw_imm_uw(0xfffe))); /* Y & ~0b1 */ + emit(SHL(t1, t1, brw_imm_uw(1))); /* (Y & ~0b1) << 1 */ if (!s_is_zero) { - emit_and(t2, S, brw_imm_uw(2)); /* S & 0b10 */ - emit_or(t1, t1, t2); /* (Y & ~0b1) << 1 | (S & 0b10) */ + emit(AND(t2, S, brw_imm_uw(2))); /* S & 0b10 */ + emit(OR(t1, t1, t2)); /* (Y & ~0b1) << 1 | (S & 0b10) */ } - emit_and(t2, Y, brw_imm_uw(1)); /* Y & 0b1 */ - emit_or(Yp, t1, t2); + emit(AND(t2, Y, brw_imm_uw(1))); /* Y & 0b1 */ + emit(OR(Yp, t1, t2)); break; case 8: /* encode_msaa(8, IMS, X, Y, S) = (X', Y', 0) @@ -1264,26 +1266,26 @@ brw_blorp_blit_program::encode_msaa(unsigned num_samples, * | (X & 0b1) * Y' = (Y & ~0b1) << 1 | (S & 0b10) | (Y & 0b1) */ - emit_and(t1, X, brw_imm_uw(0xfffe)); /* X & ~0b1 */ - emit_shl(t1, t1, brw_imm_uw(2)); /* (X & ~0b1) << 2 */ + emit(AND(t1, X, brw_imm_uw(0xfffe))); /* X & ~0b1 */ + emit(SHL(t1, t1, brw_imm_uw(2))); /* (X & ~0b1) << 2 */ if (!s_is_zero) { - emit_and(t2, S, brw_imm_uw(4)); /* S & 0b100 */ - emit_or(t1, t1, t2); /* (X & ~0b1) << 2 | (S & 0b100) */ - emit_and(t2, S, brw_imm_uw(1)); /* S & 0b1 */ - emit_shl(t2, t2, brw_imm_uw(1)); /* (S & 0b1) << 1 */ - emit_or(t1, t1, t2); /* (X & ~0b1) << 2 | (S & 0b100) - | (S & 0b1) << 1 */ + emit(AND(t2, S, brw_imm_uw(4))); /* S & 0b100 */ + emit(OR(t1, t1, t2)); /* (X & ~0b1) << 2 | (S & 0b100) */ + emit(AND(t2, S, brw_imm_uw(1))); /* S & 0b1 */ + emit(SHL(t2, t2, brw_imm_uw(1))); /* (S & 0b1) << 1 */ + emit(OR(t1, t1, t2)); /* (X & ~0b1) << 2 | (S & 0b100) + | (S & 0b1) << 1 */ } - emit_and(t2, X, brw_imm_uw(1)); /* X & 0b1 */ - emit_or(Xp, t1, t2); - emit_and(t1, Y, brw_imm_uw(0xfffe)); /* Y & ~0b1 */ - emit_shl(t1, t1, brw_imm_uw(1)); /* (Y & ~0b1) << 1 */ + emit(AND(t2, X, brw_imm_uw(1))); /* X & 0b1 */ + emit(OR(Xp, t1, t2)); + emit(AND(t1, Y, brw_imm_uw(0xfffe))); /* Y & ~0b1 */ + emit(SHL(t1, t1, brw_imm_uw(1))); /* (Y & ~0b1) << 1 */ if (!s_is_zero) { - emit_and(t2, S, brw_imm_uw(2)); /* S & 0b10 */ - emit_or(t1, t1, t2); /* (Y & ~0b1) << 1 | (S & 0b10) */ + emit(AND(t2, S, brw_imm_uw(2))); /* S & 0b10 */ + emit(OR(t1, t1, t2)); /* (Y & ~0b1) << 1 | (S & 0b10) */ } - emit_and(t2, Y, brw_imm_uw(1)); /* Y & 0b1 */ - emit_or(Yp, t1, t2); + emit(AND(t2, Y, brw_imm_uw(1))); /* Y & 0b1 */ + emit(OR(Yp, t1, t2)); break; } SWAP_XY_AND_XPYP(); @@ -1329,18 +1331,18 @@ brw_blorp_blit_program::decode_msaa(unsigned num_samples, * Y' = (Y & ~0b11) >> 1 | (Y & 0b1) * S = (Y & 0b10) | (X & 0b10) >> 1 */ - emit_and(t1, X, brw_imm_uw(0xfffc)); /* X & ~0b11 */ - emit_shr(t1, t1, brw_imm_uw(1)); /* (X & ~0b11) >> 1 */ - emit_and(t2, X, brw_imm_uw(1)); /* X & 0b1 */ - emit_or(Xp, t1, t2); - emit_and(t1, Y, brw_imm_uw(0xfffc)); /* Y & ~0b11 */ - emit_shr(t1, t1, brw_imm_uw(1)); /* (Y & ~0b11) >> 1 */ - emit_and(t2, Y, brw_imm_uw(1)); /* Y & 0b1 */ - emit_or(Yp, t1, t2); - emit_and(t1, Y, brw_imm_uw(2)); /* Y & 0b10 */ - emit_and(t2, X, brw_imm_uw(2)); /* X & 0b10 */ - emit_shr(t2, t2, brw_imm_uw(1)); /* (X & 0b10) >> 1 */ - emit_or(S, t1, t2); + emit(AND(t1, X, brw_imm_uw(0xfffc))); /* X & ~0b11 */ + emit(SHR(t1, t1, brw_imm_uw(1))); /* (X & ~0b11) >> 1 */ + emit(AND(t2, X, brw_imm_uw(1))); /* X & 0b1 */ + emit(OR(Xp, t1, t2)); + emit(AND(t1, Y, brw_imm_uw(0xfffc))); /* Y & ~0b11 */ + emit(SHR(t1, t1, brw_imm_uw(1))); /* (Y & ~0b11) >> 1 */ + emit(AND(t2, Y, brw_imm_uw(1))); /* Y & 0b1 */ + emit(OR(Yp, t1, t2)); + emit(AND(t1, Y, brw_imm_uw(2))); /* Y & 0b10 */ + emit(AND(t2, X, brw_imm_uw(2))); /* X & 0b10 */ + emit(SHR(t2, t2, brw_imm_uw(1))); /* (X & 0b10) >> 1 */ + emit(OR(S, t1, t2)); break; case 8: /* decode_msaa(8, IMS, X, Y, 0) = (X', Y', S) @@ -1348,20 +1350,20 @@ brw_blorp_blit_program::decode_msaa(unsigned num_samples, * Y' = (Y & ~0b11) >> 1 | (Y & 0b1) * S = (X & 0b100) | (Y & 0b10) | (X & 0b10) >> 1 */ - emit_and(t1, X, brw_imm_uw(0xfff8)); /* X & ~0b111 */ - emit_shr(t1, t1, brw_imm_uw(2)); /* (X & ~0b111) >> 2 */ - emit_and(t2, X, brw_imm_uw(1)); /* X & 0b1 */ - emit_or(Xp, t1, t2); - emit_and(t1, Y, brw_imm_uw(0xfffc)); /* Y & ~0b11 */ - emit_shr(t1, t1, brw_imm_uw(1)); /* (Y & ~0b11) >> 1 */ - emit_and(t2, Y, brw_imm_uw(1)); /* Y & 0b1 */ - emit_or(Yp, t1, t2); - emit_and(t1, X, brw_imm_uw(4)); /* X & 0b100 */ - emit_and(t2, Y, brw_imm_uw(2)); /* Y & 0b10 */ - emit_or(t1, t1, t2); /* (X & 0b100) | (Y & 0b10) */ - emit_and(t2, X, brw_imm_uw(2)); /* X & 0b10 */ - emit_shr(t2, t2, brw_imm_uw(1)); /* (X & 0b10) >> 1 */ - emit_or(S, t1, t2); + emit(AND(t1, X, brw_imm_uw(0xfff8))); /* X & ~0b111 */ + emit(SHR(t1, t1, brw_imm_uw(2))); /* (X & ~0b111) >> 2 */ + emit(AND(t2, X, brw_imm_uw(1))); /* X & 0b1 */ + emit(OR(Xp, t1, t2)); + emit(AND(t1, Y, brw_imm_uw(0xfffc))); /* Y & ~0b11 */ + emit(SHR(t1, t1, brw_imm_uw(1))); /* (Y & ~0b11) >> 1 */ + emit(AND(t2, Y, brw_imm_uw(1))); /* Y & 0b1 */ + emit(OR(Yp, t1, t2)); + emit(AND(t1, X, brw_imm_uw(4))); /* X & 0b100 */ + emit(AND(t2, Y, brw_imm_uw(2))); /* Y & 0b10 */ + emit(OR(t1, t1, t2)); /* (X & 0b100) | (Y & 0b10) */ + emit(AND(t2, X, brw_imm_uw(2))); /* X & 0b10 */ + emit(SHR(t2, t2, brw_imm_uw(1))); /* (X & 0b10) >> 1 */ + emit(OR(S, t1, t2)); break; } s_is_zero = false; @@ -1383,24 +1385,24 @@ brw_blorp_blit_program::translate_dst_to_src() struct brw_reg Yp_f = retype(Yp, BRW_REGISTER_TYPE_F); /* Move the UD coordinates to float registers. */ - emit_mov(Xp_f, X); - emit_mov(Yp_f, Y); + emit(MOV(Xp_f, X)); + emit(MOV(Yp_f, Y)); /* Scale and offset */ - emit_mul(X_f, Xp_f, x_transform.multiplier); - emit_mul(Y_f, Yp_f, y_transform.multiplier); - emit_add(X_f, X_f, x_transform.offset); - emit_add(Y_f, Y_f, y_transform.offset); + emit(MUL(X_f, Xp_f, x_transform.multiplier)); + emit(MUL(Y_f, Yp_f, y_transform.multiplier)); + emit(ADD(X_f, X_f, x_transform.offset)); + emit(ADD(Y_f, Y_f, y_transform.offset)); if (key->blit_scaled && key->blend) { /* Translate coordinates to lay out the samples in a rectangular grid * roughly corresponding to sample locations. */ - emit_mul(X_f, X_f, brw_imm_f(key->x_scale)); - emit_mul(Y_f, Y_f, brw_imm_f(key->y_scale)); + emit(MUL(X_f, X_f, brw_imm_f(key->x_scale))); + emit(MUL(Y_f, Y_f, brw_imm_f(key->y_scale))); /* Adjust coordinates so that integers represent pixel centers rather * than pixel edges. */ - emit_add(X_f, X_f, brw_imm_f(-0.5)); - emit_add(Y_f, Y_f, brw_imm_f(-0.5)); + emit(ADD(X_f, X_f, brw_imm_f(-0.5))); + emit(ADD(Y_f, Y_f, brw_imm_f(-0.5))); /* Clamp the X, Y texture coordinates to properly handle the sampling of * texels on texture edges. @@ -1412,21 +1414,21 @@ brw_blorp_blit_program::translate_dst_to_src() /* Store the fractional parts to be used as bilinear interpolation * coefficients. */ - emit_frc(x_frac, X_f); - emit_frc(y_frac, Y_f); + emit(FRC(x_frac, X_f)); + emit(FRC(y_frac, Y_f)); /* Round the float coordinates down to nearest integer */ - emit_rndd(Xp_f, X_f); - emit_rndd(Yp_f, Y_f); - emit_mul(X_f, Xp_f, brw_imm_f(1 / key->x_scale)); - emit_mul(Y_f, Yp_f, brw_imm_f(1 / key->y_scale)); + emit(RNDD(Xp_f, X_f)); + emit(RNDD(Yp_f, Y_f)); + emit(MUL(X_f, Xp_f, brw_imm_f(1 / key->x_scale))); + emit(MUL(Y_f, Yp_f, brw_imm_f(1 / key->y_scale))); SWAP_XY_AND_XPYP(); } else if (!key->bilinear_filter) { /* Round the float coordinates down to nearest integer by moving to * UD registers. */ - emit_mov(Xp, X_f); - emit_mov(Yp, Y_f); + emit(MOV(Xp, X_f)); + emit(MOV(Yp, Y_f)); SWAP_XY_AND_XPYP(); } } @@ -1458,10 +1460,10 @@ brw_blorp_blit_program::single_to_blend() * that maxe up a pixel). So we need to multiply our X and Y coordinates * each by 2 and then add 1. */ - emit_shl(t1, X, brw_imm_w(1)); - emit_shl(t2, Y, brw_imm_w(1)); - emit_add(Xp, t1, brw_imm_w(1)); - emit_add(Yp, t2, brw_imm_w(1)); + emit(SHL(t1, X, brw_imm_w(1))); + emit(SHL(t2, Y, brw_imm_w(1))); + emit(ADD(Xp, t1, brw_imm_w(1))); + emit(ADD(Yp, t2, brw_imm_w(1))); SWAP_XY_AND_XPYP(); } @@ -1528,7 +1530,7 @@ brw_blorp_blit_program::manual_blend_average(unsigned num_samples) s_is_zero = true; } else { s_is_zero = false; - emit_mov(vec16(S), brw_imm_ud(i)); + emit(MOV(vec16(S), brw_imm_ud(i))); } texel_fetch(texture_data[stack_depth++]); @@ -1547,7 +1549,8 @@ brw_blorp_blit_program::manual_blend_average(unsigned num_samples) * Since we have already sampled from sample 0, all we need to do is * skip the remaining fetches and averaging if MCS is zero. */ - emit_cmp_if(BRW_CONDITIONAL_NZ, mcs_data, brw_imm_ud(0)); + emit_cmp(BRW_CONDITIONAL_NZ, mcs_data, brw_imm_ud(0)); + emit(BRW_OPCODE_IF); } /* Do count_trailing_one_bits(i) times */ @@ -1573,14 +1576,14 @@ brw_blorp_blit_program::manual_blend_average(unsigned num_samples) /* Scale the result down by a factor of num_samples */ /* TODO: should use a smaller loop bound for non-RGBA formats */ for (int j = 0; j < 4; ++j) { - emit_mul(offset(texture_data[0], 2*j), - offset(vec8(texture_data[0]), 2*j), - brw_imm_f(1.0/num_samples)); + emit(MUL(offset(texture_data[0], 2*j), + offset(vec8(texture_data[0]), 2*j), + brw_imm_f(1.0/num_samples))); } } if (key->tex_layout == INTEL_MSAA_LAYOUT_CMS) - emit_endif(); + emit(BRW_OPCODE_ENDIF); } void @@ -1607,12 +1610,12 @@ brw_blorp_blit_program::manual_blend_bilinear(unsigned num_samples) s_is_zero = false; /* Compute pixel coordinates */ - emit_add(vec16(x_sample_coords), Xp_f, - brw_imm_f((float)(i & 0x1) * (1.0 / key->x_scale))); - emit_add(vec16(y_sample_coords), Yp_f, - brw_imm_f((float)((i >> 1) & 0x1) * (1.0 / key->y_scale))); - emit_mov(vec16(X), x_sample_coords); - emit_mov(vec16(Y), y_sample_coords); + emit(ADD(vec16(x_sample_coords), Xp_f, + brw_imm_f((float)(i & 0x1) * (1.0 / key->x_scale)))); + emit(ADD(vec16(y_sample_coords), Yp_f, + brw_imm_f((float)((i >> 1) & 0x1) * (1.0 / key->y_scale)))); + emit(MOV(vec16(X), x_sample_coords)); + emit(MOV(vec16(Y), y_sample_coords)); /* The MCS value we fetch has to match up with the pixel that we're * sampling from. Since we sample from different pixels in each @@ -1646,31 +1649,32 @@ brw_blorp_blit_program::manual_blend_bilinear(unsigned num_samples) * | 6 | 7 | | 7 | 1 | * --------- --------- */ - emit_frc(vec16(t1_f), x_sample_coords); - emit_frc(vec16(t2_f), y_sample_coords); - emit_mul(vec16(t1_f), t1_f, brw_imm_f(key->x_scale)); - emit_mul(vec16(t2_f), t2_f, brw_imm_f(key->x_scale * key->y_scale)); - emit_add(vec16(t1_f), t1_f, t2_f); - emit_mov(vec16(S), t1_f); + emit(FRC(vec16(t1_f), x_sample_coords)); + emit(FRC(vec16(t2_f), y_sample_coords)); + emit(MUL(vec16(t1_f), t1_f, brw_imm_f(key->x_scale))); + emit(MUL(vec16(t2_f), t2_f, brw_imm_f(key->x_scale * key->y_scale))); + emit(ADD(vec16(t1_f), t1_f, t2_f)); + emit(MOV(vec16(S), t1_f)); if (num_samples == 8) { /* Map the sample index to a sample number */ - emit_cmp_if(BRW_CONDITIONAL_L, S, brw_imm_d(4)); + emit_cmp(BRW_CONDITIONAL_L, S, brw_imm_d(4)); + emit(BRW_OPCODE_IF); { - emit_mov(vec16(t2), brw_imm_d(5)); + emit(MOV(vec16(t2), brw_imm_d(5))); emit_if_eq_mov(S, 1, vec16(t2), 2); emit_if_eq_mov(S, 2, vec16(t2), 4); emit_if_eq_mov(S, 3, vec16(t2), 6); } - emit_else(); + emit(BRW_OPCODE_ELSE); { - emit_mov(vec16(t2), brw_imm_d(0)); + emit(MOV(vec16(t2), brw_imm_d(0))); emit_if_eq_mov(S, 5, vec16(t2), 3); emit_if_eq_mov(S, 6, vec16(t2), 7); emit_if_eq_mov(S, 7, vec16(t2), 1); } - emit_endif(); - emit_mov(vec16(S), t2); + emit(BRW_OPCODE_ENDIF); + emit(MOV(vec16(S), t2)); } texel_fetch(texture_data[i]); } @@ -1682,17 +1686,17 @@ brw_blorp_blit_program::manual_blend_bilinear(unsigned num_samples) * the color components. */ for (int k = 0; k < 8; k += 2) - emit_lrp(vec8(SAMPLE(index - 1, k)), + emit(LRP(vec8(SAMPLE(index - 1, k)), x_frac, vec8(SAMPLE(index, k)), - vec8(SAMPLE(index - 1, k))); + vec8(SAMPLE(index - 1, k)))); index -= 2; } for (int k = 0; k < 8; k += 2) - emit_lrp(vec8(SAMPLE(0, k)), + emit(LRP(vec8(SAMPLE(0, k)), y_frac, vec8(SAMPLE(2, k)), - vec8(SAMPLE(0, k))); + vec8(SAMPLE(0, k)))); #undef SAMPLE } @@ -1810,23 +1814,23 @@ brw_blorp_blit_program::texture_lookup(struct brw_reg dst, switch (args[arg]) { case SAMPLER_MESSAGE_ARG_U_FLOAT: if (key->bilinear_filter) - emit_mov(retype(mrf, BRW_REGISTER_TYPE_F), - retype(X, BRW_REGISTER_TYPE_F)); + emit(MOV(retype(mrf, BRW_REGISTER_TYPE_F), + retype(X, BRW_REGISTER_TYPE_F))); else - emit_mov(retype(mrf, BRW_REGISTER_TYPE_F), X); + emit(MOV(retype(mrf, BRW_REGISTER_TYPE_F), X)); break; case SAMPLER_MESSAGE_ARG_V_FLOAT: if (key->bilinear_filter) - emit_mov(retype(mrf, BRW_REGISTER_TYPE_F), - retype(Y, BRW_REGISTER_TYPE_F)); + emit(MOV(retype(mrf, BRW_REGISTER_TYPE_F), + retype(Y, BRW_REGISTER_TYPE_F))); else - emit_mov(retype(mrf, BRW_REGISTER_TYPE_F), Y); + emit(MOV(retype(mrf, BRW_REGISTER_TYPE_F), Y)); break; case SAMPLER_MESSAGE_ARG_U_INT: - emit_mov(mrf, X); + emit(MOV(mrf, X)); break; case SAMPLER_MESSAGE_ARG_V_INT: - emit_mov(mrf, Y); + emit(MOV(mrf, Y)); break; case SAMPLER_MESSAGE_ARG_SI_INT: /* Note: on Gen7, this code may be reached with s_is_zero==true @@ -1835,14 +1839,14 @@ brw_blorp_blit_program::texture_lookup(struct brw_reg dst, * appropriate message register. */ if (s_is_zero) - emit_mov(mrf, brw_imm_ud(0)); + emit(MOV(mrf, brw_imm_ud(0))); else - emit_mov(mrf, S); + emit(MOV(mrf, S)); break; case SAMPLER_MESSAGE_ARG_MCS_INT: switch (key->tex_layout) { case INTEL_MSAA_LAYOUT_CMS: - emit_mov(mrf, mcs_data); + emit(MOV(mrf, mcs_data)); break; case INTEL_MSAA_LAYOUT_IMS: /* When sampling from an IMS surface, MCS data is not relevant, @@ -1858,7 +1862,7 @@ brw_blorp_blit_program::texture_lookup(struct brw_reg dst, } break; case SAMPLER_MESSAGE_ARG_ZERO_INT: - emit_mov(mrf, brw_imm_ud(0)); + emit(MOV(mrf, brw_imm_ud(0))); break; } mrf.nr += 2; @@ -1890,16 +1894,16 @@ brw_blorp_blit_program::render_target_write() bool use_header = key->use_kill; if (use_header) { /* Copy R0/1 to MRF */ - emit_mov(retype(mrf_rt_write, BRW_REGISTER_TYPE_UD), - retype(R0, BRW_REGISTER_TYPE_UD)); + emit(MOV(retype(mrf_rt_write, BRW_REGISTER_TYPE_UD), + retype(R0, BRW_REGISTER_TYPE_UD))); mrf_offset += 2; } /* Copy texture data to MRFs */ for (int i = 0; i < 4; ++i) { /* E.g. mov(16) m2.0<1>:f r2.0<8;8,1>:f { Align1, H1 } */ - emit_mov(offset(mrf_rt_write, mrf_offset), - offset(vec8(texture_data[0]), 2*i)); + emit(MOV(offset(mrf_rt_write, mrf_offset), + offset(vec8(texture_data[0]), 2*i))); mrf_offset += 2; } diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp index 38969d8..cd98423 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp @@ -26,14 +26,14 @@ #include "brw_blorp.h" brw_blorp_eu_emitter::brw_blorp_eu_emitter(struct brw_context *brw) - : mem_ctx(ralloc_context(NULL)), c(rzalloc(mem_ctx, struct brw_wm_compile)), - generator(brw, c, NULL, NULL, false) + : fs_emitter(brw, rzalloc(NULL, struct brw_wm_compile), 16), + generator(brw, fs_emitter::c, NULL, NULL, false) { } brw_blorp_eu_emitter::~brw_blorp_eu_emitter() { - ralloc_free(mem_ctx); + ralloc_free(fs_emitter::c); } const unsigned * @@ -43,10 +43,11 @@ brw_blorp_eu_emitter::get_program(unsigned *program_size, FILE *dump_file) if (unlikely(INTEL_DEBUG & DEBUG_BLORP)) { fprintf(stderr, "Native code for BLORP blit:\n"); - res = generator.generate_assembly(NULL, &insts, program_size, dump_file); + res = generator.generate_assembly(NULL, &instructions, program_size, + dump_file); fprintf(stderr, "\n"); } else { - res = generator.generate_assembly(NULL, &insts, program_size); + res = generator.generate_assembly(NULL, &instructions, program_size); } return res; @@ -73,9 +74,8 @@ brw_blorp_eu_emitter::emit_kill_if_outside_rect(const struct brw_reg &x, emit_cmp(BRW_CONDITIONAL_L, x, dst_x1)->predicate = BRW_PREDICATE_NORMAL; emit_cmp(BRW_CONDITIONAL_L, y, dst_y1)->predicate = BRW_PREDICATE_NORMAL; - fs_inst *inst = new (mem_ctx) fs_inst(BRW_OPCODE_AND, g1, f0, g1); + fs_inst *inst = emit(BRW_OPCODE_AND, g1, f0, g1); inst->force_writemask_all = true; - insts.push_tail(inst); } void @@ -84,14 +84,12 @@ brw_blorp_eu_emitter::emit_texture_lookup(const struct brw_reg &dst, unsigned base_mrf, unsigned msg_length) { - fs_inst *inst = new (mem_ctx) fs_inst(op, dst, brw_message_reg(base_mrf)); + fs_inst *inst = emit(op, dst, brw_message_reg(base_mrf)); inst->base_mrf = base_mrf; inst->mlen = msg_length; inst->sampler = 0; inst->header_present = false; - - insts.push_tail(inst); } void @@ -100,15 +98,13 @@ brw_blorp_eu_emitter::emit_render_target_write(const struct brw_reg &src0, unsigned msg_length, bool use_header) { - fs_inst *inst = new (mem_ctx) fs_inst(FS_OPCODE_BLORP_FB_WRITE); + fs_inst *inst = emit(FS_OPCODE_BLORP_FB_WRITE); inst->src[0] = src0; inst->base_mrf = msg_reg_nr; inst->mlen = msg_length; inst->header_present = use_header; inst->target = BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX; - - insts.push_tail(inst); } void @@ -119,7 +115,7 @@ brw_blorp_eu_emitter::emit_combine(enum opcode combine_opcode, { assert(combine_opcode == BRW_OPCODE_ADD || combine_opcode == BRW_OPCODE_AVG); - insts.push_tail(new (mem_ctx) fs_inst(combine_opcode, dst, src_1, src_2)); + emit(combine_opcode, dst, src_1, src_2); } fs_inst * @@ -127,10 +123,8 @@ brw_blorp_eu_emitter::emit_cmp(int op, const struct brw_reg &x, const struct brw_reg &y) { - fs_inst *cmp = new (mem_ctx) fs_inst(BRW_OPCODE_CMP, - vec16(brw_null_reg()), x, y); + fs_inst *cmp = emit(BRW_OPCODE_CMP, vec16(brw_null_reg()), x, y); cmp->conditional_mod = op; - insts.push_tail(cmp); return cmp; } diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h index c10695e..4026ca4 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h @@ -27,7 +27,7 @@ #include "brw_context.h" #include "brw_fs.h" -class brw_blorp_eu_emitter +class brw_blorp_eu_emitter : public fs_emitter { protected: explicit brw_blorp_eu_emitter(struct brw_context *brw); @@ -65,9 +65,8 @@ protected: { emit_cmp(op, x, y); - fs_inst *mv = new (mem_ctx) fs_inst(BRW_OPCODE_MOV, dst, src); + fs_inst *mv = emit(MOV(dst, src)); mv->predicate = BRW_PREDICATE_NORMAL; - insts.push_tail(mv); } inline void emit_if_eq_mov(const struct brw_reg &x, unsigned y, @@ -76,114 +75,17 @@ protected: emit_cond_mov(x, brw_imm_d(y), BRW_CONDITIONAL_EQ, dst, brw_imm_d(src)); } - inline void emit_lrp(const struct brw_reg &dst, - const struct brw_reg &src1, - const struct brw_reg &src2, - const struct brw_reg &src3) - { - insts.push_tail( - new (mem_ctx) fs_inst(BRW_OPCODE_LRP, dst, src1, src2, src3)); - } - - inline void emit_mov(const struct brw_reg& dst, const struct brw_reg& src) - { - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_MOV, dst, src)); - } - - inline void emit_mov_8(const struct brw_reg& dst, const struct brw_reg& src) - { - fs_inst *mv = new (mem_ctx) fs_inst(BRW_OPCODE_MOV, dst, src); - mv->force_uncompressed = true; - insts.push_tail(mv); - } - - inline void emit_and(const struct brw_reg& dst, - const struct brw_reg& src1, - const struct brw_reg& src2) - { - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_AND, dst, src1, src2)); - } - - inline void emit_add(const struct brw_reg& dst, - const struct brw_reg& src1, - const struct brw_reg& src2) - { - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_ADD, dst, src1, src2)); - } - - inline void emit_add_8(const struct brw_reg& dst, - const struct brw_reg& src1, - const struct brw_reg& src2) - { - fs_inst *add = new (mem_ctx) fs_inst(BRW_OPCODE_ADD, dst, src1, src2); - add->force_uncompressed = true; - insts.push_tail(add); - } - - inline void emit_mul(const struct brw_reg& dst, - const struct brw_reg& src1, - const struct brw_reg& src2) - { - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_MUL, dst, src1, src2)); - } - - inline void emit_shr(const struct brw_reg& dst, - const struct brw_reg& src1, - const struct brw_reg& src2) - { - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_SHR, dst, src1, src2)); - } - - inline void emit_shl(const struct brw_reg& dst, - const struct brw_reg& src1, - const struct brw_reg& src2) - { - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_SHL, dst, src1, src2)); - } - - inline void emit_or(const struct brw_reg& dst, - const struct brw_reg& src1, - const struct brw_reg& src2) - { - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_OR, dst, src1, src2)); - } - - inline void emit_frc(const struct brw_reg& dst, - const struct brw_reg& src) - { - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_FRC, dst, src)); - } - - inline void emit_rndd(const struct brw_reg& dst, - const struct brw_reg& src) - { - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_RNDD, dst, src)); - } - - inline void emit_cmp_if(int op, - const struct brw_reg &x, - const struct brw_reg &y) - { - emit_cmp(op, x, y); - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_IF)); - } + fs_inst *emit_cmp(int op, const struct brw_reg &x, const struct brw_reg &y); - inline void emit_else(void) +private: + virtual void dump_instruction(backend_instruction *) { - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_ELSE)); } - inline void emit_endif(void) + virtual void invalidate_live_intervals() { - insts.push_tail(new (mem_ctx) fs_inst(BRW_OPCODE_ENDIF)); } -private: - fs_inst *emit_cmp(int op, const struct brw_reg &x, const struct brw_reg &y); - - void *mem_ctx; - struct brw_wm_compile *c; - exec_list insts; fs_generator generator; }; -- 1.8.3.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev