From cfa5beeeab9565df814494ea873671ba6a6cd72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 15 Apr 2024 10:41:21 +0200 Subject: [PATCH] spirv: workaround for tests assuming that OpKill terminates invocations or loops Reviewed-by: Faith Ekstrand Part-of: --- src/compiler/spirv/vtn_structured_cfg.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/compiler/spirv/vtn_structured_cfg.c b/src/compiler/spirv/vtn_structured_cfg.c index 35a90d3d482..08ba4aa1f91 100644 --- a/src/compiler/spirv/vtn_structured_cfg.c +++ b/src/compiler/spirv/vtn_structured_cfg.c @@ -1256,10 +1256,19 @@ vtn_emit_branch(struct vtn_builder *b, const struct vtn_block *block, break; case vtn_branch_type_discard: - if (b->convert_discard_to_demote) + if (b->convert_discard_to_demote) { nir_demote(&b->nb); - else + + /* Workaround for outdated test cases from CTS and Tint which assume + * that OpKill always terminates the invocation. Break from the + * current loop if it exists in order to prevent infinite loops. + */ + struct vtn_construct *loop = block->parent->innermost_loop; + if (loop) + vtn_emit_break_for_construct(b, block, loop); + } else { nir_discard(&b->nb); + } break; case vtn_branch_type_terminate_invocation: