From: Jason Ekstrand Date: Thu, 7 Jan 2016 01:00:01 +0000 (-0800) Subject: nir/spirv/cfg: Only set fall to true at the start of a case X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=000eb00862545aa1a0e42cea800a06bc57b406cf;p=mesa.git 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. --- 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 */