panvk: Add a dummy sampler for NIR tex operations that don't take one
authorBoris Brezillon <boris.brezillon@collabora.com>
Thu, 23 Sep 2021 16:02:41 +0000 (18:02 +0200)
committerMarge Bot <emma+marge@anholt.net>
Mon, 14 Mar 2022 18:06:01 +0000 (18:06 +0000)
In the NIR domain, some texture operations don't require a sampler, but
Bifrost/Midgard always want one. Let's add a dummy sampler to handle
that case.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15334>

src/panfrost/vulkan/panvk_descriptor_set.c
src/panfrost/vulkan/panvk_vX_cmd_buffer.c

index 7240dd1..cdf9874 100644 (file)
@@ -340,6 +340,15 @@ panvk_CreatePipelineLayout(VkDevice _device,
    layout->num_dyn_ssbos = dyn_ssbo_idx;
    layout->num_imgs = img_idx;
 
+   /* Some NIR texture operations don't require a sampler, but Bifrost/Midgard
+    * ones always expect one. Add a dummy sampler to deal with this limitation.
+    */
+   if (layout->num_textures) {
+      layout->num_samplers++;
+      for (unsigned set = 0; set < pCreateInfo->setLayoutCount; set++)
+         layout->sets[set].sampler_offset++;
+   }
+
    _mesa_sha1_final(&ctx, layout->sha1);
 
    *pPipelineLayout = panvk_pipeline_layout_to_handle(layout);
index fbfe088..869d84a 100644 (file)
@@ -492,6 +492,18 @@ panvk_cmd_prepare_samplers(struct panvk_cmd_buffer *cmdbuf,
 
    void *sampler = samplers.cpu;
 
+   /* Prepare the dummy sampler */
+   pan_pack(sampler, SAMPLER, cfg) {
+#if PAN_ARCH >= 6
+      cfg.seamless_cube_map = false;
+#endif
+      cfg.magnify_nearest = true;
+      cfg.minify_nearest = true;
+      cfg.normalized_coordinates = false;
+   }
+
+   sampler += pan_size(SAMPLER);
+
    for (unsigned i = 0; i < ARRAY_SIZE(desc_state->sets); i++) {
       if (!desc_state->sets[i]) continue;