<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Oct 6, 2016 at 6:12 AM, Emil Velikov <span dir="ltr"><<a href="mailto:emil.l.velikov@gmail.com" target="_blank">emil.l.velikov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Emil Velikov <<a href="mailto:emil.velikov@collabora.com">emil.velikov@collabora.com</a>><br>
<br>
Driver should enumerate only up-to min2(num_available, num_requested)<br>
properties and return VK_INCOMPLETE if the # of requested props is<br>
smaller than the ones available.<br></blockquote><div><br></div><div>Thanks for fixing this!<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Presently we assert out in such cases.<br>
<br>
Inspired by a similar fix for RADV.<br>
<br>
Should fix: dEQP-VK.api.info.device.<wbr>extensions<br>
Signed-off-by: Emil Velikov <<a href="mailto:emil.velikov@collabora.com">emil.velikov@collabora.com</a>><br>
---<br>
 src/intel/vulkan/anv_device.c | 20 ++++++++++++++------<br>
 1 file changed, 14 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_device.<wbr>c b/src/intel/vulkan/anv_device.<wbr>c<br>
index c7b9979..497bf9f 100644<br>
--- a/src/intel/vulkan/anv_device.<wbr>c<br>
+++ b/src/intel/vulkan/anv_device.<wbr>c<br>
@@ -1003,15 +1003,19 @@ VkResult anv_<wbr>EnumerateInstanceExtensionProp<wbr>erties(<br>
     uint32_t*                                   pPropertyCount,<br>
     VkExtensionProperties*                      pProperties)<br>
 {<br>
+   unsigned i;<br>
+<br>
    if (pProperties == NULL) {<br>
       *pPropertyCount = ARRAY_SIZE(global_extensions);<br>
       return VK_SUCCESS;<br>
    }<br>
<br>
-   assert(*pPropertyCount >= ARRAY_SIZE(global_extensions))<wbr>;<br>
+   for (i = 0; i < MIN2(*pPropertyCount, ARRAY_SIZE(global_extensions))<wbr>; i++)<br>
+      memcpy(&pProperties[i], &global_extensions[i], sizeof(VkExtensionProperties))<wbr>;<br></blockquote><div><br></div><div>We can do this a bit easier using type typed_memcpy helper.  Perhaps something like this:<br><br></div><div>*pPropertyCount = MIN2(*pPropertyCount, ARRAY_SIZE(global_extensions));<br></div><div>typed_memcpy(pProperties, global_extensions, *pPropertyCount);<br><br></div><div>if (*pPropertyCount < ARRAY_SIZE(global_extensions))<br></div><div>   return VK_INCOMPLETE;<br></div><div><br></div><div>I don't know.  Maybe that's not any better.  Either way,<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div>Cc: "13.0" <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.org</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
-   *pPropertyCount = ARRAY_SIZE(global_extensions);<br>
-   memcpy(pProperties, global_extensions, sizeof(global_extensions));<br>
+   *pPropertyCount = i;<br>
+   if (i < ARRAY_SIZE(global_extensions))<br>
+      return VK_INCOMPLETE;<br>
<br>
    return VK_SUCCESS;<br>
 }<br>
@@ -1022,15 +1026,19 @@ VkResult anv_<wbr>EnumerateDeviceExtensionProper<wbr>ties(<br>
     uint32_t*                                   pPropertyCount,<br>
     VkExtensionProperties*                      pProperties)<br>
 {<br>
+   unsigned i;<br>
+<br>
    if (pProperties == NULL) {<br>
       *pPropertyCount = ARRAY_SIZE(device_extensions);<br>
       return VK_SUCCESS;<br>
    }<br>
<br>
-   assert(*pPropertyCount >= ARRAY_SIZE(device_extensions))<wbr>;<br>
+   for (i = 0; i < MIN2(*pPropertyCount, ARRAY_SIZE(device_extensions))<wbr>; i++)<br>
+      memcpy(&pProperties[i], &device_extensions[i], sizeof(VkExtensionProperties))<wbr>;<br>
<br>
-   *pPropertyCount = ARRAY_SIZE(device_extensions);<br>
-   memcpy(pProperties, device_extensions, sizeof(device_extensions));<br>
+   *pPropertyCount = i;<br>
+   if (i < ARRAY_SIZE(device_extensions))<br>
+      return VK_INCOMPLETE;<br>
<br>
    return VK_SUCCESS;<br>
 }<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.3<br>
<br>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>