From 6433fedcf1c09174b7ee6137775f5340ffa6120b Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 4 Nov 2020 09:05:39 -0500 Subject: [PATCH] pan/bi: Emit +ZS_EMIT as needed Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 30 +++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index bf9b868596c..68fa13ba1a1 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -270,6 +270,29 @@ bi_emit_blend(bi_context *ctx, unsigned rgba, nir_alu_type T, unsigned rt) bi_emit(ctx, blend); } +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) { @@ -291,7 +314,12 @@ bi_emit_frag_out(bi_context *ctx, nir_intrinsic_instr *instr) } 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) {