From: Francisco Jerez Date: Fri, 29 Nov 2013 02:04:10 +0000 (-0800) Subject: i965/fs: Use offset() in the ARB_fragment_program code. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8797ccf3fa29eb16f20012b0f3e8ff3e647fbec4;p=mesa.git i965/fs: Use offset() in the ARB_fragment_program code. Reviewed-by: Paul Berry --- diff --git a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp index f5faac98957..5a677a7df3c 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_fp.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_fp.cpp @@ -30,13 +30,6 @@ #include "brw_context.h" #include "brw_fs.h" -static fs_reg -regoffset(fs_reg reg, int i) -{ - reg.reg_offset += i; - return reg; -} - void fs_visitor::emit_fp_alu1(enum opcode opcode, const struct prog_instruction *fpi, @@ -44,7 +37,7 @@ fs_visitor::emit_fp_alu1(enum opcode opcode, { for (int i = 0; i < 4; i++) { if (fpi->DstReg.WriteMask & (1 << i)) - emit(opcode, regoffset(dst, i), regoffset(src, i)); + emit(opcode, offset(dst, i), offset(src, i)); } } @@ -55,8 +48,8 @@ fs_visitor::emit_fp_alu2(enum opcode opcode, { for (int i = 0; i < 4; i++) { if (fpi->DstReg.WriteMask & (1 << i)) - emit(opcode, regoffset(dst, i), - regoffset(src0, i), regoffset(src1, i)); + emit(opcode, offset(dst, i), + offset(src0, i), offset(src1, i)); } } @@ -72,8 +65,8 @@ fs_visitor::emit_fp_minmax(const prog_instruction *fpi, for (int i = 0; i < 4; i++) { if (fpi->DstReg.WriteMask & (1 << i)) { - emit_minmax(conditionalmod, regoffset(dst, i), - regoffset(src0, i), regoffset(src1, i)); + emit_minmax(conditionalmod, offset(dst, i), + offset(src0, i), offset(src1, i)); } } } @@ -88,10 +81,10 @@ fs_visitor::emit_fp_sop(uint32_t conditional_mod, if (fpi->DstReg.WriteMask & (1 << i)) { fs_inst *inst; - emit(CMP(reg_null_d, regoffset(src0, i), regoffset(src1, i), + emit(CMP(reg_null_d, offset(src0, i), offset(src1, i), conditional_mod)); - inst = emit(BRW_OPCODE_SEL, regoffset(dst, i), one, fs_reg(0.0f)); + inst = emit(BRW_OPCODE_SEL, offset(dst, i), one, fs_reg(0.0f)); inst->predicate = BRW_PREDICATE_NORMAL; } } @@ -103,7 +96,7 @@ fs_visitor::emit_fp_scalar_write(const struct prog_instruction *fpi, { for (int i = 0; i < 4; i++) { if (fpi->DstReg.WriteMask & (1 << i)) - emit(MOV(regoffset(dst, i), src)); + emit(MOV(offset(dst, i), src)); } } @@ -170,11 +163,11 @@ fs_visitor::emit_fragment_program_code() if (fpi->DstReg.WriteMask & (1 << i)) { fs_inst *inst; - emit(CMP(null, regoffset(src[0], i), fs_reg(0.0f), + emit(CMP(null, offset(src[0], i), fs_reg(0.0f), BRW_CONDITIONAL_L)); - inst = emit(BRW_OPCODE_SEL, regoffset(dst, i), - regoffset(src[1], i), regoffset(src[2], i)); + inst = emit(BRW_OPCODE_SEL, offset(dst, i), + offset(src[1], i), offset(src[2], i)); inst->predicate = BRW_PREDICATE_NORMAL; } } @@ -200,14 +193,14 @@ fs_visitor::emit_fragment_program_code() default: assert(!"not reached"); count = 0; break; } - emit(MUL(acc, regoffset(src[0], 0), regoffset(src[1], 0))); + emit(MUL(acc, offset(src[0], 0), offset(src[1], 0))); for (int i = 1; i < count; i++) { - emit(MUL(mul, regoffset(src[0], i), regoffset(src[1], i))); + emit(MUL(mul, offset(src[0], i), offset(src[1], i))); emit(ADD(acc, acc, mul)); } if (fpi->Opcode == OPCODE_DPH) - emit(ADD(acc, acc, regoffset(src[1], 3))); + emit(ADD(acc, acc, offset(src[1], 3))); emit_fp_scalar_write(fpi, dst, acc); break; @@ -217,13 +210,13 @@ fs_visitor::emit_fragment_program_code() if (fpi->DstReg.WriteMask & WRITEMASK_X) emit(MOV(dst, fs_reg(1.0f))); if (fpi->DstReg.WriteMask & WRITEMASK_Y) { - emit(MUL(regoffset(dst, 1), - regoffset(src[0], 1), regoffset(src[1], 1))); + emit(MUL(offset(dst, 1), + offset(src[0], 1), offset(src[1], 1))); } if (fpi->DstReg.WriteMask & WRITEMASK_Z) - emit(MOV(regoffset(dst, 2), regoffset(src[0], 2))); + emit(MOV(offset(dst, 2), offset(src[0], 2))); if (fpi->DstReg.WriteMask & WRITEMASK_W) - emit(MOV(regoffset(dst, 3), regoffset(src[1], 3))); + emit(MOV(offset(dst, 3), offset(src[1], 3))); break; case OPCODE_EX2: @@ -257,7 +250,7 @@ fs_visitor::emit_fragment_program_code() * undiscarded pixels, and updates just those pixels to be * turned off. */ - fs_inst *cmp = emit(CMP(null, regoffset(src[0], i), fs_reg(0.0f), + fs_inst *cmp = emit(CMP(null, offset(src[0], i), fs_reg(0.0f), BRW_CONDITIONAL_GE)); cmp->predicate = BRW_PREDICATE_NORMAL; cmp->flag_subreg = 1; @@ -286,40 +279,40 @@ fs_visitor::emit_fragment_program_code() * brw_wm_emit.c either. */ if (fpi->DstReg.WriteMask & WRITEMASK_X) - emit(MOV(regoffset(dst, 0), fs_reg(1.0f))); + emit(MOV(offset(dst, 0), fs_reg(1.0f))); if (fpi->DstReg.WriteMask & WRITEMASK_YZ) { fs_inst *inst; - emit(CMP(null, regoffset(src[0], 0), fs_reg(0.0f), + emit(CMP(null, offset(src[0], 0), fs_reg(0.0f), BRW_CONDITIONAL_LE)); if (fpi->DstReg.WriteMask & WRITEMASK_Y) { - emit(MOV(regoffset(dst, 1), regoffset(src[0], 0))); - inst = emit(MOV(regoffset(dst, 1), fs_reg(0.0f))); + emit(MOV(offset(dst, 1), offset(src[0], 0))); + inst = emit(MOV(offset(dst, 1), fs_reg(0.0f))); inst->predicate = BRW_PREDICATE_NORMAL; } if (fpi->DstReg.WriteMask & WRITEMASK_Z) { - emit_math(SHADER_OPCODE_POW, regoffset(dst, 2), - regoffset(src[0], 1), regoffset(src[0], 3)); + emit_math(SHADER_OPCODE_POW, offset(dst, 2), + offset(src[0], 1), offset(src[0], 3)); - inst = emit(MOV(regoffset(dst, 2), fs_reg(0.0f))); + inst = emit(MOV(offset(dst, 2), fs_reg(0.0f))); inst->predicate = BRW_PREDICATE_NORMAL; } } if (fpi->DstReg.WriteMask & WRITEMASK_W) - emit(MOV(regoffset(dst, 3), fs_reg(1.0f))); + emit(MOV(offset(dst, 3), fs_reg(1.0f))); break; case OPCODE_LRP: for (int i = 0; i < 4; i++) { if (fpi->DstReg.WriteMask & (1 << i)) { - fs_reg a = regoffset(src[0], i); - fs_reg y = regoffset(src[1], i); - fs_reg x = regoffset(src[2], i); - emit_lrp(regoffset(dst, i), x, y, a); + fs_reg a = offset(src[0], i); + fs_reg y = offset(src[1], i); + fs_reg x = offset(src[2], i); + emit_lrp(offset(dst, i), x, y, a); } } break; @@ -328,8 +321,8 @@ fs_visitor::emit_fragment_program_code() for (int i = 0; i < 4; i++) { if (fpi->DstReg.WriteMask & (1 << i)) { fs_reg temp = fs_reg(this, glsl_type::float_type); - emit(MUL(temp, regoffset(src[0], i), regoffset(src[1], i))); - emit(ADD(regoffset(dst, i), temp, regoffset(src[2], i))); + emit(MUL(temp, offset(src[0], i), offset(src[1], i))); + emit(ADD(offset(dst, i), temp, offset(src[2], i))); } } break; @@ -367,13 +360,13 @@ fs_visitor::emit_fragment_program_code() case OPCODE_SCS: if (fpi->DstReg.WriteMask & WRITEMASK_X) { - emit_math(SHADER_OPCODE_COS, regoffset(dst, 0), - regoffset(src[0], 0)); + emit_math(SHADER_OPCODE_COS, offset(dst, 0), + offset(src[0], 0)); } if (fpi->DstReg.WriteMask & WRITEMASK_Y) { - emit_math(SHADER_OPCODE_SIN, regoffset(dst, 1), - regoffset(src[0], 1)); + emit_math(SHADER_OPCODE_SIN, offset(dst, 1), + offset(src[0], 1)); } break; @@ -423,16 +416,16 @@ fs_visitor::emit_fragment_program_code() coordinate = fs_reg(this, glsl_type::vec3_type); fs_reg invproj = fs_reg(this, glsl_type::float_type); - emit_math(SHADER_OPCODE_RCP, invproj, regoffset(src[0], 3)); + emit_math(SHADER_OPCODE_RCP, invproj, offset(src[0], 3)); for (int i = 0; i < 3; i++) { - emit(MUL(regoffset(coordinate, i), - regoffset(src[0], i), invproj)); + emit(MUL(offset(coordinate, i), + offset(src[0], i), invproj)); } break; } case OPCODE_TXB: ir = new(mem_ctx) ir_texture(ir_txb); - lod = regoffset(src[0], 3); + lod = offset(src[0], 3); break; default: assert(!"not reached"); @@ -468,13 +461,13 @@ fs_visitor::emit_fragment_program_code() abscoord.negate = false; abscoord.abs = true; emit_minmax(BRW_CONDITIONAL_GE, temp, - regoffset(abscoord, 0), regoffset(abscoord, 1)); + offset(abscoord, 0), offset(abscoord, 1)); emit_minmax(BRW_CONDITIONAL_GE, temp, - temp, regoffset(abscoord, 2)); + temp, offset(abscoord, 2)); emit_math(SHADER_OPCODE_RCP, temp, temp); for (int i = 0; i < 3; i++) { - emit(MUL(regoffset(cubecoord, i), - regoffset(coordinate, i), temp)); + emit(MUL(offset(cubecoord, i), + offset(coordinate, i), temp)); } coordinate = cubecoord; @@ -491,7 +484,7 @@ fs_visitor::emit_fragment_program_code() ir->coordinate = new(mem_ctx) ir_constant(coordinate_type, &junk_data); if (fpi->TexShadow) { - shadow_c = regoffset(coordinate, 2); + shadow_c = offset(coordinate, 2); ir->shadow_comparitor = new(mem_ctx) ir_constant(0.0f); } @@ -532,12 +525,12 @@ fs_visitor::emit_fragment_program_code() int i2 = (i + 2) % 3; fs_reg temp = fs_reg(this, glsl_type::float_type); - fs_reg neg_src1_1 = regoffset(src[1], i1); + fs_reg neg_src1_1 = offset(src[1], i1); neg_src1_1.negate = !neg_src1_1.negate; - emit(MUL(temp, regoffset(src[0], i2), neg_src1_1)); - emit(MUL(regoffset(dst, i), - regoffset(src[0], i1), regoffset(src[1], i2))); - emit(ADD(regoffset(dst, i), regoffset(dst, i), temp)); + emit(MUL(temp, offset(src[0], i2), neg_src1_1)); + emit(MUL(offset(dst, i), + offset(src[0], i1), offset(src[1], i2))); + emit(ADD(offset(dst, i), offset(dst, i), temp)); } } break; @@ -558,8 +551,8 @@ fs_visitor::emit_fragment_program_code() for (int i = 0; i < 4; i++) { if (fpi->DstReg.WriteMask & (1 << i)) { - fs_inst *inst = emit(MOV(regoffset(real_dst, i), - regoffset(dst, i))); + fs_inst *inst = emit(MOV(offset(real_dst, i), + offset(dst, i))); inst->saturate = fpi->SaturateMode; } } @@ -574,7 +567,7 @@ fs_visitor::emit_fragment_program_code() this->current_annotation = "result.depth write"; if (frag_depth.file != BAD_FILE) { fs_reg temp = fs_reg(this, glsl_type::float_type); - emit(MOV(temp, regoffset(frag_depth, 2))); + emit(MOV(temp, offset(frag_depth, 2))); frag_depth = temp; } } @@ -626,9 +619,9 @@ fs_visitor::setup_fp_regs() fp_input_regs[i] = *emit_general_interpolation(ir); if (i == VARYING_SLOT_FOGC) { - emit(MOV(regoffset(fp_input_regs[i], 1), fs_reg(0.0f))); - emit(MOV(regoffset(fp_input_regs[i], 2), fs_reg(0.0f))); - emit(MOV(regoffset(fp_input_regs[i], 3), fs_reg(1.0f))); + emit(MOV(offset(fp_input_regs[i], 1), fs_reg(0.0f))); + emit(MOV(offset(fp_input_regs[i], 2), fs_reg(0.0f))); + emit(MOV(offset(fp_input_regs[i], 3), fs_reg(1.0f))); } break; @@ -716,7 +709,7 @@ fs_visitor::get_fp_src_reg(const prog_src_register *src) result = fs_reg(this, glsl_type::vec4_type); for (int i = 0; i < 4; i++) { - emit(MOV(regoffset(result, i), + emit(MOV(offset(result, i), fs_reg(plist->ParameterValues[src->Index][i].f))); } break; @@ -750,15 +743,15 @@ fs_visitor::get_fp_src_reg(const prog_src_register *src) */ int src_swiz = GET_SWZ(src->Swizzle, i); if (src_swiz == SWIZZLE_ZERO) { - emit(MOV(regoffset(result, i), fs_reg(0.0f))); + emit(MOV(offset(result, i), fs_reg(0.0f))); } else if (src_swiz == SWIZZLE_ONE) { - emit(MOV(regoffset(result, i), + emit(MOV(offset(result, i), negate ? fs_reg(-1.0f) : fs_reg(1.0f))); } else { - fs_reg src = regoffset(unswizzled, src_swiz); + fs_reg src = offset(unswizzled, src_swiz); if (negate) src.negate = !src.negate; - emit(MOV(regoffset(result, i), src)); + emit(MOV(offset(result, i), src)); } } }