From c4400b05be1aa68168e924066b9d05401745a879 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Fri, 1 May 2020 07:36:31 +0200 Subject: [PATCH] panfrost: GPUs newer than G-71 don't have swizzles... for attributes and varyings. Signed-off-by: Tomeu Vizoso Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_assemble.c | 16 +++++++++++++--- src/gallium/drivers/panfrost/pan_cmdstream.c | 6 +++++- src/gallium/drivers/panfrost/pan_context.c | 18 +++++++++++++++--- src/panfrost/encoder/pan_texture.h | 7 +++++++ src/panfrost/include/panfrost-quirks.h | 8 +++++++- 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c index 4c047c76a84..25d8ec4f7ae 100644 --- a/src/gallium/drivers/panfrost/pan_assemble.c +++ b/src/gallium/drivers/panfrost/pan_assemble.c @@ -226,9 +226,19 @@ panfrost_shader_compile(struct panfrost_context *ctx, for (unsigned i = 0; i < BIFROST_MAX_RENDER_TARGET_COUNT; i++) state->blend_types[i] = bifrost_blend_type_from_nir(program.blend_types[i]); - unsigned default_vec1_swizzle = panfrost_get_default_swizzle(1); - unsigned default_vec2_swizzle = panfrost_get_default_swizzle(2); - unsigned default_vec4_swizzle = panfrost_get_default_swizzle(4); + unsigned default_vec1_swizzle; + unsigned default_vec2_swizzle; + unsigned default_vec4_swizzle; + + if (dev->quirks & HAS_SWIZZLES) { + default_vec1_swizzle = panfrost_get_default_swizzle(1); + default_vec2_swizzle = panfrost_get_default_swizzle(2); + default_vec4_swizzle = panfrost_get_default_swizzle(4); + } else { + default_vec1_swizzle = panfrost_bifrost_swizzle(1); + default_vec2_swizzle = panfrost_bifrost_swizzle(2); + default_vec4_swizzle = panfrost_bifrost_swizzle(4); + } /* Record the varying mapping for the command stream's bookkeeping */ diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 02e15d6c8e5..7012f068981 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -1837,7 +1837,11 @@ panfrost_emit_varying_descriptor(struct panfrost_batch *batch, /* Set the type appropriately. TODO: Integer varyings XXX */ assert(o->stream == 0); ovs[i].format = pan_xfb_format(o->num_components); - ovs[i].swizzle = panfrost_get_default_swizzle(o->num_components); + + if (device->quirks & HAS_SWIZZLES) + ovs[i].swizzle = panfrost_get_default_swizzle(o->num_components); + else + ovs[i].swizzle = panfrost_bifrost_swizzle(o->num_components); /* Link to the fragment */ signed fs_idx = -1; diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 7ff551d093b..c8af10729c9 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -503,6 +503,7 @@ panfrost_create_vertex_elements_state( const struct pipe_vertex_element *elements) { struct panfrost_vertex_state *so = CALLOC_STRUCT(panfrost_vertex_state); + struct panfrost_device *dev = pan_device(pctx->screen); so->num_elements = num_elements; memcpy(so->pipe, elements, sizeof(*elements) * num_elements); @@ -513,16 +514,27 @@ panfrost_create_vertex_elements_state( enum pipe_format fmt = elements[i].src_format; const struct util_format_description *desc = util_format_description(fmt); so->hw[i].unknown1 = 0x2; - so->hw[i].swizzle = panfrost_translate_swizzle_4(desc->swizzle); + + if (dev->quirks & HAS_SWIZZLES) + so->hw[i].swizzle = panfrost_translate_swizzle_4(desc->swizzle); + else + so->hw[i].swizzle = panfrost_bifrost_swizzle(desc->nr_channels); so->hw[i].format = panfrost_find_format(desc); } /* Let's also prepare vertex builtins */ so->hw[PAN_VERTEX_ID].format = MALI_R32UI; - so->hw[PAN_VERTEX_ID].swizzle = panfrost_get_default_swizzle(1); + if (dev->quirks & HAS_SWIZZLES) + so->hw[PAN_VERTEX_ID].swizzle = panfrost_get_default_swizzle(1); + else + so->hw[PAN_VERTEX_ID].swizzle = panfrost_bifrost_swizzle(1); + so->hw[PAN_INSTANCE_ID].format = MALI_R32UI; - so->hw[PAN_INSTANCE_ID].swizzle = panfrost_get_default_swizzle(1); + if (dev->quirks & HAS_SWIZZLES) + so->hw[PAN_INSTANCE_ID].swizzle = panfrost_get_default_swizzle(1); + else + so->hw[PAN_INSTANCE_ID].swizzle = panfrost_bifrost_swizzle(1); return so; } diff --git a/src/panfrost/encoder/pan_texture.h b/src/panfrost/encoder/pan_texture.h index 591efd86c68..b0238aeb888 100644 --- a/src/panfrost/encoder/pan_texture.h +++ b/src/panfrost/encoder/pan_texture.h @@ -147,6 +147,13 @@ panfrost_get_default_swizzle(unsigned components) } } +static inline unsigned +panfrost_bifrost_swizzle(unsigned components) +{ + /* Set all components to 0 and force w if needed */ + return components < 4 ? 0x10 : 0x00; +} + enum mali_format panfrost_format_to_bifrost_blend(const struct util_format_description *desc); diff --git a/src/panfrost/include/panfrost-quirks.h b/src/panfrost/include/panfrost-quirks.h index c8d631cd476..e45191fe11a 100644 --- a/src/panfrost/include/panfrost-quirks.h +++ b/src/panfrost/include/panfrost-quirks.h @@ -47,9 +47,12 @@ /* What it says on the tin */ #define IS_BIFROST (1 << 3) +/* What it says on the tin */ +#define HAS_SWIZZLES (1 << 4) + /* Quirk collections common to particular uarchs */ -#define MIDGARD_QUIRKS (MIDGARD_BROKEN_FP16) +#define MIDGARD_QUIRKS (MIDGARD_BROKEN_FP16 | HAS_SWIZZLES) #define BIFROST_QUIRKS (IS_BIFROST) @@ -73,6 +76,9 @@ panfrost_get_quirks(unsigned gpu_id) case 0x880: return MIDGARD_QUIRKS; + case 0x6000: /* G71 */ + return BIFROST_QUIRKS | HAS_SWIZZLES; + case 0x7093: /* G31 */ case 0x7212: /* G52 */ return BIFROST_QUIRKS; -- 2.30.2