anv: fix acceleration structure descriptor copies
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Mon, 7 Mar 2022 08:29:19 +0000 (10:29 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 11 Mar 2022 08:47:15 +0000 (08:47 +0000)
We're not supposed to have a
VkWriteDescriptorSetAccelerationStructureKHR when doing a copy. We
should instead get the acceleration structure object from the source
descriptor.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: 03e1e19246da ("anv: Refactor descriptor copy")
Reviewed-by: Rohan Garg <rohan.garg@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15241>

src/intel/vulkan/anv_descriptor_set.c
src/intel/vulkan/anv_private.h

index f23b3a8..22d6dc5 100644 (file)
@@ -1686,8 +1686,12 @@ anv_descriptor_set_write_acceleration_structure(struct anv_device *device,
    assert(bind_layout->data & ANV_DESCRIPTOR_ADDRESS_RANGE);
    *desc = (struct anv_descriptor) {
       .type = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
+      .accel_struct = accel,
    };
 
+   if (set->pool && !set->pool->allocate_surface_states)
+      return;
+
    struct anv_address_range_descriptor desc_data = { };
    if (accel != NULL) {
       desc_data.address = anv_address_physical(accel->address);
@@ -1867,13 +1871,8 @@ void anv_UpdateDescriptorSets(
          }
 
          case VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR: {
-            const VkWriteDescriptorSetAccelerationStructureKHR *accel_write =
-               vk_find_struct_const(dst_desc, WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR);
-            assert(accel_write->accelerationStructureCount ==
-                   copy->descriptorCount);
-            ANV_FROM_HANDLE(anv_acceleration_structure, accel, accel_write->pAccelerationStructures[j]);
             anv_descriptor_set_write_acceleration_structure(device, dst,
-                                                            accel,
+                                                            src_desc[j].accel_struct,
                                                             copy->dstBinding,
                                                             copy->dstArrayElement + j);
             break;
index 62b3a04..90ec212 100644 (file)
@@ -1921,6 +1921,8 @@ struct anv_descriptor {
       };
 
       struct anv_buffer_view *buffer_view;
+
+      struct anv_acceleration_structure *accel_struct;
    };
 };