vk/util: add macros for multidraw
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 30 Mar 2021 18:48:50 +0000 (14:48 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 22 Jun 2021 15:53:03 +0000 (15:53 +0000)
this simplifies implementations since a lot of the code is going to be
copy/pasted around, enabling related tweaks to be made in a centralized place

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11496>

src/vulkan/util/vk_util.h

index 946d922..b48a195 100644 (file)
@@ -255,6 +255,21 @@ mesa_to_vk_shader_stage(gl_shader_stage mesa_stage)
    return (VkShaderStageFlagBits) (1 << ((uint32_t) mesa_stage));
 }
 
+/* iterate over a sequence of indexed multidraws for VK_EXT_multi_draw extension */
+/* 'i' must be explicitly declared */
+#define vk_foreach_multi_draw_indexed(_draw, _i, _pDrawInfo, _num_draws, _stride) \
+   for (const VkMultiDrawIndexedInfoEXT *_draw = (const void*)(_pDrawInfo); \
+        (_i) < (_num_draws); \
+        (_i)++, (_draw) = (const VkMultiDrawIndexedInfoEXT*)((const uint8_t*)(_draw) + (_stride)))
+
+/* iterate over a sequence of multidraws for VK_EXT_multi_draw extension */
+/* 'i' must be explicitly declared */
+#define vk_foreach_multi_draw(_draw, _i, _pDrawInfo, _num_draws, _stride) \
+   for (const VkMultiDrawInfoEXT *_draw = (const void*)(_pDrawInfo); \
+        (_i) < (_num_draws); \
+        (_i)++, (_draw) = (const VkMultiDrawInfoEXT*)((const uint8_t*)(_draw) + (_stride)))
+
+
 #ifdef __cplusplus
 }
 #endif