Mesa (staging/22.0): intel/fs: Fix IsHelperInvocation for the case no discard/demote are used
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 21 07:12:59 UTC 2022
Module: Mesa
Branch: staging/22.0
Commit: efcaec877e1c06237352bd73ede46a45e0bae38f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=efcaec877e1c06237352bd73ede46a45e0bae38f
Author: Caio Oliveira <caio.oliveira at intel.com>
Date: Tue Mar 15 17:04:04 2022 -0700
intel/fs: Fix IsHelperInvocation for the case no discard/demote are used
Use emit_predicate_on_sample_mask() helper that does check where to
get the correct mask depending on whether discard/demote was used or
not.
Fixes: 45f5db5a84a ("intel/fs: Implement "demote to helper invocation"")
Reviewed-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15400>
(cherry picked from commit f82731d0d7ada7bbca4a6742568925b6f97c91aa)
Conflicts:
src/intel/compiler/brw_fs.cpp
---
.pick_status.json | 2 +-
src/intel/compiler/brw_fs.cpp | 27 +++++++++++++++++++++++++++
src/intel/compiler/brw_fs.h | 1 +
src/intel/compiler/brw_fs_nir.cpp | 17 ++---------------
4 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index d02b9e93262..98a839f0eee 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -8332,7 +8332,7 @@
"description": "intel/fs: Fix IsHelperInvocation for the case no discard/demote are used",
"nominated": true,
"nomination_type": 1,
- "resolution": 5,
+ "resolution": 1,
"because_sha": "45f5db5a84ae6fe5d4a4d1cd8b62b48d70629fc9"
},
{
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index 516b001620f..c4639f43098 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -5491,6 +5491,33 @@ emit_predicate_on_sample_mask(const fs_builder &bld, fs_inst *inst)
}
}
+void
+fs_visitor::emit_is_helper_invocation(fs_reg result)
+{
+ /* Unlike the regular gl_HelperInvocation, that is defined at dispatch,
+ * the helperInvocationEXT() (aka SpvOpIsHelperInvocationEXT) takes into
+ * consideration demoted invocations.
+ */
+ result.type = BRW_REGISTER_TYPE_UD;
+
+ bld.MOV(result, brw_imm_ud(0));
+
+ /* See sample_mask_reg() for why we split SIMD32 into SIMD16 here. */
+ unsigned width = bld.dispatch_width();
+ for (unsigned i = 0; i < DIV_ROUND_UP(width, 16); i++) {
+ const fs_builder b = bld.group(MIN2(width, 16), i);
+
+ fs_inst *mov = b.MOV(offset(result, b, i), brw_imm_ud(~0));
+
+ /* The at() ensures that any code emitted to get the predicate happens
+ * before the mov right above. This is not an issue elsewhere because
+ * lowering code already set up the builder this way.
+ */
+ emit_predicate_on_sample_mask(b.at(NULL, mov), mov);
+ mov->predicate_inverse = true;
+ }
+}
+
static void
setup_surface_descriptors(const fs_builder &bld, fs_inst *inst, uint32_t desc,
const fs_reg &surface, const fs_reg &surface_handle)
diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h
index 3f6489a88cd..4afb77146bc 100644
--- a/src/intel/compiler/brw_fs.h
+++ b/src/intel/compiler/brw_fs.h
@@ -203,6 +203,7 @@ public:
void emit_dummy_fs();
void emit_repclear_shader();
void emit_fragcoord_interpolation(fs_reg wpos);
+ void emit_is_helper_invocation(fs_reg result);
fs_reg emit_frontfacing_interpolation();
fs_reg emit_samplepos_setup();
fs_reg emit_sampleid_setup();
diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp
index 16203a047e7..0fe593a71ca 100644
--- a/src/intel/compiler/brw_fs_nir.cpp
+++ b/src/intel/compiler/brw_fs_nir.cpp
@@ -3459,22 +3459,9 @@ fs_visitor::nir_emit_fs_intrinsic(const fs_builder &bld,
bld.MOV(dest, fetch_render_target_array_index(bld));
break;
- case nir_intrinsic_is_helper_invocation: {
- /* Unlike the regular gl_HelperInvocation, that is defined at dispatch,
- * the helperInvocationEXT() (aka SpvOpIsHelperInvocationEXT) takes into
- * consideration demoted invocations. That information is stored in
- * f0.1.
- */
- dest.type = BRW_REGISTER_TYPE_UD;
-
- bld.MOV(dest, brw_imm_ud(0));
-
- fs_inst *mov = bld.MOV(dest, brw_imm_ud(~0));
- mov->predicate = BRW_PREDICATE_NORMAL;
- mov->predicate_inverse = true;
- mov->flag_subreg = sample_mask_flag_subreg(this);
+ case nir_intrinsic_is_helper_invocation:
+ emit_is_helper_invocation(dest);
break;
- }
case nir_intrinsic_load_helper_invocation:
case nir_intrinsic_load_sample_mask_in:
More information about the mesa-commit
mailing list