[Mesa-dev] [PATCH v2 04/18] util/vk: Add helpers for finding an extension struct

Jason Ekstrand jason at jlekstrand.net
Tue Mar 14 02:26:06 UTC 2017


---
 src/util/vk_util.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/util/vk_util.h b/src/util/vk_util.h
index e0b5d0b..0b9cb47 100644
--- a/src/util/vk_util.h
+++ b/src/util/vk_util.h
@@ -40,4 +40,21 @@ struct vk_struct_common {
    for (const struct vk_struct_common *__iter = (const struct vk_struct_common *)(__start); \
         __iter; __iter = __iter->pNext)
 
+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 */
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list