From: Icecream95 Date: Mon, 6 Jul 2020 07:54:56 +0000 (+1200) Subject: pan/mdg: Support MRT in output load lowering X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7781d2c2eadc52c6a21fac5ffc22614b43e61e72;p=mesa.git pan/mdg: Support MRT in output load lowering Reviewed-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index 5d5ffe50ce6..dc878c65f44 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -1614,6 +1614,29 @@ mir_get_branch_cond(nir_src *src, bool *invert) return nir_src_index(NULL, &alu.src); } +static uint8_t +output_load_rt_addr(nir_shader *nir, nir_intrinsic_instr *instr) +{ + const nir_variable *var; + var = search_var(&nir->outputs, nir_intrinsic_base(instr)); + assert(var); + + unsigned loc = var->data.location; + + if (loc == FRAG_RESULT_COLOR) + loc = FRAG_RESULT_DATA0; + + if (loc >= FRAG_RESULT_DATA0) + return loc - FRAG_RESULT_DATA0; + + if (loc == FRAG_RESULT_DEPTH) + return 0x1F; + if (loc == FRAG_RESULT_STENCIL) + return 0x1E; + + assert(0); +} + static void emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr) { @@ -1726,6 +1749,8 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr) midgard_instruction ld = m_ld_color_buffer_32u(reg, 0); + ld.load_store.arg_2 = output_load_rt_addr(ctx->nir, instr); + if (ctx->quirks & MIDGARD_OLD_BLEND) { ld.load_store.op = midgard_op_ld_color_buffer_32u_old; ld.load_store.address = 16; @@ -1741,6 +1766,8 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr) midgard_instruction ld = m_ld_color_buffer_as_fp16(reg, 0); + ld.load_store.arg_2 = output_load_rt_addr(ctx->nir, instr); + for (unsigned c = 4; c < 16; ++c) ld.swizzle[0][c] = 0; diff --git a/src/panfrost/util/pan_lower_framebuffer.c b/src/panfrost/util/pan_lower_framebuffer.c index 5955cf024e2..6fdb9695b37 100644 --- a/src/panfrost/util/pan_lower_framebuffer.c +++ b/src/panfrost/util/pan_lower_framebuffer.c @@ -646,6 +646,8 @@ pan_lower_fb_load(nir_shader *shader, nir_intrinsic_load_raw_output_pan); new->num_components = 4; + nir_intrinsic_set_base(new, base); + nir_ssa_dest_init(&new->instr, &new->dest, 4, 32, NULL); nir_builder_instr_insert(b, &new->instr); @@ -714,11 +716,18 @@ pan_lower_framebuffer(nir_shader *shader, enum pipe_format *rt_fmts, if (var->data.mode != nir_var_shader_out) continue; - if (var->data.location != FRAG_RESULT_COLOR) + unsigned base = var->data.driver_location; + + unsigned rt; + if (var->data.location == FRAG_RESULT_COLOR) + rt = 0; + else if (var->data.location >= FRAG_RESULT_DATA0) + rt = var->data.location - FRAG_RESULT_DATA0; + else continue; const struct util_format_description *desc = - util_format_description(rt_fmts[0]); + util_format_description(rt_fmts[rt]); enum pan_format_class fmt_class = pan_format_class(desc, quirks, is_store);