anv/descriptor_set: Fix descriptor copies
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 3 Feb 2016 10:50:06 +0000 (02:50 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 4 Feb 2016 06:44:33 +0000 (22:44 -0800)
We weren't pulling the actual binding location information out of the set
layout.  The new code mirrors the descriptor write code.

src/vulkan/anv_descriptor_set.c

index f93ea819b0c8bbbf907b22ca613b4e66397704d7..0ddd4bf1bc229adb1f0d836a6741d9e59aaf1862 100644 (file)
@@ -584,11 +584,21 @@ void anv_UpdateDescriptorSets(
    for (uint32_t i = 0; i < descriptorCopyCount; i++) {
       const VkCopyDescriptorSet *copy = &pDescriptorCopies[i];
       ANV_FROM_HANDLE(anv_descriptor_set, src, copy->dstSet);
-      ANV_FROM_HANDLE(anv_descriptor_set, dest, copy->dstSet);
-      for (uint32_t j = 0; j < copy->descriptorCount; j++) {
-         dest->descriptors[copy->dstBinding + j] =
-            src->descriptors[copy->srcBinding + j];
-      }
-      dest->buffer_count = src->buffer_count;
+      ANV_FROM_HANDLE(anv_descriptor_set, dst, copy->dstSet);
+
+      const struct anv_descriptor_set_binding_layout *src_layout =
+         &src->layout->binding[copy->srcBinding];
+      struct anv_descriptor *src_desc =
+         &src->descriptors[src_layout->descriptor_index];
+      src_desc += copy->srcArrayElement;
+
+      const struct anv_descriptor_set_binding_layout *dst_layout =
+         &dst->layout->binding[copy->dstBinding];
+      struct anv_descriptor *dst_desc =
+         &dst->descriptors[dst_layout->descriptor_index];
+      dst_desc += copy->dstArrayElement;
+
+      for (uint32_t j = 0; j < copy->descriptorCount; j++)
+         dst_desc[j] = src_desc[j];
    }
 }