diff --git a/src/freedreno/ir3/ir3.c b/src/freedreno/ir3/ir3.c index 804acc761b5..9dca30d54f6 100644 --- a/src/freedreno/ir3/ir3.c +++ b/src/freedreno/ir3/ir3.c @@ -112,6 +112,16 @@ should_double_threadsize(struct ir3_shader_variant *v, unsigned regs_count) { const struct ir3_compiler *compiler = v->shader->compiler; + + /* We can't support more than compiler->branchstack_size diverging threads + * in a wave. Thus, doubling the threadsize is only possible if we don't + * exceed the branchstack size limit. + */ + if (MIN2(v->branchstack, compiler->threadsize_base * 2) > + compiler->branchstack_size) { + return false; + } + switch (v->type) { case MESA_SHADER_COMPUTE: { unsigned threads_per_wg = v->local_size[0] * v->local_size[1] * v->local_size[2];