Mesa (master): pan/mdg: Support MRT in output load lowering
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jul 13 14:04:07 UTC 2020
Module: Mesa
Branch: master
Commit: 7781d2c2eadc52c6a21fac5ffc22614b43e61e72
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7781d2c2eadc52c6a21fac5ffc22614b43e61e72
Author: Icecream95 <ixn at keemail.me>
Date: Mon Jul 6 19:54:56 2020 +1200
pan/mdg: Support MRT in output load lowering
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5755>
---
src/panfrost/midgard/midgard_compile.c | 27 +++++++++++++++++++++++++++
src/panfrost/util/pan_lower_framebuffer.c | 13 +++++++++++--
2 files changed, 38 insertions(+), 2 deletions(-)
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);
More information about the mesa-commit
mailing list