anv/descriptor_set: Initialize immutable_samplers to NULL
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 16 Dec 2015 00:24:19 +0000 (16:24 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 16 Dec 2015 00:24:22 +0000 (16:24 -0800)
Previously this wasn't a problem.  However, with the new API update,
descriptor sets can now be sparse so the client doesn't have to provide an
entry for every binding.  This means that it's possible for a binding to be
uninitialized other than the memset.  In that case, we want to have a null
array of immutable samplers.

src/vulkan/anv_descriptor_set.c

index a7b6b7730123b0739e10ce83c8dd12c191c5a545..904051b4f130f714b9b8993c9809d0eef0100134 100644 (file)
@@ -70,9 +70,12 @@ VkResult anv_CreateDescriptorSetLayout(
    set_layout->shader_stages = 0;
    set_layout->size = 0;
 
-   /* Initialize all binding_layout entries to -1 */
-   memset(set_layout->binding, -1,
-          (max_binding + 1) * sizeof(set_layout->binding[0]));
+   for (uint32_t b = 0; b <= max_binding; b++) {
+      /* Initialize all binding_layout entries to -1 */
+      memset(&set_layout->binding[b], -1, sizeof(set_layout->binding[b]));
+
+      set_layout->binding[b].immutable_samplers = NULL;
+   }
 
    /* Initialize all samplers to 0 */
    memset(samplers, 0, immutable_sampler_count * sizeof(*samplers));