summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@collabora.com>2020-10-12 14:26:47 +0200
committerBoris Brezillon <boris.brezillon@collabora.com>2020-10-15 08:05:23 +0200
commit6d3fce56801936ad66b540912f6e1593177b62b8 (patch)
tree41e13b6c0586ea750d43ae752122db31ce033d44
parent8d707cd91833f50a1111bf4481378ee99069befe (diff)
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 <boris.brezillon@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7151>
-rw-r--r--src/gallium/drivers/panfrost/nir/nir_lower_blend.c14
-rw-r--r--src/gallium/drivers/panfrost/nir/nir_lower_blend.h1
-rw-r--r--src/gallium/drivers/panfrost/pan_blend_shaders.c3
3 files changed, 17 insertions, 1 deletions
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 <stdio.h>
#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)