diff options
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_fs.cpp')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs.cpp | 572 |
1 files changed, 272 insertions, 300 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 8b3f5ad..5426925 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -177,6 +177,23 @@ type_size(const struct glsl_type *type) } } +void +fs_visitor::fail(const char *format, ...) +{ + if (!failed) { + failed = true; + + if (INTEL_DEBUG & DEBUG_WM) { + fprintf(stderr, "FS compile failed: "); + + va_list va; + va_start(va, format); + vfprintf(stderr, format, va); + va_end(va); + } + } +} + /** * Returns how many MRFs an FS opcode will write over. * @@ -382,60 +399,32 @@ fs_visitor::setup_uniform_values(int loc, const glsl_type *type) void fs_visitor::setup_builtin_uniform_values(ir_variable *ir) { - const struct gl_builtin_uniform_desc *statevar = NULL; - - for (unsigned int i = 0; _mesa_builtin_uniform_desc[i].name; i++) { - statevar = &_mesa_builtin_uniform_desc[i]; - if (strcmp(ir->name, _mesa_builtin_uniform_desc[i].name) == 0) - break; - } - - if (!statevar->name) { - this->fail = true; - printf("Failed to find builtin uniform `%s'\n", ir->name); - return; - } - - int array_count; - if (ir->type->is_array()) { - array_count = ir->type->length; - } else { - array_count = 1; - } + const ir_state_slot *const slots = ir->state_slots; + assert(ir->state_slots != NULL); - for (int a = 0; a < array_count; a++) { - for (unsigned int i = 0; i < statevar->num_elements; i++) { - struct gl_builtin_uniform_element *element = &statevar->elements[i]; - int tokens[STATE_LENGTH]; - - memcpy(tokens, element->tokens, sizeof(element->tokens)); - if (ir->type->is_array()) { - tokens[1] = a; - } - - /* This state reference has already been setup by ir_to_mesa, - * but we'll get the same index back here. - */ - int index = _mesa_add_state_reference(this->fp->Base.Parameters, - (gl_state_index *)tokens); + for (unsigned int i = 0; i < ir->num_state_slots; i++) { + /* This state reference has already been setup by ir_to_mesa, but we'll + * get the same index back here. + */ + int index = _mesa_add_state_reference(this->fp->Base.Parameters, + (gl_state_index *)slots[i].tokens); - /* Add each of the unique swizzles of the element as a - * parameter. This'll end up matching the expected layout of - * the array/matrix/structure we're trying to fill in. - */ - int last_swiz = -1; - for (unsigned int i = 0; i < 4; i++) { - int swiz = GET_SWZ(element->swizzle, i); - if (swiz == last_swiz) - break; - last_swiz = swiz; + /* Add each of the unique swizzles of the element as a parameter. + * This'll end up matching the expected layout of the + * array/matrix/structure we're trying to fill in. + */ + int last_swiz = -1; + for (unsigned int j = 0; j < 4; j++) { + int swiz = GET_SWZ(slots[i].swizzle, j); + if (swiz == last_swiz) + break; + last_swiz = swiz; - c->prog_data.param_convert[c->prog_data.nr_params] = - PARAM_NO_CONVERT; - this->param_index[c->prog_data.nr_params] = index; - this->param_offset[c->prog_data.nr_params] = swiz; - c->prog_data.nr_params++; - } + c->prog_data.param_convert[c->prog_data.nr_params] = + PARAM_NO_CONVERT; + this->param_index[c->prog_data.nr_params] = index; + this->param_offset[c->prog_data.nr_params] = swiz; + c->prog_data.nr_params++; } } } @@ -451,15 +440,15 @@ fs_visitor::emit_fragcoord_interpolation(ir_variable *ir) /* gl_FragCoord.x */ if (ir->pixel_center_integer) { - emit(fs_inst(BRW_OPCODE_MOV, wpos, this->pixel_x)); + emit(BRW_OPCODE_MOV, wpos, this->pixel_x); } else { - emit(fs_inst(BRW_OPCODE_ADD, wpos, this->pixel_x, fs_reg(0.5f))); + emit(BRW_OPCODE_ADD, wpos, this->pixel_x, fs_reg(0.5f)); } wpos.reg_offset++; /* gl_FragCoord.y */ if (!flip && ir->pixel_center_integer) { - emit(fs_inst(BRW_OPCODE_MOV, wpos, this->pixel_y)); + emit(BRW_OPCODE_MOV, wpos, this->pixel_y); } else { fs_reg pixel_y = this->pixel_y; float offset = (ir->pixel_center_integer ? 0.0 : 0.5); @@ -469,22 +458,22 @@ fs_visitor::emit_fragcoord_interpolation(ir_variable *ir) offset += c->key.drawable_height - 1.0; } - emit(fs_inst(BRW_OPCODE_ADD, wpos, pixel_y, fs_reg(offset))); + emit(BRW_OPCODE_ADD, wpos, pixel_y, fs_reg(offset)); } wpos.reg_offset++; /* gl_FragCoord.z */ if (intel->gen >= 6) { - emit(fs_inst(BRW_OPCODE_MOV, wpos, - fs_reg(brw_vec8_grf(c->source_depth_reg, 0)))); + emit(BRW_OPCODE_MOV, wpos, + fs_reg(brw_vec8_grf(c->source_depth_reg, 0))); } else { - emit(fs_inst(FS_OPCODE_LINTERP, wpos, this->delta_x, this->delta_y, - interp_reg(FRAG_ATTRIB_WPOS, 2))); + emit(FS_OPCODE_LINTERP, wpos, this->delta_x, this->delta_y, + interp_reg(FRAG_ATTRIB_WPOS, 2)); } wpos.reg_offset++; /* gl_FragCoord.w: Already set up in emit_interpolation */ - emit(fs_inst(BRW_OPCODE_MOV, wpos, this->wpos_w)); + emit(BRW_OPCODE_MOV, wpos, this->wpos_w); return reg; } @@ -503,7 +492,7 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) if (ir->type->is_array()) { array_elements = ir->type->length; if (array_elements == 0) { - this->fail = true; + fail("dereferenced array '%s' has length 0\n", ir->name); } type = ir->type->fields.array; } else { @@ -523,37 +512,33 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) continue; } - if (c->key.flat_shade && (location == FRAG_ATTRIB_COL0 || - location == FRAG_ATTRIB_COL1)) { + bool is_gl_Color = + location == FRAG_ATTRIB_COL0 || location == FRAG_ATTRIB_COL1; + + if (c->key.flat_shade && is_gl_Color) { /* Constant interpolation (flat shading) case. The SF has * handed us defined values in only the constant offset * field of the setup reg. */ - for (unsigned int c = 0; c < type->vector_elements; c++) { - struct brw_reg interp = interp_reg(location, c); + for (unsigned int k = 0; k < type->vector_elements; k++) { + struct brw_reg interp = interp_reg(location, k); interp = suboffset(interp, 3); - emit(fs_inst(FS_OPCODE_CINTERP, attr, fs_reg(interp))); + emit(FS_OPCODE_CINTERP, attr, fs_reg(interp)); attr.reg_offset++; } } else { /* Perspective interpolation case. */ - for (unsigned int c = 0; c < type->vector_elements; c++) { - struct brw_reg interp = interp_reg(location, c); - emit(fs_inst(FS_OPCODE_LINTERP, - attr, - this->delta_x, - this->delta_y, - fs_reg(interp))); + for (unsigned int k = 0; k < type->vector_elements; k++) { + struct brw_reg interp = interp_reg(location, k); + emit(FS_OPCODE_LINTERP, attr, + this->delta_x, this->delta_y, fs_reg(interp)); attr.reg_offset++; } - if (intel->gen < 6) { + if (intel->gen < 6 && !(is_gl_Color && c->key.linear_color)) { attr.reg_offset -= type->vector_elements; - for (unsigned int c = 0; c < type->vector_elements; c++) { - emit(fs_inst(BRW_OPCODE_MUL, - attr, - attr, - this->pixel_w)); + for (unsigned int k = 0; k < type->vector_elements; k++) { + emit(BRW_OPCODE_MUL, attr, attr, this->pixel_w); attr.reg_offset++; } } @@ -572,28 +557,21 @@ fs_visitor::emit_frontfacing_interpolation(ir_variable *ir) /* The frontfacing comes in as a bit in the thread payload. */ if (intel->gen >= 6) { - emit(fs_inst(BRW_OPCODE_ASR, - *reg, - fs_reg(retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_D)), - fs_reg(15))); - emit(fs_inst(BRW_OPCODE_NOT, - *reg, - *reg)); - emit(fs_inst(BRW_OPCODE_AND, - *reg, - *reg, - fs_reg(1))); + emit(BRW_OPCODE_ASR, *reg, + fs_reg(retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_D)), + fs_reg(15)); + emit(BRW_OPCODE_NOT, *reg, *reg); + emit(BRW_OPCODE_AND, *reg, *reg, fs_reg(1)); } else { struct brw_reg r1_6ud = retype(brw_vec1_grf(1, 6), BRW_REGISTER_TYPE_UD); /* bit 31 is "primitive is back face", so checking < (1 << 31) gives * us front face */ - fs_inst *inst = emit(fs_inst(BRW_OPCODE_CMP, - *reg, - fs_reg(r1_6ud), - fs_reg(1u << 31))); + fs_inst *inst = emit(BRW_OPCODE_CMP, *reg, + fs_reg(r1_6ud), + fs_reg(1u << 31)); inst->conditional_mod = BRW_CONDITIONAL_L; - emit(fs_inst(BRW_OPCODE_AND, *reg, *reg, fs_reg(1u))); + emit(BRW_OPCODE_AND, *reg, *reg, fs_reg(1u)); } return reg; @@ -628,11 +606,11 @@ fs_visitor::emit_math(fs_opcodes opcode, fs_reg dst, fs_reg src) src.abs || src.negate)) { fs_reg expanded = fs_reg(this, glsl_type::float_type); - emit(fs_inst(BRW_OPCODE_MOV, expanded, src)); + emit(BRW_OPCODE_MOV, expanded, src); src = expanded; } - fs_inst *inst = emit(fs_inst(opcode, dst, src)); + fs_inst *inst = emit(opcode, dst, src); if (intel->gen < 6) { inst->base_mrf = 2; @@ -658,20 +636,20 @@ fs_visitor::emit_math(fs_opcodes opcode, fs_reg dst, fs_reg src0, fs_reg src1) */ if (src0.file == UNIFORM || src0.abs || src0.negate) { fs_reg expanded = fs_reg(this, glsl_type::float_type); - emit(fs_inst(BRW_OPCODE_MOV, expanded, src0)); + emit(BRW_OPCODE_MOV, expanded, src0); src0 = expanded; } if (src1.file == UNIFORM || src1.abs || src1.negate) { fs_reg expanded = fs_reg(this, glsl_type::float_type); - emit(fs_inst(BRW_OPCODE_MOV, expanded, src1)); + emit(BRW_OPCODE_MOV, expanded, src1); src1 = expanded; } - inst = emit(fs_inst(opcode, dst, src0, src1)); + inst = emit(opcode, dst, src0, src1); } else { - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + 1), src1)); - inst = emit(fs_inst(opcode, dst, src0, reg_null_f)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + 1), src1); + inst = emit(opcode, dst, src0, reg_null_f); inst->base_mrf = base_mrf; inst->mlen = 2; @@ -788,7 +766,7 @@ fs_visitor::try_emit_saturate(ir_expression *ir) fs_reg src = this->result; this->result = fs_reg(this, ir->type); - fs_inst *inst = emit(fs_inst(BRW_OPCODE_MOV, this->result, src)); + fs_inst *inst = emit(BRW_OPCODE_MOV, this->result, src); inst->saturate = true; return true; @@ -834,9 +812,8 @@ fs_visitor::visit(ir_expression *ir) ir->operands[operand]->accept(this); if (this->result.file == BAD_FILE) { ir_print_visitor v; - printf("Failed to get tree for expression operand:\n"); + fail("Failed to get tree for expression operand:\n"); ir->operands[operand]->accept(&v); - this->fail = true; } op[operand] = this->result; @@ -859,7 +836,7 @@ fs_visitor::visit(ir_expression *ir) /* Note that BRW_OPCODE_NOT is not appropriate here, since it is * ones complement of the whole register, not just bit 0. */ - emit(fs_inst(BRW_OPCODE_XOR, this->result, op[0], fs_reg(1))); + emit(BRW_OPCODE_XOR, this->result, op[0], fs_reg(1)); break; case ir_unop_neg: op[0].negate = !op[0].negate; @@ -873,16 +850,16 @@ fs_visitor::visit(ir_expression *ir) case ir_unop_sign: temp = fs_reg(this, ir->type); - emit(fs_inst(BRW_OPCODE_MOV, this->result, fs_reg(0.0f))); + emit(BRW_OPCODE_MOV, this->result, fs_reg(0.0f)); - inst = emit(fs_inst(BRW_OPCODE_CMP, reg_null_f, op[0], fs_reg(0.0f))); + inst = emit(BRW_OPCODE_CMP, reg_null_f, op[0], fs_reg(0.0f)); inst->conditional_mod = BRW_CONDITIONAL_G; - inst = emit(fs_inst(BRW_OPCODE_MOV, this->result, fs_reg(1.0f))); + inst = emit(BRW_OPCODE_MOV, this->result, fs_reg(1.0f)); inst->predicated = true; - inst = emit(fs_inst(BRW_OPCODE_CMP, reg_null_f, op[0], fs_reg(0.0f))); + inst = emit(BRW_OPCODE_CMP, reg_null_f, op[0], fs_reg(0.0f)); inst->conditional_mod = BRW_CONDITIONAL_L; - inst = emit(fs_inst(BRW_OPCODE_MOV, this->result, fs_reg(-1.0f))); + inst = emit(BRW_OPCODE_MOV, this->result, fs_reg(-1.0f)); inst->predicated = true; break; @@ -910,21 +887,21 @@ fs_visitor::visit(ir_expression *ir) break; case ir_unop_dFdx: - emit(fs_inst(FS_OPCODE_DDX, this->result, op[0])); + emit(FS_OPCODE_DDX, this->result, op[0]); break; case ir_unop_dFdy: - emit(fs_inst(FS_OPCODE_DDY, this->result, op[0])); + emit(FS_OPCODE_DDY, this->result, op[0]); break; case ir_binop_add: - emit(fs_inst(BRW_OPCODE_ADD, this->result, op[0], op[1])); + emit(BRW_OPCODE_ADD, this->result, op[0], op[1]); break; case ir_binop_sub: assert(!"not reached: should be handled by ir_sub_to_add_neg"); break; case ir_binop_mul: - emit(fs_inst(BRW_OPCODE_MUL, this->result, op[0], op[1])); + emit(BRW_OPCODE_MUL, this->result, op[0], op[1]); break; case ir_binop_div: assert(!"not reached: should be handled by ir_div_to_mul_rcp"); @@ -946,21 +923,21 @@ fs_visitor::visit(ir_expression *ir) if (intel->gen < 5) temp.type = op[0].type; - inst = emit(fs_inst(BRW_OPCODE_CMP, temp, op[0], op[1])); + inst = emit(BRW_OPCODE_CMP, temp, op[0], op[1]); inst->conditional_mod = brw_conditional_for_comparison(ir->operation); - emit(fs_inst(BRW_OPCODE_AND, this->result, this->result, fs_reg(0x1))); + emit(BRW_OPCODE_AND, this->result, this->result, fs_reg(0x1)); break; case ir_binop_logic_xor: - emit(fs_inst(BRW_OPCODE_XOR, this->result, op[0], op[1])); + emit(BRW_OPCODE_XOR, this->result, op[0], op[1]); break; case ir_binop_logic_or: - emit(fs_inst(BRW_OPCODE_OR, this->result, op[0], op[1])); + emit(BRW_OPCODE_OR, this->result, op[0], op[1]); break; case ir_binop_logic_and: - emit(fs_inst(BRW_OPCODE_AND, this->result, op[0], op[1])); + emit(BRW_OPCODE_AND, this->result, op[0], op[1]); break; case ir_binop_dot: @@ -988,7 +965,7 @@ fs_visitor::visit(ir_expression *ir) case ir_unop_b2f: case ir_unop_b2i: case ir_unop_f2i: - emit(fs_inst(BRW_OPCODE_MOV, this->result, op[0])); + emit(BRW_OPCODE_MOV, this->result, op[0]); break; case ir_unop_f2b: case ir_unop_i2b: @@ -997,42 +974,41 @@ fs_visitor::visit(ir_expression *ir) if (intel->gen < 5) temp.type = op[0].type; - inst = emit(fs_inst(BRW_OPCODE_CMP, temp, op[0], fs_reg(0.0f))); + inst = emit(BRW_OPCODE_CMP, temp, op[0], fs_reg(0.0f)); inst->conditional_mod = BRW_CONDITIONAL_NZ; - inst = emit(fs_inst(BRW_OPCODE_AND, this->result, - this->result, fs_reg(1))); + inst = emit(BRW_OPCODE_AND, this->result, this->result, fs_reg(1)); break; case ir_unop_trunc: - emit(fs_inst(BRW_OPCODE_RNDZ, this->result, op[0])); + emit(BRW_OPCODE_RNDZ, this->result, op[0]); break; case ir_unop_ceil: op[0].negate = !op[0].negate; - inst = emit(fs_inst(BRW_OPCODE_RNDD, this->result, op[0])); + inst = emit(BRW_OPCODE_RNDD, this->result, op[0]); this->result.negate = true; break; case ir_unop_floor: - inst = emit(fs_inst(BRW_OPCODE_RNDD, this->result, op[0])); + inst = emit(BRW_OPCODE_RNDD, this->result, op[0]); break; case ir_unop_fract: - inst = emit(fs_inst(BRW_OPCODE_FRC, this->result, op[0])); + inst = emit(BRW_OPCODE_FRC, this->result, op[0]); break; case ir_unop_round_even: - emit(fs_inst(BRW_OPCODE_RNDE, this->result, op[0])); + emit(BRW_OPCODE_RNDE, this->result, op[0]); break; case ir_binop_min: - inst = emit(fs_inst(BRW_OPCODE_CMP, this->result, op[0], op[1])); + inst = emit(BRW_OPCODE_CMP, this->result, op[0], op[1]); inst->conditional_mod = BRW_CONDITIONAL_L; - inst = emit(fs_inst(BRW_OPCODE_SEL, this->result, op[0], op[1])); + inst = emit(BRW_OPCODE_SEL, this->result, op[0], op[1]); inst->predicated = true; break; case ir_binop_max: - inst = emit(fs_inst(BRW_OPCODE_CMP, this->result, op[0], op[1])); + inst = emit(BRW_OPCODE_CMP, this->result, op[0], op[1]); inst->conditional_mod = BRW_CONDITIONAL_G; - inst = emit(fs_inst(BRW_OPCODE_SEL, this->result, op[0], op[1])); + inst = emit(BRW_OPCODE_SEL, this->result, op[0], op[1]); inst->predicated = true; break; @@ -1041,16 +1017,16 @@ fs_visitor::visit(ir_expression *ir) break; case ir_unop_bit_not: - inst = emit(fs_inst(BRW_OPCODE_NOT, this->result, op[0])); + inst = emit(BRW_OPCODE_NOT, this->result, op[0]); break; case ir_binop_bit_and: - inst = emit(fs_inst(BRW_OPCODE_AND, this->result, op[0], op[1])); + inst = emit(BRW_OPCODE_AND, this->result, op[0], op[1]); break; case ir_binop_bit_xor: - inst = emit(fs_inst(BRW_OPCODE_XOR, this->result, op[0], op[1])); + inst = emit(BRW_OPCODE_XOR, this->result, op[0], op[1]); break; case ir_binop_bit_or: - inst = emit(fs_inst(BRW_OPCODE_OR, this->result, op[0], op[1])); + inst = emit(BRW_OPCODE_OR, this->result, op[0], op[1]); break; case ir_unop_u2f: @@ -1074,7 +1050,7 @@ fs_visitor::emit_assignment_writes(fs_reg &l, fs_reg &r, l.type = brw_type_for_base_type(type); r.type = brw_type_for_base_type(type); - fs_inst *inst = emit(fs_inst(BRW_OPCODE_MOV, l, r)); + fs_inst *inst = emit(BRW_OPCODE_MOV, l, r); inst->predicated = predicated; l.reg_offset++; @@ -1127,7 +1103,7 @@ fs_visitor::visit(ir_assignment *ir) ir->lhs->type->is_vector()) { for (int i = 0; i < ir->lhs->type->vector_elements; i++) { if (ir->write_mask & (1 << i)) { - inst = emit(fs_inst(BRW_OPCODE_MOV, l, r)); + inst = emit(BRW_OPCODE_MOV, l, r); if (ir->condition) inst->predicated = true; r.reg_offset++; @@ -1152,8 +1128,7 @@ fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate) if (ir->shadow_comparitor) { for (int i = 0; i < ir->coordinate->type->vector_elements; i++) { - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen + i), - coordinate)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen + i), coordinate); coordinate.reg_offset++; } /* gen4's SIMD8 sampler always has the slots for u,v,r present. */ @@ -1163,29 +1138,25 @@ fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate) /* There's no plain shadow compare message, so we use shadow * compare with a bias of 0.0. */ - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), - fs_reg(0.0f))); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), fs_reg(0.0f)); mlen++; } else if (ir->op == ir_txb) { ir->lod_info.bias->accept(this); - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), - this->result)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result); mlen++; } else { assert(ir->op == ir_txl); ir->lod_info.lod->accept(this); - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), - this->result)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result); mlen++; } ir->shadow_comparitor->accept(this); - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result); mlen++; } else if (ir->op == ir_tex) { for (int i = 0; i < ir->coordinate->type->vector_elements; i++) { - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen + i), - coordinate)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen + i), coordinate); coordinate.reg_offset++; } /* gen4's SIMD8 sampler always has the slots for u,v,r present. */ @@ -1199,8 +1170,7 @@ fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate) assert(ir->op == ir_txb || ir->op == ir_txl); for (int i = 0; i < ir->coordinate->type->vector_elements; i++) { - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen + i * 2), - coordinate)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen + i * 2), coordinate); coordinate.reg_offset++; } @@ -1209,13 +1179,11 @@ fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate) if (ir->op == ir_txb) { ir->lod_info.bias->accept(this); - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), - this->result)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result); mlen++; } else { ir->lod_info.lod->accept(this); - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), - this->result)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result); mlen++; } @@ -1236,16 +1204,16 @@ fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate) fs_inst *inst = NULL; switch (ir->op) { case ir_tex: - inst = emit(fs_inst(FS_OPCODE_TEX, dst)); + inst = emit(FS_OPCODE_TEX, dst); break; case ir_txb: - inst = emit(fs_inst(FS_OPCODE_TXB, dst)); + inst = emit(FS_OPCODE_TXB, dst); break; case ir_txl: - inst = emit(fs_inst(FS_OPCODE_TXL, dst)); + inst = emit(FS_OPCODE_TXL, dst); break; case ir_txd: - inst = emit(fs_inst(FS_OPCODE_TXD, dst)); + inst = emit(FS_OPCODE_TXD, dst); break; case ir_txf: assert(!"GLSL 1.30 features unsupported"); @@ -1256,7 +1224,7 @@ fs_visitor::emit_texture_gen4(ir_texture *ir, fs_reg dst, fs_reg coordinate) if (simd16) { for (int i = 0; i < 4; i++) { - emit(fs_inst(BRW_OPCODE_MOV, orig_dst, dst)); + emit(BRW_OPCODE_MOV, orig_dst, dst); orig_dst.reg_offset++; dst.reg_offset += 2; } @@ -1280,8 +1248,7 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate) int base_mrf = 1; for (int i = 0; i < ir->coordinate->type->vector_elements; i++) { - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen + i), - coordinate)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen + i), coordinate); coordinate.reg_offset++; } mlen += ir->coordinate->type->vector_elements; @@ -1290,30 +1257,30 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate) mlen = MAX2(mlen, 5); ir->shadow_comparitor->accept(this); - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result); mlen++; } fs_inst *inst = NULL; switch (ir->op) { case ir_tex: - inst = emit(fs_inst(FS_OPCODE_TEX, dst)); + inst = emit(FS_OPCODE_TEX, dst); break; case ir_txb: ir->lod_info.bias->accept(this); mlen = MAX2(mlen, 5); - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result); mlen++; - inst = emit(fs_inst(FS_OPCODE_TXB, dst)); + inst = emit(FS_OPCODE_TXB, dst); break; case ir_txl: ir->lod_info.lod->accept(this); mlen = MAX2(mlen, 5); - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result); mlen++; - inst = emit(fs_inst(FS_OPCODE_TXL, dst)); + inst = emit(FS_OPCODE_TXL, dst); break; case ir_txd: case ir_txf: @@ -1356,14 +1323,14 @@ fs_visitor::visit(ir_texture *ir) } /* Explicitly set up the message header by copying g0 to msg reg m1. */ - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, 1, BRW_REGISTER_TYPE_UD), - fs_reg(GRF, 0, BRW_REGISTER_TYPE_UD))); + emit(BRW_OPCODE_MOV, fs_reg(MRF, 1, BRW_REGISTER_TYPE_UD), + fs_reg(GRF, 0, BRW_REGISTER_TYPE_UD)); /* Then set the offset bits in DWord 2 of the message header. */ - emit(fs_inst(BRW_OPCODE_MOV, - fs_reg(retype(brw_vec1_reg(BRW_MESSAGE_REGISTER_FILE, 1, 2), - BRW_REGISTER_TYPE_UD)), - fs_reg(brw_imm_uw(offset_bits)))); + emit(BRW_OPCODE_MOV, + fs_reg(retype(brw_vec1_reg(BRW_MESSAGE_REGISTER_FILE, 1, 2), + BRW_REGISTER_TYPE_UD)), + fs_reg(brw_imm_uw(offset_bits))); } /* Should be lowered by do_lower_texture_projection */ @@ -1409,10 +1376,10 @@ fs_visitor::visit(ir_texture *ir) fs_reg src = coordinate; coordinate = dst; - emit(fs_inst(BRW_OPCODE_MUL, dst, src, scale_x)); + emit(BRW_OPCODE_MUL, dst, src, scale_x); dst.reg_offset++; src.reg_offset++; - emit(fs_inst(BRW_OPCODE_MUL, dst, src, scale_y)); + emit(BRW_OPCODE_MUL, dst, src, scale_y); } /* Writemasking doesn't eliminate channels on SIMD8 texture @@ -1453,13 +1420,13 @@ fs_visitor::visit(ir_texture *ir) l.reg_offset += i; if (swiz == SWIZZLE_ZERO) { - emit(fs_inst(BRW_OPCODE_MOV, l, fs_reg(0.0f))); + emit(BRW_OPCODE_MOV, l, fs_reg(0.0f)); } else if (swiz == SWIZZLE_ONE) { - emit(fs_inst(BRW_OPCODE_MOV, l, fs_reg(1.0f))); + emit(BRW_OPCODE_MOV, l, fs_reg(1.0f)); } else { fs_reg r = dst; r.reg_offset += GET_SWZ(c->key.tex_swizzles[inst->sampler], i); - emit(fs_inst(BRW_OPCODE_MOV, l, r)); + emit(BRW_OPCODE_MOV, l, r); } } this->result = swizzle_dst; @@ -1500,7 +1467,7 @@ fs_visitor::visit(ir_swizzle *ir) } channel.reg_offset += swiz; - emit(fs_inst(BRW_OPCODE_MOV, result, channel)); + emit(BRW_OPCODE_MOV, result, channel); result.reg_offset++; } } @@ -1512,8 +1479,8 @@ fs_visitor::visit(ir_discard *ir) assert(ir->condition == NULL); /* FINISHME */ - emit(fs_inst(FS_OPCODE_DISCARD_NOT, temp, reg_null_d)); - emit(fs_inst(FS_OPCODE_DISCARD_AND, reg_null_d, temp)); + emit(FS_OPCODE_DISCARD_NOT, temp, reg_null_d); + emit(FS_OPCODE_DISCARD_AND, reg_null_d, temp); kill_emitted = true; } @@ -1539,7 +1506,7 @@ fs_visitor::visit(ir_constant *ir) dst_reg.type = src_reg.type; for (unsigned j = 0; j < size; j++) { - emit(fs_inst(BRW_OPCODE_MOV, dst_reg, src_reg)); + emit(BRW_OPCODE_MOV, dst_reg, src_reg); src_reg.reg_offset++; dst_reg.reg_offset++; } @@ -1554,7 +1521,7 @@ fs_visitor::visit(ir_constant *ir) dst_reg.type = src_reg.type; for (unsigned j = 0; j < size; j++) { - emit(fs_inst(BRW_OPCODE_MOV, dst_reg, src_reg)); + emit(BRW_OPCODE_MOV, dst_reg, src_reg); src_reg.reg_offset++; dst_reg.reg_offset++; } @@ -1565,16 +1532,16 @@ fs_visitor::visit(ir_constant *ir) for (unsigned i = 0; i < size; i++) { switch (ir->type->base_type) { case GLSL_TYPE_FLOAT: - emit(fs_inst(BRW_OPCODE_MOV, dst_reg, fs_reg(ir->value.f[i]))); + emit(BRW_OPCODE_MOV, dst_reg, fs_reg(ir->value.f[i])); break; case GLSL_TYPE_UINT: - emit(fs_inst(BRW_OPCODE_MOV, dst_reg, fs_reg(ir->value.u[i]))); + emit(BRW_OPCODE_MOV, dst_reg, fs_reg(ir->value.u[i])); break; case GLSL_TYPE_INT: - emit(fs_inst(BRW_OPCODE_MOV, dst_reg, fs_reg(ir->value.i[i]))); + emit(BRW_OPCODE_MOV, dst_reg, fs_reg(ir->value.i[i])); break; case GLSL_TYPE_BOOL: - emit(fs_inst(BRW_OPCODE_MOV, dst_reg, fs_reg((int)ir->value.b[i]))); + emit(BRW_OPCODE_MOV, dst_reg, fs_reg((int)ir->value.b[i])); break; default: assert(!"Non-float/uint/int/bool constant"); @@ -1605,40 +1572,39 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir) switch (expr->operation) { case ir_unop_logic_not: - inst = emit(fs_inst(BRW_OPCODE_AND, reg_null_d, op[0], fs_reg(1))); + inst = emit(BRW_OPCODE_AND, reg_null_d, op[0], fs_reg(1)); inst->conditional_mod = BRW_CONDITIONAL_Z; break; case ir_binop_logic_xor: - inst = emit(fs_inst(BRW_OPCODE_XOR, reg_null_d, op[0], op[1])); + inst = emit(BRW_OPCODE_XOR, reg_null_d, op[0], op[1]); inst->conditional_mod = BRW_CONDITIONAL_NZ; break; case ir_binop_logic_or: - inst = emit(fs_inst(BRW_OPCODE_OR, reg_null_d, op[0], op[1])); + inst = emit(BRW_OPCODE_OR, reg_null_d, op[0], op[1]); inst->conditional_mod = BRW_CONDITIONAL_NZ; break; case ir_binop_logic_and: - inst = emit(fs_inst(BRW_OPCODE_AND, reg_null_d, op[0], op[1])); + inst = emit(BRW_OPCODE_AND, reg_null_d, op[0], op[1]); inst->conditional_mod = BRW_CONDITIONAL_NZ; break; case ir_unop_f2b: if (intel->gen >= 6) { - inst = emit(fs_inst(BRW_OPCODE_CMP, reg_null_d, - op[0], fs_reg(0.0f))); + inst = emit(BRW_OPCODE_CMP, reg_null_d, op[0], fs_reg(0.0f)); } else { - inst = emit(fs_inst(BRW_OPCODE_MOV, reg_null_f, op[0])); + inst = emit(BRW_OPCODE_MOV, reg_null_f, op[0]); } inst->conditional_mod = BRW_CONDITIONAL_NZ; break; case ir_unop_i2b: if (intel->gen >= 6) { - inst = emit(fs_inst(BRW_OPCODE_CMP, reg_null_d, op[0], fs_reg(0))); + inst = emit(BRW_OPCODE_CMP, reg_null_d, op[0], fs_reg(0)); } else { - inst = emit(fs_inst(BRW_OPCODE_MOV, reg_null_d, op[0])); + inst = emit(BRW_OPCODE_MOV, reg_null_d, op[0]); } inst->conditional_mod = BRW_CONDITIONAL_NZ; break; @@ -1651,14 +1617,14 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir) case ir_binop_all_equal: case ir_binop_nequal: case ir_binop_any_nequal: - inst = emit(fs_inst(BRW_OPCODE_CMP, reg_null_cmp, op[0], op[1])); + inst = emit(BRW_OPCODE_CMP, reg_null_cmp, op[0], op[1]); inst->conditional_mod = brw_conditional_for_comparison(expr->operation); break; default: assert(!"not reached"); - this->fail = true; + fail("bad cond code\n"); break; } return; @@ -1667,11 +1633,10 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir) ir->accept(this); if (intel->gen >= 6) { - fs_inst *inst = emit(fs_inst(BRW_OPCODE_AND, reg_null_d, - this->result, fs_reg(1))); + fs_inst *inst = emit(BRW_OPCODE_AND, reg_null_d, this->result, fs_reg(1)); inst->conditional_mod = BRW_CONDITIONAL_NZ; } else { - fs_inst *inst = emit(fs_inst(BRW_OPCODE_MOV, reg_null_d, this->result)); + fs_inst *inst = emit(BRW_OPCODE_MOV, reg_null_d, this->result); inst->conditional_mod = BRW_CONDITIONAL_NZ; } } @@ -1700,36 +1665,36 @@ fs_visitor::emit_if_gen6(ir_if *ir) switch (expr->operation) { case ir_unop_logic_not: - inst = emit(fs_inst(BRW_OPCODE_IF, temp, op[0], fs_reg(0))); + inst = emit(BRW_OPCODE_IF, temp, op[0], fs_reg(0)); inst->conditional_mod = BRW_CONDITIONAL_Z; return; case ir_binop_logic_xor: - inst = emit(fs_inst(BRW_OPCODE_IF, reg_null_d, op[0], op[1])); + inst = emit(BRW_OPCODE_IF, reg_null_d, op[0], op[1]); inst->conditional_mod = BRW_CONDITIONAL_NZ; return; case ir_binop_logic_or: temp = fs_reg(this, glsl_type::bool_type); - emit(fs_inst(BRW_OPCODE_OR, temp, op[0], op[1])); - inst = emit(fs_inst(BRW_OPCODE_IF, reg_null_d, temp, fs_reg(0))); + emit(BRW_OPCODE_OR, temp, op[0], op[1]); + inst = emit(BRW_OPCODE_IF, reg_null_d, temp, fs_reg(0)); inst->conditional_mod = BRW_CONDITIONAL_NZ; return; case ir_binop_logic_and: temp = fs_reg(this, glsl_type::bool_type); - emit(fs_inst(BRW_OPCODE_AND, temp, op[0], op[1])); - inst = emit(fs_inst(BRW_OPCODE_IF, reg_null_d, temp, fs_reg(0))); + emit(BRW_OPCODE_AND, temp, op[0], op[1]); + inst = emit(BRW_OPCODE_IF, reg_null_d, temp, fs_reg(0)); inst->conditional_mod = BRW_CONDITIONAL_NZ; return; case ir_unop_f2b: - inst = emit(fs_inst(BRW_OPCODE_IF, reg_null_f, op[0], fs_reg(0))); + inst = emit(BRW_OPCODE_IF, reg_null_f, op[0], fs_reg(0)); inst->conditional_mod = BRW_CONDITIONAL_NZ; return; case ir_unop_i2b: - inst = emit(fs_inst(BRW_OPCODE_IF, reg_null_d, op[0], fs_reg(0))); + inst = emit(BRW_OPCODE_IF, reg_null_d, op[0], fs_reg(0)); inst->conditional_mod = BRW_CONDITIONAL_NZ; return; @@ -1741,15 +1706,15 @@ fs_visitor::emit_if_gen6(ir_if *ir) case ir_binop_all_equal: case ir_binop_nequal: case ir_binop_any_nequal: - inst = emit(fs_inst(BRW_OPCODE_IF, reg_null_d, op[0], op[1])); + inst = emit(BRW_OPCODE_IF, reg_null_d, op[0], op[1]); inst->conditional_mod = brw_conditional_for_comparison(expr->operation); return; default: assert(!"not reached"); - inst = emit(fs_inst(BRW_OPCODE_IF, reg_null_d, op[0], fs_reg(0))); + inst = emit(BRW_OPCODE_IF, reg_null_d, op[0], fs_reg(0)); inst->conditional_mod = BRW_CONDITIONAL_NZ; - this->fail = true; + fail("bad condition\n"); return; } return; @@ -1757,7 +1722,7 @@ fs_visitor::emit_if_gen6(ir_if *ir) ir->condition->accept(this); - fs_inst *inst = emit(fs_inst(BRW_OPCODE_IF, reg_null_d, this->result, fs_reg(0))); + fs_inst *inst = emit(BRW_OPCODE_IF, reg_null_d, this->result, fs_reg(0)); inst->conditional_mod = BRW_CONDITIONAL_NZ; } @@ -1776,7 +1741,7 @@ fs_visitor::visit(ir_if *ir) } else { emit_bool_to_cond_code(ir->condition); - inst = emit(fs_inst(BRW_OPCODE_IF)); + inst = emit(BRW_OPCODE_IF); inst->predicated = true; } @@ -1788,7 +1753,7 @@ fs_visitor::visit(ir_if *ir) } if (!ir->else_instructions.is_empty()) { - emit(fs_inst(BRW_OPCODE_ELSE)); + emit(BRW_OPCODE_ELSE); foreach_iter(exec_list_iterator, iter, ir->else_instructions) { ir_instruction *ir = (ir_instruction *)iter.get(); @@ -1798,7 +1763,7 @@ fs_visitor::visit(ir_if *ir) } } - emit(fs_inst(BRW_OPCODE_ENDIF)); + emit(BRW_OPCODE_ENDIF); } void @@ -1815,21 +1780,20 @@ fs_visitor::visit(ir_loop *ir) this->base_ir = ir->from; ir->from->accept(this); - emit(fs_inst(BRW_OPCODE_MOV, counter, this->result)); + emit(BRW_OPCODE_MOV, counter, this->result); } } - emit(fs_inst(BRW_OPCODE_DO)); + emit(BRW_OPCODE_DO); if (ir->to) { this->base_ir = ir->to; ir->to->accept(this); - fs_inst *inst = emit(fs_inst(BRW_OPCODE_CMP, reg_null_cmp, - counter, this->result)); + fs_inst *inst = emit(BRW_OPCODE_CMP, reg_null_cmp, counter, this->result); inst->conditional_mod = brw_conditional_for_comparison(ir->cmp); - inst = emit(fs_inst(BRW_OPCODE_BREAK)); + inst = emit(BRW_OPCODE_BREAK); inst->predicated = true; } @@ -1843,10 +1807,10 @@ fs_visitor::visit(ir_loop *ir) if (ir->increment) { this->base_ir = ir->increment; ir->increment->accept(this); - emit(fs_inst(BRW_OPCODE_ADD, counter, counter, this->result)); + emit(BRW_OPCODE_ADD, counter, counter, this->result); } - emit(fs_inst(BRW_OPCODE_WHILE)); + emit(BRW_OPCODE_WHILE); } void @@ -1854,10 +1818,10 @@ fs_visitor::visit(ir_loop_jump *ir) { switch (ir->mode) { case ir_loop_jump::jump_break: - emit(fs_inst(BRW_OPCODE_BREAK)); + emit(BRW_OPCODE_BREAK); break; case ir_loop_jump::jump_continue: - emit(fs_inst(BRW_OPCODE_CONTINUE)); + emit(BRW_OPCODE_CONTINUE); break; } } @@ -1923,23 +1887,13 @@ void fs_visitor::emit_dummy_fs() { /* Everyone's favorite color. */ - emit(fs_inst(BRW_OPCODE_MOV, - fs_reg(MRF, 2), - fs_reg(1.0f))); - emit(fs_inst(BRW_OPCODE_MOV, - fs_reg(MRF, 3), - fs_reg(0.0f))); - emit(fs_inst(BRW_OPCODE_MOV, - fs_reg(MRF, 4), - fs_reg(1.0f))); - emit(fs_inst(BRW_OPCODE_MOV, - fs_reg(MRF, 5), - fs_reg(0.0f))); + emit(BRW_OPCODE_MOV, fs_reg(MRF, 2), fs_reg(1.0f)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, 3), fs_reg(0.0f)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, 4), fs_reg(1.0f)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, 5), fs_reg(0.0f)); fs_inst *write; - write = emit(fs_inst(FS_OPCODE_FB_WRITE, - fs_reg(0), - fs_reg(0))); + write = emit(FS_OPCODE_FB_WRITE, fs_reg(0), fs_reg(0)); write->base_mrf = 0; } @@ -1969,14 +1923,14 @@ fs_visitor::emit_interpolation_setup_gen4() this->pixel_y = fs_reg(this, glsl_type::uint_type); this->pixel_x.type = BRW_REGISTER_TYPE_UW; this->pixel_y.type = BRW_REGISTER_TYPE_UW; - emit(fs_inst(BRW_OPCODE_ADD, - this->pixel_x, - fs_reg(stride(suboffset(g1_uw, 4), 2, 4, 0)), - fs_reg(brw_imm_v(0x10101010)))); - emit(fs_inst(BRW_OPCODE_ADD, - this->pixel_y, - fs_reg(stride(suboffset(g1_uw, 5), 2, 4, 0)), - fs_reg(brw_imm_v(0x11001100)))); + emit(BRW_OPCODE_ADD, + this->pixel_x, + fs_reg(stride(suboffset(g1_uw, 4), 2, 4, 0)), + fs_reg(brw_imm_v(0x10101010))); + emit(BRW_OPCODE_ADD, + this->pixel_y, + fs_reg(stride(suboffset(g1_uw, 5), 2, 4, 0)), + fs_reg(brw_imm_v(0x11001100))); this->current_annotation = "compute pixel deltas from v0"; if (brw->has_pln) { @@ -1987,22 +1941,18 @@ fs_visitor::emit_interpolation_setup_gen4() this->delta_x = fs_reg(this, glsl_type::float_type); this->delta_y = fs_reg(this, glsl_type::float_type); } - emit(fs_inst(BRW_OPCODE_ADD, - this->delta_x, - this->pixel_x, - fs_reg(negate(brw_vec1_grf(1, 0))))); - emit(fs_inst(BRW_OPCODE_ADD, - this->delta_y, - this->pixel_y, - fs_reg(negate(brw_vec1_grf(1, 1))))); + emit(BRW_OPCODE_ADD, this->delta_x, + this->pixel_x, fs_reg(negate(brw_vec1_grf(1, 0)))); + emit(BRW_OPCODE_ADD, this->delta_y, + this->pixel_y, fs_reg(negate(brw_vec1_grf(1, 1)))); this->current_annotation = "compute pos.w and 1/pos.w"; /* Compute wpos.w. It's always in our setup, since it's needed to * interpolate the other attributes. */ this->wpos_w = fs_reg(this, glsl_type::float_type); - emit(fs_inst(FS_OPCODE_LINTERP, wpos_w, this->delta_x, this->delta_y, - interp_reg(FRAG_ATTRIB_WPOS, 3))); + emit(FS_OPCODE_LINTERP, wpos_w, this->delta_x, this->delta_y, + interp_reg(FRAG_ATTRIB_WPOS, 3)); /* Compute the pixel 1/W value from wpos.w. */ this->pixel_w = fs_reg(this, glsl_type::float_type); emit_math(FS_OPCODE_RCP, this->pixel_w, wpos_w); @@ -2021,14 +1971,14 @@ fs_visitor::emit_interpolation_setup_gen6() fs_reg int_pixel_y = fs_reg(this, glsl_type::uint_type); int_pixel_x.type = BRW_REGISTER_TYPE_UW; int_pixel_y.type = BRW_REGISTER_TYPE_UW; - emit(fs_inst(BRW_OPCODE_ADD, - int_pixel_x, - fs_reg(stride(suboffset(g1_uw, 4), 2, 4, 0)), - fs_reg(brw_imm_v(0x10101010)))); - emit(fs_inst(BRW_OPCODE_ADD, - int_pixel_y, - fs_reg(stride(suboffset(g1_uw, 5), 2, 4, 0)), - fs_reg(brw_imm_v(0x11001100)))); + emit(BRW_OPCODE_ADD, + int_pixel_x, + fs_reg(stride(suboffset(g1_uw, 4), 2, 4, 0)), + fs_reg(brw_imm_v(0x10101010))); + emit(BRW_OPCODE_ADD, + int_pixel_y, + fs_reg(stride(suboffset(g1_uw, 5), 2, 4, 0)), + fs_reg(brw_imm_v(0x11001100))); /* As of gen6, we can no longer mix float and int sources. We have * to turn the integer pixel centers into floats for their actual @@ -2036,13 +1986,13 @@ fs_visitor::emit_interpolation_setup_gen6() */ this->pixel_x = fs_reg(this, glsl_type::float_type); this->pixel_y = fs_reg(this, glsl_type::float_type); - emit(fs_inst(BRW_OPCODE_MOV, this->pixel_x, int_pixel_x)); - emit(fs_inst(BRW_OPCODE_MOV, this->pixel_y, int_pixel_y)); + emit(BRW_OPCODE_MOV, this->pixel_x, int_pixel_x); + emit(BRW_OPCODE_MOV, this->pixel_y, int_pixel_y); - this->current_annotation = "compute 1/pos.w"; - this->wpos_w = fs_reg(brw_vec8_grf(c->source_w_reg, 0)); - this->pixel_w = fs_reg(this, glsl_type::float_type); - emit_math(FS_OPCODE_RCP, this->pixel_w, wpos_w); + this->current_annotation = "compute pos.w"; + this->pixel_w = fs_reg(brw_vec8_grf(c->source_w_reg, 0)); + this->wpos_w = fs_reg(this, glsl_type::float_type); + emit_math(FS_OPCODE_RCP, this->wpos_w, this->pixel_w); this->delta_x = fs_reg(brw_vec8_grf(2, 0)); this->delta_y = fs_reg(brw_vec8_grf(3, 0)); @@ -2069,8 +2019,8 @@ fs_visitor::emit_fb_writes() } if (c->aa_dest_stencil_reg) { - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, nr++), - fs_reg(brw_vec8_grf(c->aa_dest_stencil_reg, 0)))); + emit(BRW_OPCODE_MOV, fs_reg(MRF, nr++), + fs_reg(brw_vec8_grf(c->aa_dest_stencil_reg, 0))); } /* Reserve space for color. It'll be filled in per MRT below. */ @@ -2083,17 +2033,17 @@ fs_visitor::emit_fb_writes() assert(this->frag_depth); fs_reg depth = *(variable_storage(this->frag_depth)); - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, nr++), depth)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, nr++), depth); } else { /* Pass through the payload depth. */ - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, nr++), - fs_reg(brw_vec8_grf(c->source_depth_reg, 0)))); + emit(BRW_OPCODE_MOV, fs_reg(MRF, nr++), + fs_reg(brw_vec8_grf(c->source_depth_reg, 0))); } } if (c->dest_depth_reg) { - emit(fs_inst(BRW_OPCODE_MOV, fs_reg(MRF, nr++), - fs_reg(brw_vec8_grf(c->dest_depth_reg, 0)))); + emit(BRW_OPCODE_MOV, fs_reg(MRF, nr++), + fs_reg(brw_vec8_grf(c->dest_depth_reg, 0))); } fs_reg color = reg_undef; @@ -2110,9 +2060,7 @@ fs_visitor::emit_fb_writes() target); if (this->frag_color || this->frag_data) { for (int i = 0; i < 4; i++) { - emit(fs_inst(BRW_OPCODE_MOV, - fs_reg(MRF, color_mrf + i), - color)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, color_mrf + i), color); color.reg_offset++; } } @@ -2120,8 +2068,7 @@ fs_visitor::emit_fb_writes() if (this->frag_color) color.reg_offset -= 4; - fs_inst *inst = emit(fs_inst(FS_OPCODE_FB_WRITE, - reg_undef, reg_undef)); + fs_inst *inst = emit(FS_OPCODE_FB_WRITE); inst->target = target; inst->base_mrf = 0; inst->mlen = nr; @@ -2137,13 +2084,10 @@ fs_visitor::emit_fb_writes() * renderbuffer. */ color.reg_offset += 3; - emit(fs_inst(BRW_OPCODE_MOV, - fs_reg(MRF, color_mrf + 3), - color)); + emit(BRW_OPCODE_MOV, fs_reg(MRF, color_mrf + 3), color); } - fs_inst *inst = emit(fs_inst(FS_OPCODE_FB_WRITE, - reg_undef, reg_undef)); + fs_inst *inst = emit(FS_OPCODE_FB_WRITE); inst->base_mrf = 0; inst->mlen = nr; inst->eot = true; @@ -2868,8 +2812,7 @@ fs_visitor::calculate_live_intervals() if (inst->src[i].file == GRF && inst->src[i].reg != 0) { int reg = inst->src[i].reg; - if (!loop_depth || (this->virtual_grf_sizes[reg] == 1 && - def[reg] >= bb_header_ip)) { + if (!loop_depth) { use[reg] = ip; } else { def[reg] = MIN2(loop_start, def[reg]); @@ -2885,8 +2828,7 @@ fs_visitor::calculate_live_intervals() if (inst->dst.file == GRF && inst->dst.reg != 0) { int reg = inst->dst.reg; - if (!loop_depth || (this->virtual_grf_sizes[reg] == 1 && - !inst->predicated)) { + if (!loop_depth) { def[reg] = MIN2(def[reg], ip); } else { def[reg] = MIN2(def[reg], loop_start); @@ -2996,12 +2938,41 @@ fs_visitor::propagate_constants() progress = true; } break; + case BRW_OPCODE_CMP: + if (i == 1) { + scan_inst->src[i] = inst->src[0]; + progress = true; + } else if (i == 0 && scan_inst->src[1].file != IMM) { + uint32_t new_cmod; + + new_cmod = brw_swap_cmod(scan_inst->conditional_mod); + if (new_cmod != ~0u) { + /* Fit this constant in by swapping the operands and + * flipping the test + */ + scan_inst->src[0] = scan_inst->src[1]; + scan_inst->src[1] = inst->src[0]; + scan_inst->conditional_mod = new_cmod; + progress = true; + } + } + break; + case BRW_OPCODE_SEL: if (i == 1) { scan_inst->src[i] = inst->src[0]; progress = true; + } else if (i == 0 && scan_inst->src[1].file != IMM) { + /* Fit this constant in by swapping the operands and + * flipping the predicate + */ + scan_inst->src[0] = scan_inst->src[1]; + scan_inst->src[1] = inst->src[0]; + scan_inst->predicate_inverse = !scan_inst->predicate_inverse; + progress = true; } + break; } } @@ -3487,6 +3458,7 @@ fs_visitor::generate_code() brw_set_conditionalmod(p, inst->conditional_mod); brw_set_predicate_control(p, inst->predicated); + brw_set_predicate_inverse(p, inst->predicate_inverse); brw_set_saturate(p, inst->saturate); switch (inst->opcode) { @@ -3677,7 +3649,7 @@ fs_visitor::generate_code() } else { _mesa_problem(ctx, "Unsupported opcode %d in FS", inst->opcode); } - this->fail = true; + fail("unsupported opcode in FS\n"); } if (unlikely(INTEL_DEBUG & DEBUG_WM)) { @@ -3808,18 +3780,18 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c) v.assign_regs_trivial(); else { while (!v.assign_regs()) { - if (v.fail) + if (v.failed) break; } } } - if (!v.fail) + if (!v.failed) v.generate_code(); - assert(!v.fail); /* FINISHME: Cleanly fail, tested at link time, etc. */ + assert(!v.failed); /* FINISHME: Cleanly fail, tested at link time, etc. */ - if (v.fail) + if (v.failed) return GL_FALSE; c->prog_data.total_grf = v.grf_used; |