summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2015-06-16 20:16:15 +0200
committerJason Ekstrand <[email protected]>2015-08-03 09:40:47 -0700
commit5c0436dbf87fef76ba67456f215d9285c38f1816 (patch)
tree0d87f6450be58a7111e37a4a1b69c8017e4e782b
parentf3187ea31ede6bc181ee561573d127aa2e485657 (diff)
i965/nir/vec4: Implement conditional statements (nir_cf_node_if)
The same we do in the FS NIR backend, only that here we need to consider the number of components in the condition and adjust the swizzle accordingly. Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_nir.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index a3dfddf7d3c..7ce571a2261 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -282,7 +282,21 @@ vec4_visitor::nir_emit_cf_list(exec_list *list)
void
vec4_visitor::nir_emit_if(nir_if *if_stmt)
{
- /* @TODO: Not yet implemented */
+ /* First, put the condition in f0 */
+ src_reg condition = get_nir_src(if_stmt->condition, BRW_REGISTER_TYPE_D, 1);
+ vec4_instruction *inst = emit(MOV(dst_null_d(), condition));
+ inst->conditional_mod = BRW_CONDITIONAL_NZ;
+
+ emit(IF(BRW_PREDICATE_NORMAL));
+
+ nir_emit_cf_list(&if_stmt->then_list);
+
+ /* note: if the else is empty, dead CF elimination will remove it */
+ emit(BRW_OPCODE_ELSE);
+
+ nir_emit_cf_list(&if_stmt->else_list);
+
+ emit(BRW_OPCODE_ENDIF);
}
void