From c7f6b973b210fd27ae677f7cc907cbbdde3cdbe6 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 17 Mar 2022 12:31:28 -0400 Subject: [PATCH] pan/bi: Check return addresses in blend shaders Required on Valhall, where jumping to 0x0 doesn't automatically terminate the program. Luckily the check is free there too. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index ca921e9c42a..fd7d2f10879 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -674,9 +674,15 @@ bi_emit_fragment_out(bi_builder *b, nir_intrinsic_instr *instr) if (b->shader->inputs->is_blend) { /* Jump back to the fragment shader, return address is stored - * in r48 (see above). + * in r48 (see above). On Valhall, only jump if the address is + * nonzero. The check is free there and it implements the "jump + * to 0 terminates the blend shader" that's automatic on + * Bifrost. */ - bi_jump(b, bi_register(48)); + if (b->shader->arch >= 8) + bi_branchzi(b, bi_register(48), bi_register(48), BI_CMPF_NE); + else + bi_jump(b, bi_register(48)); } }