summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2020-11-23 10:07:17 -0600
committerDylan Baker <dylan.c.baker@intel.com>2020-11-24 22:08:25 -0800
commitb2c70c3b116cc8874c71e4a1d903ff62e4484f16 (patch)
tree896862c4fdd97e3b8cef299967d4d288698f70c6
parentdeccfbc0d77e093990c67e634bf82831ae1d0d92 (diff)
spirv: Call repair SSA for OpTerminateInvocation
Fixes: 886d2d1a9abcb "spirv: Handle SpvOpTerminateInvocation" Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7734> (cherry picked from commit 66685679b7c047398d3f593db86a24eba38db3b9)
-rw-r--r--.pick_status.json2
-rw-r--r--src/compiler/spirv/vtn_cfg.c6
-rw-r--r--src/compiler/spirv/vtn_private.h14
3 files changed, 18 insertions, 4 deletions
diff --git a/.pick_status.json b/.pick_status.json
index fdcb77fda17..d7f2811c588 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -481,7 +481,7 @@
"description": "spirv: Call repair SSA for OpTerminateInvocation",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "886d2d1a9abcb0572a957c24ae44de4d6c055bc0"
},
diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 41622752f36..4d68f8f34da 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -687,11 +687,12 @@ vtn_process_block(struct vtn_builder *b,
return NULL;
case SpvOpKill:
- b->has_kill = true;
+ b->has_early_terminate = true;
block->branch_type = vtn_branch_type_discard;
return NULL;
case SpvOpTerminateInvocation:
+ b->has_early_terminate = true;
block->branch_type = vtn_branch_type_terminate;
return NULL;
@@ -1377,7 +1378,8 @@ vtn_function_emit(struct vtn_builder *b, struct vtn_function *func,
* but instructions in the continue may use SSA defs in the loop body.
* Therefore, we need to repair SSA to insert the needed phi nodes.
*/
- if (b->func->impl->structured && (b->has_loop_continue || b->has_kill))
+ if (b->func->impl->structured &&
+ (b->has_loop_continue || b->has_early_terminate))
nir_repair_ssa_impl(func->impl);
func->emitted = true;
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 45187a092c7..c136db2d5bb 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -693,7 +693,19 @@ struct vtn_builder {
unsigned func_param_idx;
bool has_loop_continue;
- bool has_kill;
+
+ /** True if this shader has any early termination instructions like OpKill
+ *
+ * In the SPIR-V, the following instructions are block terminators:
+ *
+ * - OpKill
+ * - OpTerminateInvocation
+ *
+ * However, in NIR, they're represented by regular intrinsics with no
+ * control-flow semantics. This means that the SSA form from the SPIR-V
+ * may not 100% match NIR and we have to fix it up at the end.
+ */
+ bool has_early_terminate;
/* false by default, set to true by the ContractionOff execution mode */
bool exact;