diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c index 4d68f8f34da..445e3e55a24 100644 --- a/src/compiler/spirv/vtn_cfg.c +++ b/src/compiler/spirv/vtn_cfg.c @@ -256,6 +256,8 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode, case SpvOpSwitch: case SpvOpKill: case SpvOpTerminateInvocation: + case SpvOpIgnoreIntersectionKHR: + case SpvOpTerminateRayKHR: case SpvOpReturn: case SpvOpReturnValue: case SpvOpUnreachable: @@ -693,7 +695,17 @@ vtn_process_block(struct vtn_builder *b, case SpvOpTerminateInvocation: b->has_early_terminate = true; - block->branch_type = vtn_branch_type_terminate; + block->branch_type = vtn_branch_type_terminate_invocation; + return NULL; + + case SpvOpIgnoreIntersectionKHR: + b->has_early_terminate = true; + block->branch_type = vtn_branch_type_ignore_intersection; + return NULL; + + case SpvOpTerminateRayKHR: + b->has_early_terminate = true; + block->branch_type = vtn_branch_type_terminate_ray; return NULL; case SpvOpBranchConditional: { @@ -957,12 +969,25 @@ 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: { + case vtn_branch_type_terminate_invocation: { nir_intrinsic_instr *terminate = nir_intrinsic_instr_create(b->nb.shader, nir_intrinsic_terminate); nir_builder_instr_insert(&b->nb, &terminate->instr); break; } + case vtn_branch_type_ignore_intersection: { + nir_intrinsic_instr *ignore = + nir_intrinsic_instr_create(b->nb.shader, + nir_intrinsic_ignore_ray_intersection); + nir_builder_instr_insert(&b->nb, &ignore->instr); + break; + } + case vtn_branch_type_terminate_ray: { + nir_intrinsic_instr *terminate = + nir_intrinsic_instr_create(b->nb.shader, nir_intrinsic_terminate_ray); + 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 3d32db83312..7275fff0d59 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -139,7 +139,9 @@ 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_terminate_invocation, + vtn_branch_type_ignore_intersection, + vtn_branch_type_terminate_ray, vtn_branch_type_return, }; @@ -709,6 +711,8 @@ struct vtn_builder { * * - OpKill * - OpTerminateInvocation + * - OpIgnoreIntersectionKHR + * - OpTerminateRayKHR * * However, in NIR, they're represented by regular intrinsics with no * control-flow semantics. This means that the SSA form from the SPIR-V