aboutsummaryrefslogtreecommitdiffstats
path: root/src/panfrost
diff options
context:
space:
mode:
authorBoris Brezillon <[email protected]>2020-01-31 09:22:50 +0100
committerMarge Bot <[email protected]>2020-02-03 12:53:47 +0000
commitc68cd39eb3797eb34a049950cb34acfd0719cde7 (patch)
tree1c1b17ab0ef8c6c6064f439fb2b5544001e27bf8 /src/panfrost
parent25946be4c451fe1cc645a6fd3cb5d59160e93f25 (diff)
pan/midgard: Make sure we pass the right RT id to emit_fragment_store()
nir_intrinsic_base() is assigned nir_variable.data.driver_location, which is assigned a unique ID based on the variable position in the shader variable list. There's no guarantee that this position will match the RT id we want to pass to emit_fragment_store(). Add a search_var() helper to retrieve a nir_variable based on its driver location, so we can pass the right RT value to emit_fragment_store(). We also make sure the shader output is color, since emit_fragment_store() is not ready for depth/stencil stores yet. Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3676>
Diffstat (limited to 'src/panfrost')
-rw-r--r--src/panfrost/midgard/midgard_compile.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 604b7bf5f2a..76294c4c81a 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -1404,6 +1404,17 @@ emit_vertex_builtin(compiler_context *ctx, nir_intrinsic_instr *instr)
emit_attr_read(ctx, reg, vertex_builtin_arg(instr->intrinsic), 1, nir_type_int);
}
+static const nir_variable *
+search_var(struct exec_list *vars, unsigned driver_loc)
+{
+ nir_foreach_variable(var, vars) {
+ if (var->data.driver_location == driver_loc)
+ return var;
+ }
+
+ return NULL;
+}
+
static void
emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
{
@@ -1556,7 +1567,21 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
reg = nir_src_index(ctx, &instr->src[0]);
if (ctx->stage == MESA_SHADER_FRAGMENT) {
- emit_fragment_store(ctx, reg, offset);
+ const nir_variable *var;
+ enum midgard_rt_id rt;
+
+ var = search_var(&ctx->nir->outputs,
+ nir_intrinsic_base(instr));
+ assert(var);
+ if (var->data.location == FRAG_RESULT_COLOR)
+ rt = MIDGARD_COLOR_RT0;
+ else if (var->data.location >= FRAG_RESULT_DATA0)
+ rt = MIDGARD_COLOR_RT0 + var->data.location -
+ FRAG_RESULT_DATA0;
+ else
+ assert(0);
+
+ emit_fragment_store(ctx, reg, rt);
} else if (ctx->stage == MESA_SHADER_VERTEX) {
/* We should have been vectorized, though we don't
* currently check that st_vary is emitted only once