From d43912b18865b45db0ac72ec1e3e02ca7500d9ea Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 23 Sep 2021 13:10:28 +0200 Subject: [PATCH] panvk: Handle input varyings without previous writes Some input varyings might not be written by any of the active stages preceding the stage reading the varying (e.g. gl_Layer should be set to 0 when not written by vertex/geometry shaders). In this case, we can insert a dummy varying attribute returning zero. This is actually what the code intended to do, but 2 things were missing: 1. formats[NONE] is not mapping to the CONSTANT0 format 2. the offset and strides should always be set to 0 when using a CONSTANT0 attribute All of this is needed to have the input attachments working. Indeed, we use the nir_lower_input_attachments() pass which lowers input attachment loads to texel fetches, and the txf operation is passed the layer_id in its 3rd coordinate. Signed-off-by: Boris Brezillon Reviewed-by: Tomeu Vizoso Part-of: --- src/panfrost/vulkan/panvk_vX_cs.c | 8 +++++++- src/panfrost/vulkan/panvk_vX_pipeline.c | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/panfrost/vulkan/panvk_vX_cs.c b/src/panfrost/vulkan/panvk_vX_cs.c index b270ff6fb7e..0f25b66242f 100644 --- a/src/panfrost/vulkan/panvk_vX_cs.c +++ b/src/panfrost/vulkan/panvk_vX_cs.c @@ -116,7 +116,13 @@ panvk_varying_hw_format(const struct panvk_device *dev, panfrost_get_default_swizzle(4); default: assert(!panvk_varying_is_builtin(stage, loc)); - return pdev->formats[varyings->varying[loc].format].hw; + if (varyings->varying[loc].format != PIPE_FORMAT_NONE) + return pdev->formats[varyings->varying[loc].format].hw; +#if PAN_ARCH >= 7 + return (MALI_CONSTANT << 12) | MALI_RGB_COMPONENT_ORDER_0000; +#else + return (MALI_CONSTANT << 12) | PAN_V6_SWIZZLE(0, 0, 0, 0); +#endif } } diff --git a/src/panfrost/vulkan/panvk_vX_pipeline.c b/src/panfrost/vulkan/panvk_vX_pipeline.c index e7d1dde5fd0..f1bcbc50e80 100644 --- a/src/panfrost/vulkan/panvk_vX_pipeline.c +++ b/src/panfrost/vulkan/panvk_vX_pipeline.c @@ -827,6 +827,9 @@ panvk_pipeline_builder_collect_varyings(struct panvk_pipeline_builder *builder, /* TODO: Xfb */ gl_varying_slot loc; BITSET_FOREACH_SET(loc, pipeline->varyings.active, VARYING_SLOT_MAX) { + if (pipeline->varyings.varying[loc].format == PIPE_FORMAT_NONE) + continue; + enum panvk_varying_buf_id buf_id = panvk_varying_buf_id(false, loc); unsigned buf_idx = panvk_varying_buf_index(&pipeline->varyings, buf_id);