From: Alyssa Rosenzweig Date: Fri, 6 Mar 2020 14:26:44 +0000 (-0500) Subject: pan/bi: Implement store_output for fragment shaders X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dabb6c6b9fd473b10ae9d63b96e7ef248b1a7ed1;p=mesa.git pan/bi: Implement store_output for fragment shaders Corresponds to a BLEND instruction, possibly preceded by an ATEST instruction. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 6a57adc4e53..922591279c5 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -88,6 +88,31 @@ bi_emit_ld_vary(bi_context *ctx, nir_intrinsic_instr *instr) bi_emit(ctx, ins); } +static void +bi_emit_frag_out(bi_context *ctx, nir_intrinsic_instr *instr) +{ + if (!ctx->emitted_atest) { + bi_instruction ins = { + .type = BI_ATEST + }; + + bi_emit(ctx, ins); + bi_schedule_barrier(ctx); + ctx->emitted_atest = true; + } + + bi_instruction blend = { + .type = BI_BLEND, + .blend_location = nir_intrinsic_base(instr), + .src = { + bir_src_index(&instr->src[0]) + } + }; + + bi_emit(ctx, blend); + bi_schedule_barrier(ctx); +} + static void emit_intrinsic(bi_context *ctx, nir_intrinsic_instr *instr) { @@ -99,6 +124,13 @@ emit_intrinsic(bi_context *ctx, nir_intrinsic_instr *instr) case nir_intrinsic_load_interpolated_input: bi_emit_ld_vary(ctx, instr); break; + case nir_intrinsic_store_output: + if (ctx->stage == MESA_SHADER_FRAGMENT) + bi_emit_frag_out(ctx, instr); + else { + /* TODO */ + } + break; default: /* todo */ break; diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 71d1b240059..cbd76d5e2d0 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -330,6 +330,7 @@ typedef struct { bi_block *after_block; bi_block *break_block; bi_block *continue_block; + bool emitted_atest; /* Stats for shader-db */ unsigned instruction_count;