From 000eb00862545aa1a0e42cea800a06bc57b406cf Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 6 Jan 2016 17:00:01 -0800 Subject: [PATCH] nir/spirv/cfg: Only set fall to true at the start of a case Previously, we were setting it to true at the top of the switch statement. However, this causes all of the cases to get executed until you hit a break. Instead, you want to be not executing at the start, start executing when you hit your case, and end at a break. --- src/glsl/nir/spirv/vtn_cfg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/glsl/nir/spirv/vtn_cfg.c b/src/glsl/nir/spirv/vtn_cfg.c index 9330ac03769..db1163d0707 100644 --- a/src/glsl/nir/spirv/vtn_cfg.c +++ b/src/glsl/nir/spirv/vtn_cfg.c @@ -598,7 +598,7 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head *cf_list, */ nir_variable *fall_var = nir_local_variable_create(b->nb.impl, glsl_bool_type(), "fall"); - nir_store_var(&b->nb, fall_var, nir_imm_int(&b->nb, NIR_TRUE), 1); + nir_store_var(&b->nb, fall_var, nir_imm_int(&b->nb, NIR_FALSE), 1); /* Next, we gather up all of the conditions. We have to do this * up-front because we also need to build an "any" condition so @@ -649,6 +649,7 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head *cf_list, bool has_break = false; b->nb.cursor = nir_after_cf_list(&case_if->then_list); + nir_store_var(&b->nb, fall_var, nir_imm_int(&b->nb, NIR_TRUE), 1); vtn_emit_cf_list(b, &cse->body, fall_var, &has_break, handler); (void)has_break; /* We don't care */ -- 2.11.0