Mesa (main): vk/util: add macros for multidraw

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 22 16:11:54 UTC 2021


Module: Mesa
Branch: main
Commit: 6d0aceae4db45542f8d9531ec6e9ff5bee6ed282
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6d0aceae4db45542f8d9531ec6e9ff5bee6ed282

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Tue Mar 30 14:48:50 2021 -0400

vk/util: add macros for multidraw

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 at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11496>

---

 src/vulkan/util/vk_util.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/vulkan/util/vk_util.h b/src/vulkan/util/vk_util.h
index 946d92231bb..b48a1953d11 100644
--- a/src/vulkan/util/vk_util.h
+++ b/src/vulkan/util/vk_util.h
@@ -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



More information about the mesa-commit mailing list