tu: Add missing code for immutable samplers
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 24 Mar 2020 17:00:21 +0000 (18:00 +0100)
committerMarge Bot <eric+marge@anholt.net>
Thu, 9 Apr 2020 15:56:55 +0000 (15:56 +0000)
Actually fill out the samplers, based on the radv implementation.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4358>

src/freedreno/vulkan/tu_descriptor_set.c

index f6327b85c50a46102aad88ab0dbd54d6861a37b6..d693ac45c30468177647ebd58a6e8ad9c6a54643 100644 (file)
@@ -489,6 +489,26 @@ tu_descriptor_set_create(struct tu_device *device,
          return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY);
    }
 
+   if (layout->has_immutable_samplers) {
+      for (unsigned i = 0; i < layout->binding_count; ++i) {
+         if (!layout->binding[i].immutable_samplers_offset)
+            continue;
+
+         unsigned offset = layout->binding[i].offset / 4;
+         if (layout->binding[i].type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
+            offset += A6XX_TEX_CONST_DWORDS;
+
+         const struct tu_sampler *samplers =
+            (const struct tu_sampler *)((const char *)layout +
+                               layout->binding[i].immutable_samplers_offset);
+         for (unsigned j = 0; j < layout->binding[i].array_size; ++j) {
+            memcpy(set->mapped_ptr + offset, samplers + j,
+                   sizeof(struct tu_sampler));
+            offset += layout->binding[i].size / 4;
+         }
+      }
+   }
+
    *out_set = set;
    return VK_SUCCESS;
 }