diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c index 3ca1e54d8c9..5f0505a35f1 100644 --- a/src/compiler/spirv/vtn_cfg.c +++ b/src/compiler/spirv/vtn_cfg.c @@ -255,6 +255,7 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode, case SpvOpBranchConditional: case SpvOpSwitch: case SpvOpKill: + case SpvOpTerminateInvocation: case SpvOpReturn: case SpvOpReturnValue: case SpvOpUnreachable: @@ -690,6 +691,10 @@ vtn_process_block(struct vtn_builder *b, block->branch_type = vtn_branch_type_discard; return NULL; + case SpvOpTerminateInvocation: + block->branch_type = vtn_branch_type_terminate; + return NULL; + case SpvOpBranchConditional: { struct vtn_value *cond_val = vtn_untyped_value(b, block->branch[1]); vtn_fail_if(!cond_val->type || @@ -951,6 +956,12 @@ vtn_emit_branch(struct vtn_builder *b, enum vtn_branch_type branch_type, nir_builder_instr_insert(&b->nb, &discard->instr); break; } + case vtn_branch_type_terminate: { + nir_intrinsic_instr *terminate = + nir_intrinsic_instr_create(b->nb.shader, nir_intrinsic_terminate); + nir_builder_instr_insert(&b->nb, &terminate->instr); + break; + } default: vtn_fail("Invalid branch type"); } diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index e7e7a643aed..ec6493d5207 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -130,6 +130,7 @@ enum vtn_branch_type { vtn_branch_type_loop_continue, vtn_branch_type_loop_back_edge, vtn_branch_type_discard, + vtn_branch_type_terminate, vtn_branch_type_return, };