diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp b/src/mesa/drivers/dri/i965/brw_cfg.cpp index 6bf99f1..2d58b39 100644 --- a/src/mesa/drivers/dri/i965/brw_cfg.cpp +++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp @@ -154,6 +154,7 @@ cfg_t::cfg_t(exec_list *instructions) } else { cur_endif = new_block(); cur_endif->start = inst; + cur_endif->end = inst; cur->end = (backend_instruction *)inst->prev; cur->add_successor(mem_ctx, cur_endif); diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 60a4906..f57dabb 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -452,6 +452,10 @@ public: void emit_color_write(int target, int index, int first_color_mrf); void emit_alpha_test(); + void do_emit_single_fb_write(int target, int base_mrf, int mlen, bool eot, + bool header_present); + void emit_single_fb_write(int target, int base_mrf, int mlen, bool eot, + bool header_present); void emit_fb_writes(); void emit_shader_time_begin(); diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 6ba8bb9..2ced3b6 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -98,7 +98,6 @@ fs_generator::patch_discard_jumps_to_fb_writes() void fs_generator::generate_fb_write(fs_inst *inst) { - bool eot = inst->eot; struct brw_reg implied_header; uint32_t msg_control; @@ -153,10 +152,9 @@ fs_generator::generate_fb_write(fs_inst *inst) implied_header = brw_null_reg(); } else { implied_header = retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW); - - brw_MOV(p, - brw_message_reg(inst->base_mrf + 1), - brw_vec8_grf(1, 0)); + brw_MOV(p, + brw_message_reg(inst->base_mrf + 1), + brw_vec8_grf(1, 0)); } } else { implied_header = brw_null_reg(); @@ -174,15 +172,15 @@ fs_generator::generate_fb_write(fs_inst *inst) uint32_t surf_index = prog_data->binding_table.render_target_start + inst->target; brw_fb_WRITE(p, - dispatch_width, - inst->base_mrf, - implied_header, - msg_control, - surf_index, - inst->mlen, - 0, - eot, - inst->header_present); + dispatch_width, + inst->base_mrf, + implied_header, + msg_control, + surf_index, + inst->mlen, + 0, + inst->eot, + inst->header_present); brw_mark_surface_used(&prog_data->base, surf_index); } diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 171f063..1a3f1e2 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2731,6 +2731,54 @@ fs_visitor::emit_alpha_test() } void +fs_visitor::do_emit_single_fb_write(int target, int base_mrf, int mlen, + bool eot, bool header_present) +{ + fs_inst *inst = emit(FS_OPCODE_FB_WRITE); + inst->target = target; + inst->base_mrf = base_mrf; + inst->mlen = mlen; + inst->eot = eot; + inst->header_present = header_present; + if ((brw->gen >= 8 || brw->is_haswell) && fp->UsesKill) { + inst->predicate = BRW_PREDICATE_NORMAL; + inst->flag_subreg = 1; + } +} + +void +fs_visitor::emit_single_fb_write(int target, int base_mrf, int mlen, bool eot, + bool header_present) +{ + if (!runtime_check_aads_emit) { + do_emit_single_fb_write(target, base_mrf, mlen, eot, header_present); + } else { + /* This can only happen in Gen < 6 + */ + fs_reg reg_tmp_ud = fs_reg(this, glsl_type::uint_type); + emit(AND(reg_tmp_ud, + fs_reg(get_element_ud(brw_vec8_grf(1,0), 6)), + fs_reg(brw_imm_ud(1<<26)))); + emit(CMP(reg_null_ud, + reg_tmp_ud, + fs_reg(brw_imm_ud(0)), + BRW_CONDITIONAL_Z)); + emit(IF(BRW_PREDICATE_NORMAL)); + { + /* Shift message header one register since we are not sending + * AA data stored in base_mrf+2 + */ + do_emit_single_fb_write(target, base_mrf + 1, mlen - 1, eot, header_present); + } + emit(BRW_OPCODE_ELSE); + { + do_emit_single_fb_write(target, base_mrf, mlen, eot, header_present); + } + emit(BRW_OPCODE_ENDIF); + } +} + +void fs_visitor::emit_fb_writes() { this->current_annotation = "FB write header"; @@ -2847,17 +2895,8 @@ fs_visitor::emit_fb_writes() if (INTEL_DEBUG & DEBUG_SHADER_TIME) emit_shader_time_end(); - - fs_inst *inst = emit(FS_OPCODE_FB_WRITE); - inst->target = 0; - inst->base_mrf = base_mrf; - inst->mlen = nr - base_mrf; - inst->eot = true; - inst->header_present = header_present; - if ((brw->gen >= 8 || brw->is_haswell) && fp->UsesKill) { - inst->predicate = BRW_PREDICATE_NORMAL; - inst->flag_subreg = 1; - } + + emit_single_fb_write(0, base_mrf, nr - base_mrf, true, header_present); prog_data->dual_src_blend = true; this->current_annotation = NULL; @@ -2894,19 +2933,10 @@ fs_visitor::emit_fb_writes() emit_shader_time_end(); } - fs_inst *inst = emit(FS_OPCODE_FB_WRITE); - inst->target = target; - inst->base_mrf = base_mrf; - if (src0_alpha_to_render_target && target == 0) - inst->mlen = nr - base_mrf - reg_width; - else - inst->mlen = nr - base_mrf; - inst->eot = eot; - inst->header_present = header_present; - if ((brw->gen >= 8 || brw->is_haswell) && fp->UsesKill) { - inst->predicate = BRW_PREDICATE_NORMAL; - inst->flag_subreg = 1; - } + int mlen = (src0_alpha_to_render_target && target == 0) ? + nr - base_mrf - reg_width : nr - base_mrf; + + emit_single_fb_write(target, base_mrf, mlen, eot, header_present); } if (key->nr_color_regions == 0) { @@ -2919,15 +2949,7 @@ fs_visitor::emit_fb_writes() if (INTEL_DEBUG & DEBUG_SHADER_TIME) emit_shader_time_end(); - fs_inst *inst = emit(FS_OPCODE_FB_WRITE); - inst->base_mrf = base_mrf; - inst->mlen = nr - base_mrf; - inst->eot = true; - inst->header_present = header_present; - if ((brw->gen >= 8 || brw->is_haswell) && fp->UsesKill) { - inst->predicate = BRW_PREDICATE_NORMAL; - inst->flag_subreg = 1; - } + emit_single_fb_write(0, base_mrf, nr - base_mrf, true, header_present); } this->current_annotation = NULL;