From 6d3fce56801936ad66b540912f6e1593177b62b8 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Mon, 12 Oct 2020 14:26:47 +0200 Subject: [PATCH] panfrost: Scalarize nir_load_blend_const_color_rgba Bifrost is a scalar architecture, which means we can't load all components of the blend constant at once. We could add a lowering pass to scalarize nir_load_blend_const_color_rgba, but it's easier to handle that at when lowering the blend equations. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/nir/nir_lower_blend.c | 14 +++++++++++++- src/gallium/drivers/panfrost/nir/nir_lower_blend.h | 1 + src/gallium/drivers/panfrost/pan_blend_shaders.c | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/panfrost/nir/nir_lower_blend.c b/src/gallium/drivers/panfrost/nir/nir_lower_blend.c index a325a77fa87..40b1be5e341 100644 --- a/src/gallium/drivers/panfrost/nir/nir_lower_blend.c +++ b/src/gallium/drivers/panfrost/nir/nir_lower_blend.c @@ -266,7 +266,19 @@ nir_blend( return nir_blend_logicop(b, options, src, dst); /* Grab the blend constant ahead of time */ - nir_ssa_def *bconst = nir_load_blend_const_color_rgba(b); + nir_ssa_def *bconst; + if (options.is_bifrost) { + /* Bifrost is a scalar architecture, so let's split loads now to avoid a + * lowering pass. + */ + bconst = nir_vec4(b, + nir_load_blend_const_color_r_float(b), + nir_load_blend_const_color_g_float(b), + nir_load_blend_const_color_b_float(b), + nir_load_blend_const_color_a_float(b)); + } else { + bconst = nir_load_blend_const_color_rgba(b); + } if (options.half) bconst = nir_f2f16(b, bconst); diff --git a/src/gallium/drivers/panfrost/nir/nir_lower_blend.h b/src/gallium/drivers/panfrost/nir/nir_lower_blend.h index f015bba1473..7d89d8cfcee 100644 --- a/src/gallium/drivers/panfrost/nir/nir_lower_blend.h +++ b/src/gallium/drivers/panfrost/nir/nir_lower_blend.h @@ -56,6 +56,7 @@ typedef struct { /* Use fp16 instead of fp32 */ bool half; + bool is_bifrost; nir_ssa_def *src1; } nir_lower_blend_options; diff --git a/src/gallium/drivers/panfrost/pan_blend_shaders.c b/src/gallium/drivers/panfrost/pan_blend_shaders.c index fee3bbe24ca..e02f88251d0 100644 --- a/src/gallium/drivers/panfrost/pan_blend_shaders.c +++ b/src/gallium/drivers/panfrost/pan_blend_shaders.c @@ -25,6 +25,7 @@ #include #include "pan_blend_shaders.h" #include "pan_util.h" +#include "panfrost-quirks.h" #include "midgard/midgard_compile.h" #include "compiler/nir/nir_builder.h" #include "nir/nir_lower_blend.h" @@ -134,6 +135,7 @@ panfrost_create_blend_shader(struct panfrost_context *ctx, struct panfrost_blend_state *state, const struct panfrost_blend_shader_key *key) { + struct panfrost_device *dev = pan_device(ctx->base.screen); struct panfrost_blend_shader *res = rzalloc(ctx, struct panfrost_blend_shader); res->ctx = ctx; @@ -201,6 +203,7 @@ panfrost_create_blend_shader(struct panfrost_context *ctx, nir_lower_blend_options options = nir_make_options(&state->base, key->rt); options.format = key->format; + options.is_bifrost = !!(dev->quirks & IS_BIFROST); options.src1 = s_src[1]; if (T == nir_type_float16)