panvk: Handle input varyings without previous writes
authorBoris Brezillon <boris.brezillon@collabora.com>
Thu, 23 Sep 2021 11:10:28 +0000 (13:10 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 28 Sep 2021 14:03:40 +0000 (14:03 +0000)
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 <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13077>

src/panfrost/vulkan/panvk_vX_cs.c
src/panfrost/vulkan/panvk_vX_pipeline.c

index b270ff6..0f25b66 100644 (file)
@@ -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
    }
 }
 
index e7d1dde..f1bcbc5 100644 (file)
@@ -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);