From 083fd96a97d992b8233587f4626c4d433fbd4045 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Sat, 4 Jan 2020 14:32:09 -0800 Subject: [PATCH] intel/fs: Use helper for discard sample mask flag subregister number. Use it instead of hard-coding f0.1 for the sample mask of programs that use discard. This will make the task easier when we replace f0.1 with another flag register location in order to support discard with SIMD32 shaders. Reviewed-by: Kenneth Graunke --- src/intel/compiler/brw_fs.cpp | 4 ++-- src/intel/compiler/brw_fs.h | 11 +++++++++++ src/intel/compiler/brw_fs_nir.cpp | 4 ++-- src/intel/compiler/brw_fs_visitor.cpp | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index ee402876e39..b5834540ef1 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -1532,7 +1532,7 @@ fs_visitor::emit_discard_jump() * shader if all relevant channels have been discarded. */ fs_inst *discard_jump = bld.emit(FS_OPCODE_DISCARD_JUMP); - discard_jump->flag_subreg = 1; + discard_jump->flag_subreg = sample_mask_flag_subreg(this); discard_jump->predicate = BRW_PREDICATE_ALIGN1_ANY4H; discard_jump->predicate_inverse = true; @@ -4286,7 +4286,7 @@ sample_mask_reg(const fs_builder &bld) return brw_imm_ud(0xffffffff); } else if (brw_wm_prog_data(v->stage_prog_data)->uses_kill) { assert(bld.group() < 16 && bld.dispatch_width() <= 16); - return brw_flag_reg(0, 1); + return brw_flag_subreg(sample_mask_flag_subreg(v)); } else { assert(v->devinfo->gen >= 6 && bld.dispatch_width() <= 16); return retype(brw_vec1_grf((bld.group() >= 16 ? 2 : 1), 7), diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h index dfa1ff4d0e1..93d3e460098 100644 --- a/src/intel/compiler/brw_fs.h +++ b/src/intel/compiler/brw_fs.h @@ -417,6 +417,17 @@ private: unsigned workgroup_size() const; }; +/** + * Return the flag register used in fragment shaders to keep track of live + * samples. + */ +static inline unsigned +sample_mask_flag_subreg(const fs_visitor *shader) +{ + assert(shader->stage == MESA_SHADER_FRAGMENT); + return 1; +} + /** * The fragment shader code generator. * diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp index fab27c10d8c..93c6ee24404 100644 --- a/src/intel/compiler/brw_fs_nir.cpp +++ b/src/intel/compiler/brw_fs_nir.cpp @@ -3435,7 +3435,7 @@ fs_visitor::nir_emit_fs_intrinsic(const fs_builder &bld, fs_inst *mov = bld.MOV(dest, brw_imm_ud(~0)); mov->predicate = BRW_PREDICATE_NORMAL; mov->predicate_inverse = true; - mov->flag_subreg = 1; + mov->flag_subreg = sample_mask_flag_subreg(this); break; } @@ -3552,7 +3552,7 @@ fs_visitor::nir_emit_fs_intrinsic(const fs_builder &bld, } cmp->predicate = BRW_PREDICATE_NORMAL; - cmp->flag_subreg = 1; + cmp->flag_subreg = sample_mask_flag_subreg(this); if (devinfo->gen >= 6) { /* Due to the way we implement discard, the jump will only happen diff --git a/src/intel/compiler/brw_fs_visitor.cpp b/src/intel/compiler/brw_fs_visitor.cpp index 5cb240098f9..f7baeb5522f 100644 --- a/src/intel/compiler/brw_fs_visitor.cpp +++ b/src/intel/compiler/brw_fs_visitor.cpp @@ -455,7 +455,7 @@ fs_visitor::emit_single_fb_write(const fs_builder &bld, if (prog_data->uses_kill) { write->predicate = BRW_PREDICATE_NORMAL; - write->flag_subreg = 1; + write->flag_subreg = sample_mask_flag_subreg(this); } return write; -- 2.30.2