dzn: Skip binding entries with zero descriptors
authorBoris Brezillon <boris.brezillon@collabora.com>
Mon, 11 Apr 2022 11:46:31 +0000 (04:46 -0700)
committerMarge Bot <emma+marge@anholt.net>
Thu, 14 Apr 2022 13:14:57 +0000 (13:14 +0000)
D3D12 doesn't like empty descriptor ranges, so let's skip those
at set layout creation time.

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15884>

src/microsoft/vulkan/dzn_descriptor_set.cpp

index 557e454..b98d513 100644 (file)
@@ -134,6 +134,11 @@ dzn_descriptor_set_layout_create(dzn_device *device,
    uint32_t range_count[MAX_SHADER_VISIBILITIES][NUM_POOL_TYPES] = {};
 
    for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) {
+      binding_count = MAX2(binding_count, bindings[i].binding + 1);
+
+      if (!bindings[i].descriptorCount)
+         continue;
+
       D3D12_SHADER_VISIBILITY visibility =
          translate_desc_visibility(bindings[i].stageFlags);
       VkDescriptorType desc_type = bindings[i].descriptorType;
@@ -189,8 +194,6 @@ dzn_descriptor_set_layout_create(dzn_device *device,
             dynamic_ranges_offset += bindings[i].descriptorCount * factor;
          }
       }
-
-      binding_count = MAX2(binding_count, bindings[i].binding + 1);
    }
 
    /* We need to allocate decriptor set layouts off the device allocator
@@ -321,6 +324,9 @@ dzn_descriptor_set_layout_create(dzn_device *device,
          assert(dynamic_buffer_idx <= MAX_DYNAMIC_BUFFERS);
       }
 
+      if (!ordered_bindings[i].descriptorCount)
+         continue;
+
       unsigned num_descs =
          num_descs_for_type(desc_type, has_static_sampler);
       if (!num_descs) continue;