Mesa (master): spirv: make use of the select control support in nir
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Mar 27 03:12:42 UTC 2019
Module: Mesa
Branch: master
Commit: d163780f819b406679bf5b86b6c4286940c00415
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d163780f819b406679bf5b86b6c4286940c00415
Author: Timothy Arceri <tarceri at itsqueeze.com>
Date: Wed Mar 20 15:56:54 2019 +1100
spirv: make use of the select control support in nir
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108841
---
src/compiler/spirv/vtn_cfg.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 925b4c643e7..e95279fbd01 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -586,6 +586,8 @@ vtn_cfg_walk_blocks(struct vtn_builder *b, struct list_head *cf_list,
if (block->merge &&
(*block->merge & SpvOpCodeMask) == SpvOpSelectionMerge) {
if_stmt->control = block->merge[2];
+ } else {
+ if_stmt->control = SpvSelectionControlMaskNone;
}
if_stmt->then_type = vtn_get_branch_type(b, then_block,
@@ -895,6 +897,19 @@ vtn_loop_control(struct vtn_builder *b, struct vtn_loop *vtn_loop)
}
}
+static nir_selection_control
+vtn_selection_control(struct vtn_builder *b, struct vtn_if *vtn_if)
+{
+ if (vtn_if->control == SpvSelectionControlMaskNone)
+ return nir_selection_control_none;
+ else if (vtn_if->control & SpvSelectionControlDontFlattenMask)
+ return nir_selection_control_dont_flatten;
+ else if (vtn_if->control & SpvSelectionControlFlattenMask)
+ return nir_selection_control_flatten;
+ else
+ vtn_fail("Invalid selection control");
+}
+
static void
vtn_emit_cf_list(struct vtn_builder *b, struct list_head *cf_list,
nir_variable *switch_fall_var, bool *has_switch_break,
@@ -946,6 +961,9 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head *cf_list,
nir_if *nif =
nir_push_if(&b->nb, vtn_ssa_value(b, vtn_if->condition)->def);
+
+ nif->control = vtn_selection_control(b, vtn_if);
+
if (vtn_if->then_type == vtn_branch_type_none) {
vtn_emit_cf_list(b, &vtn_if->then_body,
switch_fall_var, &sw_break, handler);
More information about the mesa-commit
mailing list