radv: ignore redundant variable descriptor counts (v2)
authorIshi Tatsuyuki <ishitatsuyuki@gmail.com>
Thu, 24 Jun 2021 12:12:48 +0000 (21:12 +0900)
committerMarge Bot <eric+marge@anholt.net>
Tue, 29 Jun 2021 09:29:40 +0000 (09:29 +0000)
The Vulkan specification says: "If VkDescriptorSetAllocateInfo::pSetLayouts[i]
does not include a variable count descriptor binding, then
pDescriptorCounts[i] is ignored". The previous code triggered an assertion
in such cases, and this patch fixes it.

v2: removed the offending assertion that is now always satisfied and
    reworded the commit message with a reference to Vulkan spec.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4992
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11576>

src/amd/vulkan/radv_descriptor_set.c

index f2a999d..409145e 100644 (file)
@@ -578,7 +578,6 @@ radv_descriptor_set_create(struct radv_device *device, struct radv_descriptor_po
    set->header.buffer_count = buffer_count;
    uint32_t layout_size = layout->size;
    if (variable_count) {
-      assert(layout->has_variable_descriptors);
       uint32_t stride = layout->binding[layout->binding_count - 1].size;
       if (layout->binding[layout->binding_count - 1].type ==
           VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT)
@@ -885,7 +884,7 @@ radv_AllocateDescriptorSets(VkDevice _device, const VkDescriptorSetAllocateInfo
       RADV_FROM_HANDLE(radv_descriptor_set_layout, layout, pAllocateInfo->pSetLayouts[i]);
 
       const uint32_t *variable_count = NULL;
-      if (variable_counts) {
+      if (layout->has_variable_descriptors && variable_counts) {
          if (i < variable_counts->descriptorSetCount)
             variable_count = variable_counts->pDescriptorCounts + i;
          else