pan/bi: Emit +ZS_EMIT as needed

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7446>
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index bf9b868..68fa13b 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -271,6 +271,29 @@
 }
 
 static void
+bi_emit_zs_emit(bi_context *ctx, unsigned z, unsigned stencil)
+{
+        bi_instruction ins = {
+                .type = BI_ZS_EMIT,
+                .src = {
+                        z,
+                        stencil,
+                        BIR_INDEX_REGISTER | 60 /* TODO: RA */,
+                },
+                .src_types = {
+                        nir_type_float32,
+                        nir_type_uint8,
+                        nir_type_uint32,
+                },
+                .swizzle = { { 0 }, { 0 }, { 0 } },
+                .dest = BIR_INDEX_REGISTER | 60 /* TODO: RA */,
+                .dest_type = nir_type_uint32,
+        };
+
+        bi_emit(ctx, ins);
+}
+
+static void
 bi_emit_frag_out(bi_context *ctx, nir_intrinsic_instr *instr)
 {
         bool combined = instr->intrinsic ==
@@ -291,7 +314,12 @@
         }
 
         if (emit_zs) {
-                unreachable("stub");
+                unsigned z = writeout & PAN_WRITEOUT_Z ?
+                        pan_src_index(&instr->src[2]) : 0;
+                unsigned s = writeout & PAN_WRITEOUT_S ?
+                        pan_src_index(&instr->src[3]) : 0;
+
+                bi_emit_zs_emit(ctx, z, s);
         }
 
         if (emit_blend) {