pan/bi: Check return addresses in blend shaders
authorAlyssa Rosenzweig <alyssa@collabora.com>
Thu, 17 Mar 2022 16:31:28 +0000 (12:31 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 25 Mar 2022 19:00:13 +0000 (19:00 +0000)
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 <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15223>

src/panfrost/bifrost/bifrost_compile.c

index ca921e9..fd7d2f1 100644 (file)
@@ -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));
         }
 }