<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jul 13, 2016 at 3:34 PM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Section 13.2.3. of the Vulkan spec requires that implementations be able to<br>
bind sparsely-defined Descriptor Sets without any errors or exceptions.<br>
<br>
When binding a descriptor set that contains a dynamic buffer binding/descriptor,<br>
the driver attempts to dereference the descriptor's buffer_view field if it is<br>
non-NULL. It currently segfaults on undefined descriptors as this field is never<br>
zero-initialized. Zero undefined descriptors to avoid segfaulting. This<br>
solution was suggested by Jason Ekstrand.<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=96850" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=96850</a><br>
Cc: 12.0 <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.org</a>><br>
Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
---<br>
 src/intel/vulkan/anv_descriptor_set.c | 9 +++++++--<br>
 1 file changed, 7 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c<br>
index 448ae0e..f06d2e4 100644<br>
--- a/src/intel/vulkan/anv_descriptor_set.c<br>
+++ b/src/intel/vulkan/anv_descriptor_set.c<br>
@@ -412,8 +412,8 @@ anv_descriptor_set_create(struct anv_device *device,<br>
    /* Go through and fill out immutable samplers if we have any */<br>
    struct anv_descriptor *desc = set->descriptors;<br>
    for (uint32_t b = 0; b < layout->binding_count; b++) {<br>
-      if (layout->binding[b].immutable_samplers) {<br>
-         for (uint32_t i = 0; i < layout->binding[b].array_size; i++) {<br>
+      for (uint32_t i = 0; i < layout->binding[b].array_size; i++) {<br>
+         if (layout->binding[b].immutable_samplers) {<br>
             /* The type will get changed to COMBINED_IMAGE_SAMPLER in<br>
              * UpdateDescriptorSets if needed.  However, if the descriptor<br>
              * set has an immutable sampler, UpdateDescriptorSets may never<br>
@@ -423,6 +423,11 @@ anv_descriptor_set_create(struct anv_device *device,<br>
                .type = VK_DESCRIPTOR_TYPE_SAMPLER,<br>
                .sampler = layout->binding[b].immutable_samplers[i],<br>
             };<br>
+         } else {<br>
+            /* By defining the descriptors to be zero now, we can later verify that<br>
+             * the descriptor has not been populated with user data.<br>
+             */<br>
+            zero(desc[i]);<br></blockquote><div><br></div><div>I think I'd rather just zero the whole thing rather than one descriptor at a time.  Given that the memset will use vectorized memory operations, it's almost certainly just as fast if not faster to do so and I think it's more clear.<br><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          }<br>
       }<br>
       desc += layout->binding[b].array_size;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>