util/vk: Add helpers for finding an extension struct
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 14 Mar 2017 02:26:06 +0000 (19:26 -0700)
committerDave Airlie <airlied@redhat.com>
Tue, 14 Mar 2017 22:22:02 +0000 (08:22 +1000)
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/util/vk_util.h

index 589d5c6f5d55bcda248fa233c9c3885df1906539..5ff1f00195c2ad44dfc9a7b0a0df6f5a79d5e505 100644 (file)
@@ -180,4 +180,21 @@ __vk_outarray_next(struct __vk_outarray *a, size_t elem_size)
    for (vk_outarray_typeof_elem(a) *elem = vk_outarray_next(a); \
         elem != NULL; elem = NULL)
 
+static inline void *
+__vk_find_struct(void *start, VkStructureType sType)
+{
+   vk_foreach_struct(s, start) {
+      if (s->sType == sType)
+         return s;
+   }
+
+   return NULL;
+}
+
+#define vk_find_struct(__start, __sType) \
+   __vk_find_struct((__start), VK_STRUCTURE_TYPE_##__sType)
+
+#define vk_find_struct_const(__start, __sType) \
+   (const void *)__vk_find_struct((void *)(__start), VK_STRUCTURE_TYPE_##__sType)
+
 #endif /* VK_UTIL_H */